question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Emojis are not rendering

See original GitHub issue

English characters render, but emojis don’t. I have loaded a font with emojis.

Issue details

https://stackoverflow.com/questions/58635857/how-to-render-an-emoji-with-libgdx

Reproduction steps/code

FileHandle fontFile = Gdx.files.internal("path/to/file.ttf");
FreeTypeFontGenerator g = new FreeTypeFontGenerator(fontFile);
FreeTypeFontGenerator.FreeTypeFontParameter p = new FreeTypeFontGenerator.FreeTypeFontParameter();
// Some config here with p
BitmapFont emojiFont= g.generateFont(p);

public static void renderFont(SpriteBatch sb, BitmapFont font, String msg, float x, float y, Color c) {
  font.setColor(c);
  font.draw(sb, msg, x, y);
}

String str = "emoji ❤ \uD83D\uDC49 test \uD83D\uDC49 \uD83D\uDC4D test \uD83D\uDE03"
renderFont(sb, emojiFont, str, x, y, new Color(-597249));

Version of LibGDX and/or relevant dependencies

1.9.2

Please select the affected platforms

  • [ x] Windows

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
talukscommented, Dec 19, 2019

would be nice add point code support for font and label. when i try add code point (int type) to font i get error BitmapFontData bitmapFontData = new BitmapFontData(); bitmapFontData.setGlyph(0x1F60B, new Glyph());

java.lang.ArrayIndexOutOfBoundsException: 251 at com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.setGlyph(BitmapFont.java:744)

and then we can easy to add custom emoji and stickers. for example https://github.com/taluks/libgdx-emodji

2reactions
DavidPDevcommented, Jan 14, 2020

I have been doing some “experiments” on how to add Emojis to libGDX texts (Labels, BitmapFonts, etc) and have created a EmojiSupport class without having to change any file in the gdx core. https://github.com/DavidPDev/gdx-EmojiSupport Currently supports adding emojis to any text with very low penalty. Please if you can check it, it’s not 100% perfect but may be the way to supporting emojis natively.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Html character emoji does not render - Stack Overflow
The rendering of the emojis is depending on the font you use to display them. Emojis are just normal characters like the letter...
Read more >
Emojis are not rendering, even with emojify : r/emacs - Reddit
Emojis are not rendering, even with emojify. I just reinstalled archlinux on to this device, so I had to reinstall emacs as well....
Read more >
Emoji not displaying | WordPress.org
Hey, So the issue is with your customizer not saving. If you've tried deactivating all plugins and using a default theme, then it's...
Read more >
Emojis not rendering - Ask Different - Apple Stack Exchange
I fixed it by copying the Apple Color Emoji font from another Mac running the same OS version. You can find it in...
Read more >
Emojis Not Rendering Correctly When Published to Tableau ...
When publishing a dashboard that uses emojis to Tableau Cloud, some emojis appear different or do not render successfully when compared to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found