Loading...
Searching...
No Matches
CAPI_FontLoader.h File Reference

Overview

User-defined font loader interface.

#include <Ultralight/CAPI/CAPI_FontLoader.h>

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.

See also
ulPlatformSetFontLoader

Classes

struct  ULFontLoader
 User-defined font loader interface. More...
 

Typedefs

typedef ULString(* ULFontLoaderGetFallbackFont) ()
 Fallback font family name.
 
typedef ULString(* ULFontLoaderGetFallbackFontForCharacters) (ULString characters, int weight, bool italic)
 Fallback font family name that can render the specified characters.
 
typedef ULFontFile(* ULFontLoaderLoad) (ULString family, int weight, bool italic)
 Get the actual font file data (TTF/OTF) for a given font description.
 

Typedef Documentation

◆ ULFontLoaderGetFallbackFont

typedef ULString(* ULFontLoaderGetFallbackFont) ()

Fallback font family name.

Will be used if all other fonts fail to load.

Note
This font should be guaranteed to exist (eg, ULFontLoader::load should not fail when when passed this font family name).
The returned ULString instance will be consumed (ulDestroyString will be called on it).

◆ ULFontLoaderGetFallbackFontForCharacters

typedef ULString(* ULFontLoaderGetFallbackFontForCharacters) (ULString characters, int weight, bool italic)

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.
Returns
Should return a font family name that can render the text. The returned ULString instance will be consumed (ulDestroyString will be called on it).

◆ ULFontLoaderLoad

typedef ULFontFile(* ULFontLoaderLoad) (ULString family, int weight, bool italic)

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.
Returns
A font file matching the given description (either an on-disk font filepath or an in-memory file buffer). You can return NULL here and the loader will fallback to another font.

Go to the source code of this file.