我正在尝试使用最新的freetype 2.8.1(我从源代码编译了x64调试版本,没有单线程或多线程)和OpenGL来呈现Windows“Segoe UI Emoji”字体的彩色字形。因此,我使用来自“Windows\Fonts”目录的“seguiemj.ttf”文件(SHA256 =“d67717a6fe84e21bc580443add16ec920e6988ca067041d0461c641f75074a8c”),但FT_HAS_COLOR始终返回false。我还尝试了eosrei from github提供的
当在Android上使用this文件时,
基本上我使用上面的代码,只能接收那些字体文件的单色位图,并且像素模式总是FT_PIXEL_MODE_GRAY。
Word/Firefox中的表情符号
EmojiOneColor-SVGinOT.ttf
文件,结果行为相同。当在Android上使用this文件时,
FT_HAS_COLOR
返回true,但位图插槽仍未填充。FT_Library library;
FT_Face face;
FT_Init_FreeType(&library);
FT_New_Face(library, "resources/fonts/seguiemj.ttf", 0, &face);
bool has_color = FT_HAS_COLOR(face);
debug(LOG_INFO, 0, "font has colors: %s", has_color ? "yes" : "no");
std::u32string s = U" ";
FT_GlyphSlot slot = face->glyph;
for (auto c : s)
{
int glyph_index = FT_Get_Char_Index(face, c);
FT_Error error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT|FT_LOAD_COLOR);
if (error)
continue;
error = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
if (error)
continue;
if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA)
debug(LOG_INFO, 0, "glyph is colored");
...
}
基本上我使用上面的代码,只能接收那些字体文件的单色位图,并且像素模式总是FT_PIXEL_MODE_GRAY。
Word/Firefox中的表情符号
我的应用程序中的表情符号
有什么方法可以修复这个问题,还是我做错了什么?
FT_Load_Glyph()
后,face->glyph->format
是否设置为FT_GLYPH_FORMAT_BITMAP
? - genpfaultFT_GLYPH_FORMAT_OUTLINE
。 - code_hunter