-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Not able to use NotoColorEmoji font #6302
Comments
Two things you can do to begin debugging this:
|
I can confirm this on my side. Some references: |
Man I've been spending the last 3 days trying to get this same font to work, finally found this and saw it was an issue...fml |
clfontpng (https://gist.github.com/jokertarot/7583938) can render emoji in NotoColorEmoji_WindowsCompatible.ttf into png file without a problem. |
Any update on this issue? |
Apparently, the notoemoji font (CBDT variant) is not scalable ( To reproduce cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_LoadColor | ImGuiFreeTypeBuilderFlags_Bitmap; bool FreeTypeFont::IsCBDTFont()
{
FT_ULong tag = FT_MAKE_TAG('C', 'B', 'D', 'T');
FT_ULong length = 0;
FT_Load_Sfnt_Table(Face, tag, 0, nullptr, &length);
return length > 0;
}
void FreeTypeFont::SetPixelHeight(int pixel_height)
{
if (IsCBDTFont())
{
IM_ASSERT(Face->num_fixed_sizes != 0);
LoadFlags |= FT_LOAD_COLOR;
int best_match = 0;
int diff = std::abs(pixel_height - Face->available_sizes[0].width);
for (int i = 1; i < Face->num_fixed_sizes; ++i)
{
int ndiff = std::abs(pixel_height - Face->available_sizes[i].width);
if (ndiff < diff)
{
best_match = i;
diff = ndiff;
}
}
FT_Select_Size(Face, best_match);
}
else
{
// Vuhdo: I'm not sure how to deal with font sizes properly. As far as I understand, currently ImGui assumes that the 'pixel_height'
// is a maximum height of an any given glyph, i.e. it's the sum of font's ascender and descender. Seems strange to me.
// NB: FT_Set_Pixel_Sizes() doesn't seem to get us the same result.
FT_Size_RequestRec req;
req.type = (UserFlags & ImGuiFreeTypeBuilderFlags_Bitmap) ? FT_SIZE_REQUEST_TYPE_NOMINAL : FT_SIZE_REQUEST_TYPE_REAL_DIM;
req.width = 0;
req.height = (uint32_t)pixel_height * 64;
req.horiResolution = 0;
req.vertResolution = 0;
FT_Request_Size(Face, &req);
}
// Update font info
FT_Size_Metrics metrics = Face->size->metrics;
Info.PixelHeight = (uint32_t)pixel_height;
Info.Ascender = (float)FT_CEIL(metrics.ascender);
Info.Descender = (float)FT_CEIL(metrics.descender);
Info.LineSpacing = (float)FT_CEIL(metrics.height);
Info.LineGap = (float)FT_CEIL(metrics.height - metrics.ascender + metrics.descender);
Info.MaxAdvanceWidth = (float)FT_CEIL(metrics.max_advance);
} Furthermore, with the noto-glyf_colr_1.ttf font, it is scalable and has outlines, but its outline (path) size is 0, making the I can't figure out how to adjust the scale, given that it's "unscalable" but as a workaround, we can use the SVGinOT font noto-untouchedsvg.ttf with my PR #6591 |
@ocornut I think we can close this as this is freetype's lack of support for CBDT & COLRv1 fonts (see the technical details I posted above). With |
Thank you @sakiodre, closing this indeed! |
My Issue/Question:
I want to use font NotoColorEmoji_WindowsCompatible.ttf and display a smile face similar to what is shown in:
#4566 (comment)
It seems the font is not loaded correctly.
Screenshots/Video
Standalone, minimal, complete and verifiable example: (see )
Full example with CMake (run build_and_run.sh after unzipping):
emoji_font.zip
The text was updated successfully, but these errors were encountered: