I have loaded a font with emoji support and I am trying to render a string with emoji's with libgdx. However, it renders the text, but not the emojis.
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));
emoji test test
FreeTypeFontGenerator creates a BitmapFont from your TTF file. Most likely your created font does not contain the emojis.
You don't show the interesting part of your code: the parameters you set. Add the emojis you want to use to the parameters:
p.characters = "characters you want to use";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.