HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions
tt::FontBook Class Reference

#include <TTauri/Text/FontBook.hpp>

Public Member Functions

 FontBook (std::vector< URL > const &font_directories)
 
FontID register_font (URL url, bool post_process=true)
 Register a font.
 
void post_process () noexcept
 Post process FontBook Should be called after a set of register_font() calls This calculates font fallbacks.
 
FontFamilyID find_family (std::string_view family_name) const noexcept
 Find font family id.
 
FontFamilyID register_family (std::string_view family_name) noexcept
 Register font family id.
 
FontID find_font (FontFamilyID family_id, FontVariant variant) const noexcept
 Find a font closest to the variant.
 
FontID find_font (FontFamilyID family_id, FontWeight weight, bool italic) const noexcept
 Find a font closest to the variant.
 
FontID find_font (std::string_view family_name, FontWeight weight, bool italic) const noexcept
 Find a font closest to the variant.
 
Font const & get_font (FontID font_id) const noexcept
 
FontGlyphIDs find_glyph (FontID font_id, Grapheme grapheme) const noexcept
 Find a glyph using the given code-point.
 

Detailed Description

FontBook keeps track of multiple fonts.

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

Member Function Documentation

◆ find_family()

FontFamilyID tt::FontBook::find_family ( std::string_view family_name) const
noexcept

Find font family id.

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

◆ find_font() [1/3]

FontID tt::FontBook::find_font ( FontFamilyID family_id,
FontVariant variant ) const
noexcept

Find a font closest to the variant.

This function will always return a valid FontID.

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

◆ find_font() [2/3]

FontID tt::FontBook::find_font ( FontFamilyID family_id,
FontWeight weight,
bool italic ) const
noexcept

Find a font closest to the variant.

This function will always return a valid FontID.

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]

FontID tt::FontBook::find_font ( std::string_view family_name,
FontWeight weight,
bool italic ) const
noexcept

Find a font closest to the variant.

This function will always return a valid FontID.

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_glyph()

FontGlyphIDs tt::FontBook::find_glyph ( FontID font_id,
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
font_idThe 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 tt::FontBook::post_process ( )
noexcept

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

◆ register_family()

FontFamilyID tt::FontBook::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()

FontID tt::FontBook::register_font ( URL url,
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
urlLocation of font.
post_processCalculate font fallback

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