小编cod*_*ter的帖子

如何使用freetype从"Segoe UI Emoji"渲染彩色字形?

我正在尝试从Windows"Segoe UI Emoji"渲染彩色字形 - 使用最新的freetype 2.8.1(我从源代码编译x64调试版本,没有单线程或多线程)和OpenGL.所以,我用的是seguiemj.ttfWindows\Fonts目录(SHA256 = d67717a6fe84e21bc580443add16ec920e6988ca067041d0461c641f75074a8c),但FT_HAS_COLOR始终返回false.我也尝试使用来自githubEmojiOneColor-SVGinOT.ttfeosrei,这导致了相同的行为.

这个文件用于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); …
Run Code Online (Sandbox Code Playgroud)

c++ windows opengl fonts freetype

9
推荐指数
1
解决办法
1742
查看次数

标签 统计

c++ ×1

fonts ×1

freetype ×1

opengl ×1

windows ×1