Godot: Emoji support

Created on 1 Sep 2017  ยท  15Comments  ยท  Source: godotengine/godot

Operating system or device, Godot version, GPU Model and driver (if graphics related):
Windows, Godot 2.1.4

Issue description:
Godot does not render many emojis. I attempted to use a RichTextLabel containing the text:

te๐Ÿ˜Šx๐ŸŒt๐Ÿ”ผแดฅโ™ป๐Ÿš€โ‚โ˜ฎโ˜ฏ๐Ÿš€๐ŸŽก๐Ÿšข๐Ÿญ๐Ÿ’ฆ๐Ÿ”ป

And instead what renders is:

image

I did this using a dynamic font for the node and I tried loading EmojiOneColor-SVGinOT.ttf, OpenSansEmoji.ttf, and unifont-10.0.06.ttf all with very limited success. The EmojiOneColor comes with a demo which, when opened in Chrome, renders just fine in B&W including many of the symbols I'm looking to use. Finding an adequate demo of the other fonts is a bit more difficult than I imagined.

enhancement core

Most helpful comment

screenshot from 2018-01-16 15-56-04
:sunglasses: finally....
need to clean up codes, but also need to go to bed...
will make a PR, maybe tomorrow

All 15 comments

Maybe related to #6834 , 3 have better support of fonts with special characters.

allow using them in code editor too like variables ๐Ÿ”จ

@curly-brace well, if you manage to get a font with emoji in the format supported by the editor it should be possible (settings uses a .font, I have no idea what is that).

You can now use any TTF font in the editor itself (code editor included) and in games, so this should work fine.

If a TTF font contains glyphs and Godot doesn't render them, that needs to be investigated.

You can now use any TTF font in the editor itself (code editor included) and in games, so this should work fine.

Note that colored fonts aren't currently supported, though (this is important as most emoji fonts make use of colors).

Is working in editor, labels, node names, gdscript, debugger, terminal output.

Tested with https://github.com/eosrei/twemoji-color-font (of course, color does not work).

I did not even know color fonts existed, I suppose we could detect this
somehow and render to color?

On Mon, Jan 15, 2018 at 1:58 PM, eon-s notifications@github.com wrote:

Is working in editor, labels, node names, gdscript, debugger, terminal
output.

Tested with https://github.com/eosrei/twemoji-color-font (of course,
color does not work).

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/10873#issuecomment-357738745,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z2xlXISG7Dcfw-umuc_FmV6JfHmNzks5tK4OxgaJpZM4PKmOP
.

I'm trying on this.
I don't know why but it works only with Google Noto Emoji font... :cry:

screenshot from 2018-01-16 09-43-34

I'm amazed, how are you detecting that the font needs to use a RGB texture
and raster to it?

On Mon, Jan 15, 2018 at 9:45 PM, volzhs notifications@github.com wrote:

I'm trying on this.
I don't know why but it works only with Google Noto Emoji font... ๐Ÿ˜ข

[image: screenshot from 2018-01-16 09-43-34]
https://user-images.githubusercontent.com/8281454/34966795-d05abee0-faa1-11e7-8648-bbf41bf5a0f0.png

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/10873#issuecomment-357821492,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z29pDTA5OX5FmojSWM4l7O4Ck6tQEks5tK_E0gaJpZM4PKmOP
.

detecting color

bool has_color = FT_HAS_COLOR(face);
int error = FT_Load_Char(face, p_char, has_color ? FT_LOAD_COLOR : FT_LOAD_DEFAULT);

to raster

case FT_PIXEL_MODE_BGRA:
    wr[ofs + 2] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 0];
    wr[ofs + 1] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 1];
    wr[ofs + 0] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 2];
    wr[ofs + 3] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 3];
    break;

need to take care of DynamicFontAtSize::textures though...

I'm not sure that fonts downloaded from internet is really colored font beside google noto color emoji...
or I missed something to do with freetype to render rest colored fonts.

ah yeah, you need to find out if at least one of the chars uses color so
you create a color texture... either that or use a separate texture for
chars with colors, not sure.

On Mon, Jan 15, 2018 at 10:33 PM, volzhs notifications@github.com wrote:

detecting color

bool has_color = FT_HAS_COLOR(face);int error = FT_Load_Char(face, p_char, has_color ? FT_LOAD_COLOR : FT_LOAD_DEFAULT);

to raster

case FT_PIXEL_MODE_BGRA:
wr[ofs + 2] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 0];
wr[ofs + 1] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 1];
wr[ofs + 0] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 2];
wr[ofs + 3] = slot->bitmap.buffer[i * slot->bitmap.pitch + (j << 2) + 3];
break;

need to take care of DynamicFontAtSize::textures though...

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/10873#issuecomment-357828031,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z28fKVYrp33ZvFSwnGQGrNahEQgTYks5tK_xjgaJpZM4PKmOP
.

yeah. i've done that too so far.
problem is checking and loading colored font correctly.

screenshot from 2018-01-16 11-45-06

as my research, freetype supports only CBDT format color font which Google supports also.
if font is CBDT format, it works fine.
now need to handle size of font rendering.

screenshot from 2018-01-16 15-56-04
:sunglasses: finally....
need to clean up codes, but also need to go to bed...
will make a PR, maybe tomorrow

Was this page helpful?
0 / 5 - 0 ratings