用FreeType加载彩色字体 [英] Loading Colored Fonts With FreeType

查看:738
本文介绍了用FreeType加载彩色字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试渲染默认情况下已在文件中着色的图释。
我正在使用'Segoe UI Emoji' SHA-256:9e5a8c7e6c1e9096918a490798f4177107f0522870c8ad0227d5f02be407e0ed

I'm trying to render emoticons that are already colored by default in the file. I'm using 'Segoe UI Emoji' SHA-256: 9e5a8c7e6c1e9096918a490798f4177107f0522870c8ad0227d5f02be407e0ed

问题是 FT_HAS_COLOR()始终返回false,因此我无法使用FT_LOAD_COLOR将位图加载到纹理中。

The problem is that FT_HAS_COLOR() always returns false, so therefor I can't use FT_LOAD_COLOR to load the bitmap to my texture.

我已经在通用字符映射中打开了文件,并看到了-

I've opened the file in Universal Character Map and saw this -

此处有一个摘录栅格化字形的代码

Heres a snippet from the code that rasterizes the glyphs

FT_Int32 flags = FT_LOAD_FORCE_AUTOHINT | ( m_bAntiAliasing ? FT_LOAD_TARGET_NORMAL : FT_LOAD_TARGET_MONO );
if ( FT_HAS_COLOR( m_face ) )
    flags |= FT_LOAD_COLOR;
else
    flags |= FT_LOAD_RENDER;         

if ( FT_Load_Char( m_face, glyphit->first, flags ) )
    continue;


的结果

我将不胜感激,我已经坚持了一段时间,并尝试了该字体/其他字体的不同版本。

I would appreciate any help, I've been stuck on this for quite a while and have tried different versions of this font / other fonts.

注意:我见过,但似乎没有得到答案

Note: I've seen this but it doesn't seem like it was answered

谢谢。

推荐答案

从FreeType文档中:

From the FreeType docs:


[自2.5起]加载嵌入式彩色位图图像。生成的颜色位图(如果可用)将具有FT_PIXEL_MODE_BGRA格式。如果未设置该标志并找到了彩色位图,则使用FT_PIXEL_MODE_GRAY格式将它们透明转换为256级灰度位图。

[Since 2.5] Load embedded color bitmap images. The resulting color bitmaps, if available, will have the FT_PIXEL_MODE_BGRA format. If the flag is not set and color bitmaps are found, they are converted to 256-level gray bitmaps transparently, using the FT_PIXEL_MODE_GRAY format.

显然,FreeType仅支持彩色位图图像。 Segoe使用COLR / CPAL矢量格式,也许这就是为什么它返回负数并呈现常规的黑白字形的原因?

Apparently FreeType only supports color bitmap images. Segoe uses the COLR/CPAL vector format, maybe that's why it's returning a negative and rendering the regular "black and white" glyphs?

这篇关于用FreeType加载彩色字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆