libgdx: Emojis are not rendering
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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (5 by maintainers)
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());and then we can easy to add custom emoji and stickers. for example https://github.com/taluks/libgdx-emodji
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.
+1 for incremental mode. I’m using freetype in my game and so far have had no issue using incremental mode to support asian scripts, even at large text sizes (size scales with device resolution) and 1,000+ characters.