Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load twemoji color font #6607

Closed
misuke0 opened this issue Jul 16, 2023 · 3 comments
Closed

Cannot load twemoji color font #6607

misuke0 opened this issue Jul 16, 2023 · 3 comments

Comments

@misuke0
Copy link

misuke0 commented Jul 16, 2023

Version/Branch of Dear ImGui:

Version: 1.89.7
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_dx11.cpp + imgui_impl_win32.cpp
Compiler: Visual Studio 2022
Operating System: Windows

My Issue/Question:

I cannot load the twemoji font (https://github.com/twitter/twemoji), I followed the instructions here: https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#using-colorful-glyphsemojis. With seguiemj.ttf it works but not with twemoji.

ImGuiIO& io = ImGui::GetIO();
auto font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18);

static ImWchar ranges[] = { 0x1, 0x1FFFF, 0 };
static ImFontConfig cfg;
cfg.OversampleH = cfg.OversampleV = 1;
cfg.MergeMode = true;
cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_LoadColor;
io.Fonts->AddFontFromFileTTF("c:\\users\\misuke\\downloads\\TwitterColorEmoji-SVGinOT.ttf", 18f, &cfg, ranges);

It throws an exception in imgui_freetype.cpp (https://github.com/ocornut/imgui/blob/master/misc/freetype/imgui_freetype.cpp#L247):

IM_ASSERT(slot->format == FT_GLYPH_FORMAT_OUTLINE || slot->format == FT_GLYPH_FORMAT_BITMAP);

If I remove this assertion, the font atlas contains only a few icons from twemoji
Screenshots/Video

image

@PathogenDavid
Copy link
Contributor

Twemoji is an SVG font, which aren't supported by FreeType out of the box. (Hence the failed assert.)

There's a PR to enable support via LunaSVG, see #6591

@misuke0
Copy link
Author

misuke0 commented Jul 16, 2023

@PathogenDavid thanks for the quick response, that works for me

@ocornut
Copy link
Owner

ocornut commented Aug 1, 2023

Merged Lunasvg support in #6591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants