Ultralight C++ API 1.4.0
|
#include <Ultralight/platform/FontLoader.h>
User-defined font loader interface.
The library uses this to load a font file (eg, Arial.ttf
) for a given font description (eg, font-family: Arial;
).
Every OS has its own library of installed system fonts. The FontLoader interface is used to lookup these fonts and fetch the actual font data (raw TTF/OTF file data) for a given font description.
You can provide the library with your own font loader implementation so that you can bundle fonts with your application rather than relying on the system's installed fonts.
A platform-specific implementation of FontLoader is provided for you when you call App::Create().
If you are using Renderer::Create(), you must provide your own. You can still use AppCore's implementation however– see the helper functions defined in <AppCore/Platform.h>.
To provide your own custom FontLoader implementation, you should inherit from this class, handle the virtual member functions, and then pass an instance of your class to Platform::set_font_loader() before calling Renderer::Create() or App::Create().
Public Member Functions | |
virtual | ~FontLoader () |
virtual String | fallback_font () const =0 |
Fallback font family name. | |
virtual String | fallback_font_for_characters (const String &characters, int weight, bool italic) const =0 |
Fallback font family name that can render the specified characters. | |
virtual RefPtr< FontFile > | Load (const String &family, int weight, bool italic)=0 |
Get the actual font file data (TTF/OTF) for a given font description. | |
|
virtual |
|
pure virtual |
Fallback font family name.
Will be used if all other fonts fail to load.
|
pure virtual |
Fallback font family name that can render the specified characters.
Mainly used to support CJK (Chinese, Japanese, Korean) text display.
characters | One or more UTF-16 characters. This is almost always a single character. |
weight | Font weight. |
italic | Whether or not italic is requested. |
Get the actual font file data (TTF/OTF) for a given font description.
family | Font family name. |
weight | Font weight. |
italic | Whether or not italic is requested. |