cod*_*ter 9 c++ windows opengl fonts freetype
我正在尝试从Windows"Segoe UI Emoji"渲染彩色字形 - 使用最新的freetype 2.8.1(我从源代码编译x64调试版本,没有单线程或多线程)和OpenGL.所以,我用的是seguiemj.ttf从Windows\Fonts目录(SHA256 = d67717a6fe84e21bc580443add16ec920e6988ca067041d0461c641f75074a8c),但FT_HAS_COLOR始终返回false.我也尝试使用来自githubEmojiOneColor-SVGinOT.ttf的eosrei,这导致了相同的行为.
当这个文件用于android时,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");
...
}
Run Code Online (Sandbox Code Playgroud)
基本上我使用上面的代码,即只能接收那些字体文件的单色位图,而像素模式总是FT_PIXEL_MODE_GRAY.
Word/Firefox中的表情符号
Emojis在我的应用程序中
有什么东西要解决这个问题,还是我做错了什么?
FT_Load_Glyph 和 FT_LOAD_COLOR 将字体的位图版本加载到字形槽中。之后,您的代码调用 FT_Render_Glyph 并从轮廓渲染字形,从而有效地替换先前加载的位图。
如果你跳过 FT_Render_Glyph 应该没问题。
| 归档时间: |
|
| 查看次数: |
1742 次 |
| 最近记录: |