简体   繁体   中英

Loading Colored Fonts With FreeType

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

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 - Segoe UI表情符号

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;

Results in this 结果

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

Thank you.

From the FreeType docs:

[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.

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?

Solved, @PeterT mentioned that FreeType 2.10 supports Segoe UI Emoji and similar fonts that use CPAL, 2.9.1 does not.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM