HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
v1::font_book Class Reference

#include <hikogui/text/font_book.hpp>

Public Member Functions

 font_book (font_book const &)=delete
 
 font_book (font_book &&)=delete
 
font_bookoperator= (font_book const &)=delete
 
font_bookoperator= (font_book &&)=delete
 
fontregister_font (std::filesystem::path const &path, bool post_process=true)
 Register a font.
 
void register_font_directory (std::filesystem::path const &path, bool post_process=true)
 Register all fonts found in a directory.
 
void register_elusive_icon_font (std::filesystem::path const &path)
 
void register_hikogui_icon_font (std::filesystem::path const &path)
 
void post_process () noexcept
 Post process font_book Should be called after a set of register_font() calls This calculates font fallbacks.
 
font_family_id find_family (std::string_view family_name) const noexcept
 Find font family id.
 
font_family_id register_family (std::string_view family_name) noexcept
 Register font family id.
 
font constfind_font (font_family_id family_id, font_variant variant) const noexcept
 Find a font closest to the variant.
 
font constfind_font (font_family_id family_id, font_weight weight, bool italic) const noexcept
 Find a font closest to the variant.
 
font constfind_font (std::string_view family_name, font_weight weight, bool italic) const noexcept
 Find a font closest to the variant.
 
glyph_ids find_glyph (font const &font, grapheme grapheme) const noexcept
 Find a glyph using the given code-point.
 
glyph_ids find_glyph (elusive_icon rhs) const noexcept
 
glyph_ids find_glyph (hikogui_icon rhs) const noexcept
 

Static Public Member Functions

static font_bookglobal () noexcept
 

Detailed Description

font_book keeps track of multiple fonts.

The font_book is instantiated during application startup and is available through Foundation_globals->font_book.

Member Function Documentation

◆ find_family()

font_family_id v1::font_book::find_family ( std::string_view family_name) const
noexcept

Find font family id.

This function will always return a valid font_family_id by walking the fallback-chain.

◆ find_font() [1/3]

font const & v1::font_book::find_font ( font_family_id family_id,
font_variant variant ) const
noexcept

Find a font closest to the variant.

This function will always return a valid font_id.

Parameters
family_ida valid family id.
variantThe variant of the font to select.
Returns
a valid font id.

◆ find_font() [2/3]

font const & v1::font_book::find_font ( font_family_id family_id,
font_weight weight,
bool italic ) const
noexcept

Find a font closest to the variant.

This function will always return a valid font_id.

Parameters
family_ida valid family id.
weightThe weight of the font to select.
italicIf the font to select should be italic or not.
Returns
a valid font id.

◆ find_font() [3/3]

font const & v1::font_book::find_font ( std::string_view family_name,
font_weight weight,
bool italic ) const
noexcept

Find a font closest to the variant.

This function will always return a valid font_id.

Parameters
family_nameA name of a font family, which may be invalid.
weightThe weight of the font to select.
italicIf the font to select should be italic or not.
Returns
a font id, possibly from a fallback font.

◆ find_glyph()

glyph_ids v1::font_book::find_glyph ( font const & font,
grapheme grapheme ) const
noexcept

Find a glyph using the given code-point.

This function will find a glyph matching the grapheme in the selected font, or find the glyph in the fallback font.

Parameters
fontThe font to use to find the grapheme in.
graphemeThe Unicode grapheme to find in the font.
Returns
A list of glyphs which matched the grapheme.

◆ post_process()

void v1::font_book::post_process ( )
noexcept

Post process font_book Should be called after a set of register_font() calls This calculates font fallbacks.

◆ register_family()

font_family_id v1::font_book::register_family ( std::string_view family_name)
noexcept

Register font family id.

If the family already exists the existing family_id is returned.

◆ register_font()

font & v1::font_book::register_font ( std::filesystem::path const & path,
bool post_process = true )

Register a font.

Duplicate registrations will be ignored.

When a font file is registered the file will be temporarily opened to read and cache a set of properties:

  • The English font Family from the 'name' table.
  • The weight, width, slant & design-size from the 'fdsc' table.
  • The character map 'cmap' table.
Parameters
pathLocation of font.
post_processCalculate font fallback

◆ register_font_directory()

void v1::font_book::register_font_directory ( std::filesystem::path const & path,
bool post_process = true )

Register all fonts found in a directory.

See also
register_font()

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