UTF32 and WINDOWS TT fonts not listed in the Create a Font box

bpsbps
edited April 2015 in Programming Questions

Being new to Processing as I am and wishing to write a natural language processing program for a very dead language (Mycenaean Linear B), I have several questions. I have a TT font that will display the MLB script. How can I use it in Processing? The language is encoded in UTF-32 unlike almost everything else. Does this pose any problems? How do I declare it in a program?

Answers

  • edited October 2014

    Got no experience but I guess a UTF-32 text would need an int[] array in order to store each code point.
    Since Java's String is UTF-16, any code point above a certain limit gotta be converted into 2 char values.
    Check it out my lousy attempt on it and see whether it's any help: :-??

    // forum.processing.org/two/discussion/7513/
    // utf32-and-windows-tt-fonts-not-listed-in-the-create-a-font-box
    
    size(200, 150, JAVA2D);
    noLoop();
    background(0);
    fill(#FFFF00);
    
    textFont(createFont("DejaVu Sans Bold", 050, true));
    textAlign(CENTER, CENTER);
    println(PFont.list());
    
    final int[] UTF32 = {
      0x1F608, 0x1F604, 0x1F607
    };
    
    String s = new String(UTF32, 0, UTF32.length);
    text(s, width>>1, height>>1);
    
    println(s.length());
    println(s.codePointCount(0, s.length()));
    
  • You asked the question in a p5.js category, so is the question targeting specifically JS or is it a Java question? In the latter case, edit your question to move to a proper category (How To, likely, or Programming Question perhaps).

    I think Java's String is able to handle surrogates to manipulate UTF-32 entities, and that the \u notation can work for such characters, but this has to be checked (no time right now).

  • Once again, being new to this forum, I wasn't sure where to post. I just saw some string related questions and posted there. Sorry. BYW, my query was not about JAVA but about PROCESSING. I do not want to write JAVA code.

  • edited October 2014

    Processing isn't a programming language per se but merely a framework!
    What is known as Java Mode is Processing framework atop Java language! :-B
    Of course, there are other Processing framework implementations for other programming languages too.

  • void setup() 
    {
      size(500, 500);
      PFont f = createFont("Segoe UI Symbol", 64); // Font with the character I use
      textFont(f, 64);
      String c = new String(Character.toChars(0x0001D356));
      text(">" + c + "<", 200, 200);
    }
    

    See http://www.oracle.com/us/technologies/java/supplementary-142654.html for more information.

Sign In or Register to comment.