Font fallback support
Posted: Mon Jan 07, 2013 03:56
A feature that would be very useful (i'd say essential) to have is the concept of fallback fonts. Android for example has a fallback font that has all the unicode range that is used whenever a certain font doesn't contain a certain glyph.
That way you can use a nice decorative font of your choosing for the ascii range and for the CJK charactesr the fallback would be used. This is very practical and there's no way to do this in CEGUI currently (that I know of, unless the default font has this behavior). I could also contribute this if CE agrees and tells me how to approach it or how it would look.
The simplest way would be to just have a global fallback font. One way would be to add a method like this:
Another way would be to change the behavior of the current default font to act as a fallback:
I'd prefer the first method though, cause it's more specific. The problem with a global fallback font is that it would only have one size, and maybe you want to have several.
So perhaps it could be part of a font definition, any font could point to other font to use as fallback:
With MyUnicodeFont-10 being defined in another file.
EDIT: I think a mix of the two ways would be the best way, the Fallback parameter on the font definition and apart from that a System::setDefaultFallbackFont() would be nice in case you forget the fallback parameter in a font.
That way you can use a nice decorative font of your choosing for the ascii range and for the CJK charactesr the fallback would be used. This is very practical and there's no way to do this in CEGUI currently (that I know of, unless the default font has this behavior). I could also contribute this if CE agrees and tells me how to approach it or how it would look.
The simplest way would be to just have a global fallback font. One way would be to add a method like this:
Code: Select all
CEGUI::System::getSingleton().setFallbackFont("UnicodeFont");
Another way would be to change the behavior of the current default font to act as a fallback:
Code: Select all
CEGUI::System::getSingleton().setDefaultFont("UnicodeFont");
I'd prefer the first method though, cause it's more specific. The problem with a global fallback font is that it would only have one size, and maybe you want to have several.
So perhaps it could be part of a font definition, any font could point to other font to use as fallback:
<Font Name="sans-10" Filename="sans.ttf" Fallback="MyUnicodeFont-10" ...
With MyUnicodeFont-10 being defined in another file.
EDIT: I think a mix of the two ways would be the best way, the Fallback parameter on the font definition and apart from that a System::setDefaultFallbackFont() would be nice in case you forget the fallback parameter in a font.