- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用最新的 freetype 2.8.1(我从没有单线程或多线程的源代码编译 x64 调试版本)和 OpenGL 渲染来自 Windows“Segoe UI Emoji”字体的彩色字形。所以我使用 Windows\Fonts
目录中的 seguiemj.ttf
(SHA256 = d67717a6fe84e21bc580443add16ec920e6988ca067041d0461c641f75074a8c
),但 FT_HAS_COLOR 始终返回 false。我也用 EmojiOneColor-SVGinOT.ttf
试过了通过 eosrei from github ,这会导致相同的行为。
使用 this 时对于 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");
...
}
基本上我使用上面的代码,它只能接收该字体文件的单色位图,像素模式始终为 FT_PIXEL_MODE_GRAY。
Word/Firefox 中的表情符号
我的应用程序中的表情符号
有什么办法可以解决这个问题还是我做错了什么?
最佳答案
FT_Load_Glyph 和 FT_LOAD_COLOR 将字体的位图版本加载到字形槽中。之后,您的代码调用 FT_Render_Glyph 并根据轮廓渲染字形,从而有效地替换之前加载的位图。
如果您跳过 FT_Render_Glyph,应该没问题。
关于c++ - 如何使用 freetype 从 "Segoe UI Emoji"渲染彩色字形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46368673/
我有点困惑设置字符大小对象的字符宽度和高度字段(示例来自 FreeType tutorial 中所述) error = FT_Set_Char_Size( face, /*
我正在尝试使用 freetype 枚举字体文件中的字形(名称和 unicode)。 为了获取名称,我使用了 FT_Get_Glyph_Name。但是我怎样才能得到字形 unicode 值呢? 我是字形
它运行在 OS X 10.9 上。我使用 brew 和 FreeType v2.5.2 安装了 GraphicsMagick。但是当我在程序中使用 gm Convert 时,出现此错误: { [Err
项目设置: GameProject [此项目包含游戏代码] GameProject-Android GameProject-桌面 GameProject-robovm [这是一个无需使用任何自由字体即
尝试在 Ubuntu Linux 86-64 上编译 freetype 2.6.1 时,我在配置步骤收到以下消息: /usr/local/include/harfbuzz/hb-common.h:31
当字符串确实包含我使用的默认字体中不存在的字符时,如何告诉 freetype 使用后备字体? 我需要在我的应用程序中正确呈现非拉丁字形。 我必须自己管理回退吗? 如果是这样:如何检测给定字符串中是否缺
我已将“arial.ttf”文件(从我的/Windows/Fonts 文件夹中获取)加载到内存中,但是将其传递到 FT_New_Memory_Face 时会崩溃(在 FT_Open_Face 中的某处
我正在尝试使用 FreeType 为微 Controller 创建位图字体,但我对坐标表达方式的根本差异感到困惑。我的微 Controller 期望字形位图相对于左上角的原点有 X 和 Y 偏移,而
我正在编写一个 DirectX WindowsPhone 应用程序,我需要使用 FreeType。好吧,我已经下载了 FreeType 源代码并使用 CMake 为 WP ARM 生成 Visual
所以我尝试在我的图形引擎中使用带符号的距离字段实现字体渲染。 为此,我使用 FreeType 库生成所有字母的字形。具体来说,我正在尝试像这样加载单色位图: FT_Load_Char(face, c,
我目前正在尝试创建仅包含字形外部边界、内部没有任何填充的字形位图。为此使用 FreeType 库。这是我的代码,类似于 FreeType 引用中的示例 2 代码: Spans outlineSpans
我正在渲染文本,我需要字体的大写高度达到一定的像素数。例如,在下面的标志中,我需要让 SPEED 和 LIMIT 的高度相同,在本例中为 45 px,因此我将字体大小设置为45(我现在明白这不是一个好
我正在尝试使用 FreeType 2.4.11在我使用 openGL 渲染文本的项目中。 虽然我初始化了库,但只将 charmap 设置为 unicode 一次。在每次绘制的字符循环中使用 FT_Lo
我正在尝试创建单色字形图集,但遇到了问题。 Freetype 在字形的位图中呈现“废话”。我责怪 freetype,因为一些字形仍然正确呈现。 生成的纹理图集: 为什么会这样,我该如何解决? 但是我仍
我尝试在 OpenGL 和 FreeType2 中渲染文本,但我不知道如何在渲染字体时获取每行之间的空间(以像素为单位)。当我解析文本时,我希望能够做类似的事情 const char *text =
我正在尝试使用 AIDE 应用程序直接从我的手机使用 freetypefontgenerator。我已完成本文中显示的所有步骤:https://github.com/libgdx/libgdx/wik
这个问题与以下内容密切相关 Is there a way to programmatically determine if a font file has a specific Unicode Gly
我对 Mac OS X 环境比较陌生。 我试图安装 freetype 库以在 OpenGL 中显示文本,但我失败了。 我在一些论坛上读到 freetype 预装了 Mac OS X 山狮。 我只是想确
以前版本的 FreeType 有一个方法 setScale() 现在我可以使用以下方法更改比例: bitmapFont.getData().SetScale(); 但是我遇到了字母间距问题: /ima
使用 FreeType (2.10.1) 在我的游戏引擎中实现文本渲染,我遇到了奇怪的字形,包含重复四次的字母,在 x 轴上镜像并颠倒。 在所需的字母上方似乎有被解释为字形的相邻内存,它在每次运行时都
我是一名优秀的程序员,十分优秀!