Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

freetype use fallback for missing glyphs

How can I tell freetype to use a fallback font when a string does contain a character that is not present in the Font I'm using as a default?

I need to render non-latin glyphs correctly in my application.

Do I have to manage a fallback myself?

If so: how do I detect if there is a missing glyph in a given string?

like image 620
Rock Avatar asked Apr 25 '13 13:04

Rock


2 Answers

I'm sorry, I don't know if you need to handle fallback yourself, but my guess would be that you do. As for how to detect if there is missing glyph, you could use this method: FT_Get_Char_index If it returns 0, it means symbol was not found.

like image 139
SMGhost Avatar answered Oct 07 '22 02:10

SMGhost


The GNU Unifont can serve as a fallback font for every codepoint in the Basic Multilingual Plane (BMP), which would be 0x0000-0xFFFF. That should cover the vast majority of what you might encounter. Available for download here (archive).

The Unicode Last Resort font can serve as a final fallback for every codepoint in all of the planes. These glyphs only show broad categories. Available for download here.

It looks like you would have to detect the absence of a glyph with FT_Get_Char_Index() as SMart explained, and in those cases turn to Unifont or the Last Resort font.

like image 39
Josh Sanford Avatar answered Oct 07 '22 03:10

Josh Sanford