Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
ultralight::FontLoader Class Referenceabstract

Font Loader interface, used for all font lookup operations. More...

#include <FontLoader.h>

Public Member Functions

virtual String16 fallback_font () const =0
 Fallback font family name. More...
 
virtual String16 fallback_font_for_characters (const String16 &characters, int weight, bool italic, float size) const =0
 Fallback font family name that can render the specified characters. More...
 
virtual Ref< BufferLoad (const String16 &family, int weight, bool italic, float size)=0
 Get the actual font file data (TTF/OTF) for a given font description. More...
 

Detailed Description

Font Loader interface, used for all font lookup operations.

Every operating system 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) given a certain font description.

You can override this interface to bundle your own fonts or override the default system font loading behavior.

This is intended to be implemented by users and defined before creating the Renderer.

See also
Platform::set_font_loader

Definition at line 34 of file FontLoader.h.

Member Function Documentation

◆ fallback_font()

virtual String16 ultralight::FontLoader::fallback_font ( ) const
pure virtual

Fallback font family name.

Will be used if all other fonts fail to load.

Note
This font should be GUARANTEED to exist (eg, FontLoader::Load won't fail when passed this font family name).

◆ fallback_font_for_characters()

virtual String16 ultralight::FontLoader::fallback_font_for_characters ( const String16 characters,
int  weight,
bool  italic,
float  size 
) const
pure virtual

Fallback font family name that can render the specified characters.

This is mainly used to support CJK (Chinese, Japanese, Korean) text display.

Parameters
charactersOne or more UTF-16 characters. This is almost ALWAYS a single character.
weightFont weight.
italicWhether or not italic is requested.
sizeFont size.
Returns
Should return a font family name that can render the text.

◆ Load()

virtual Ref<Buffer> ultralight::FontLoader::Load ( const String16 family,
int  weight,
bool  italic,
float  size 
)
pure virtual

Get the actual font file data (TTF/OTF) for a given font description.

Parameters
familyFont family name.
weightFont weight.
italicWhether or not italic is requested.
sizeFont size.
Returns
A buffer of bytes containing raw font file contents of the font matching the given description.
Note
As an example of usage, when given the family "Arial", this function should return the raw file contents for "ARIAL.TTF"

The documentation for this class was generated from the following file: