NDEVR
API Documentation
FontEngine

Stores many different types of font. More...

Collaboration diagram for FontEngine:
[legend]

Static Public Member Functions

static void AddFontListener (const StringView &app_font, UUID id, std::function< void(const StringView &)> callback)
 Registers a callback to be invoked when an application font changes.
static const FontApplicationFont (const StringView &app_font)
 Retrieves a registered application font by name.
static File FindBestFitFontFile (Font &font, bool allow_backup_file=true)
 Finds the best matching font file for the given font properties.
static Font FindFallbackFont (Font original, wchar_t character)
 Finds a fallback font that supports the given character.
static bool HasApplicationFont (const StringView &app_font)
 Checks whether an application font has been registered with the given name.
static bool HasFontFile (const StringView &font_name)
 Checks whether a font file is registered for the given font name.
static void PullFontFromFolder (const File &folder)
 Scans a folder for font files and registers them.
static void ReadFontSettings ()
 Reads font settings from the settings file.
static void RemoveFontListener (const StringView &app_font, UUID id)
 Removes a previously registered font change listener.
static void SaveFontSettings ()
 Saves the current font settings to the settings file.
static void SetApplicationFont (const StringView &app_font, const Font &font)
 Registers or updates an application font by name.
static void SetFontFile (const StringView &font_name, const File &file, uint04 index=0)
 Associates a font file with a font name.
static void SetSettingsFile (const File &file)
 Sets the file used to persist font settings.

Static Public Attributes

static constexpr StringView DefaultFont = "Default"
 The default application font identifier.

Static Protected Member Functions

static File TryFontName (const StringView &family)
 Attempts to locate a font file by font family name.

Static Protected Attributes

static Dictionary< String, Dictionary< UUID, std::function< void(const StringView &)> > > s_app_font_listener
 Registered font change listeners per application font.
static Dictionary< String, Fonts_application_fonts
 Mapping of application font identifiers to fonts.
static Dictionary< String, Strings_font_files
 Mapping of font names to font file paths.
static Dictionary< String, uint04s_font_indices
 Mapping of font names to face indices within font files.
static File s_settings_file
 File used to persist font settings.
static Dictionary< String, Fonts_system_fonts
 Mapping of font names to system-installed fonts.

Detailed Description

Stores many different types of font.


Definition at line 175 of file Font.h.

Member Function Documentation

◆ AddFontListener()

void FontEngine::AddFontListener ( const StringView & app_font,
UUID id,
std::function< void(const StringView &)> callback )
static

Registers a callback to be invoked when an application font changes.

Parameters
[in]app_fontThe application font identifier to listen on.
[in]idA unique identifier for the listener.
[in]callbackThe function to call when the font changes.

◆ ApplicationFont()

const Font & FontEngine::ApplicationFont ( const StringView & app_font)
static

Retrieves a registered application font by name.

Parameters
[in]app_fontThe application font identifier.
Returns
A const reference to the registered font.

◆ FindBestFitFontFile()

File FontEngine::FindBestFitFontFile ( Font & font,
bool allow_backup_file = true )
static

Finds the best matching font file for the given font properties.

Parameters
[in]fontThe font whose file should be resolved. May be modified with the found file.
[in]allow_backup_fileWhether to fall back to a backup font file if exact match is not found.
Returns
The best matching font file.

◆ FindFallbackFont()

Font FontEngine::FindFallbackFont ( Font original,
wchar_t character )
static

Finds a fallback font that supports the given character.

Parameters
[in]originalThe original font that does not support the character.
[in]characterThe character that needs font support.
Returns
A font that can render the specified character.

◆ HasApplicationFont()

bool FontEngine::HasApplicationFont ( const StringView & app_font)
static

Checks whether an application font has been registered with the given name.

Parameters
[in]app_fontThe application font identifier.
Returns
True if the font is registered.

◆ HasFontFile()

bool FontEngine::HasFontFile ( const StringView & font_name)
static

Checks whether a font file is registered for the given font name.

Parameters
[in]font_nameThe font family name to look up.
Returns
True if a font file exists for the name.

◆ PullFontFromFolder()

void FontEngine::PullFontFromFolder ( const File & folder)
static

Scans a folder for font files and registers them.

Parameters
[in]folderThe directory to scan for font files.

◆ RemoveFontListener()

void FontEngine::RemoveFontListener ( const StringView & app_font,
UUID id )
static

Removes a previously registered font change listener.

Parameters
[in]app_fontThe application font identifier the listener was registered on.
[in]idThe unique identifier of the listener to remove.

◆ SetApplicationFont()

void FontEngine::SetApplicationFont ( const StringView & app_font,
const Font & font )
static

Registers or updates an application font by name.

Parameters
[in]app_fontThe application font identifier.
[in]fontThe font to associate with the identifier.

◆ SetFontFile()

void FontEngine::SetFontFile ( const StringView & font_name,
const File & file,
uint04 index = 0 )
static

Associates a font file with a font name.

Parameters
[in]font_nameThe font family name.
[in]fileThe font file path.
[in]indexThe face index within the font file.

◆ SetSettingsFile()

void FontEngine::SetSettingsFile ( const File & file)
static

Sets the file used to persist font settings.

Parameters
[in]fileThe settings file path.

◆ TryFontName()

File FontEngine::TryFontName ( const StringView & family)
staticprotected

Attempts to locate a font file by font family name.

Parameters
[in]familyThe font family name to search for.
Returns
The file path if found, or an invalid file otherwise.

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