Why I still can't display Emoji?

I have searched on this forum about emoji and found only a few topics about it. People usually refer to this post but I, somehow, cannot make it work! Here is my code: Also,*I have the font inside the data folder already.

`PFont myFont;
String emoji = new String(Character.toChars(unhex("1F601")));


void setup(){
size(200,100);
  //String[] fontList = PFont.list();
  //println(fontList);
  myFont = createFont("Apple Color Emoji", 24);
  textFont(myFont);
  //s="0x1f602";
}

void draw(){
  background(0);
  fill(255);
text(new String(Character.toChars(0x1F601)), 30, 30); // didn't work!
text("\u1F601", width/2, height/2);// didn't work!
text(emoji, width/2, height/2);// didn't work!
text(new String(Character.toChars(0x201D2)), width/2, height/2);// didn't work!
}
`

I try several ways as you can see on text() but all of them gave me the rectangle icon.

Tagged:

Answers

  • here is how I treat unicode

    PFont myFont;
    
    String emoji = "";
    
    
    void setup() {
      size(1400, 400);
    
      String[] fontList = PFont.list();
      printArray(fontList); // !!!!!!!!!!!!!
    
      myFont = createFont("Apple Color Emoji", 24);
    
      textFont(myFont);
    }
    
    void draw() {
      background(0);
      fill(255);
    
      textSize(15);
      for (int i=199; i<2256; i++) 
        text(char(i), 30+(i-199)*24, 23);
    
      textSize(85);
      emoji =  str((char)0x1F601);
      text(emoji, width/2+100, height/2);
    
      text( str((char)0x25BC), width/2+200, height/2);
    }
    
  • size(444, 444);
    
    textSize(33);
    String Text1 = str((char)0x25B2) ; //"";
    String Text2 =  str((char)0x25BC); 
    
    text (Text1, 99, 99);
    text (Text2, 199, 99);
    
  • Hi, Thank you for replying. Yes, it came out as unicode. I wonder if you know how to display emoji then. I am still stuck on that point.

  • edited February 2018

    Is this how it suppose to come out?

  • the first longer program shows sign ~ and then the arrow

    I don't have the font "Apple Color Emoji"- do you have it? Does it work in Word?

    in processing: in menu Tools there is a command Create Font

    maybe you need to use this

  • @Chrisir Yes I have it and it does work in every program but Processing. I did not have it in my Font book at first although I can type by selecting (option+Shift+Spacebar) in Mac. I could not find it anywhere in the actual finder so I download it (weird?). The file called Apple Color Emoji.ttc. I have installed it and now it is .ttf. I have tried put it in 'data' folder too.

    Your suggestion to create this font make it to .vlw, still doesn't work.

  • Did you try this using the vlw file:

    PFont font;
    // The font must be located in the sketch's 
    // "data" directory to load successfully
    font = loadFont("LetterGothicStd-32.vlw");
    textFont(font, 32);
    text("word", 10, 50);
    

    and then my code?

  • Do you mean if I should try that font? "LetterGothicStd-32.vlw ? No, I have not. but I did try other type of font.

    Someone just gave me the font called "OpenSansEmoji.ttf". and it can read the emoji in black and white instead of color. So it solved 1 level of problem; left only another one. Use this with "emoji-java-4.0.0.jar" and "java-jason.jar" by throw them into the IDE, it will create the "code" folder. In the code do call the lib.

        `import org.json.JSONArray;
    void setup() {
      size(500, 500);
      background(255);
      noLoop();
      String str = "An :grinning:awesome :smiley:string &#128516;with a few :wink:emojis!";
      String result = EmojiParser.parseToUnicode(str);
    
    fill(0);
      textFont(createFont("OpenSansEmoji.ttf", 14, true));
      textSize(20);
      text(result, 10, 150);`
    

    Anyway, thing is I receive twitter API so I can display the emoji in B/W but in the console of processing it doesn't display what is the number so I cannot compare with the .cvs file to generate something else. However, in Eclipse which is a JAVA software the text can be display in the console in emoji pic. LOL. funny enough I still do not know what is the code anyway but I got the pic in Eclipse's console.

    I have not had time left to work on this but, might be back to figure it out how to get number code from Twitter API so I can use this for something creative.

    Thank you so much for your help! I appreciate that you want to solve this problem with me :D

  • strange...

Sign In or Register to comment.