HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Data Fields | Friends
v1::font Class Referenceabstract

#include <hikogui/text/font.hpp>

Inheritance diagram for v1::font:
v1::true_type_font

Data Structures

struct  substitution_and_kerning_type
 

Public Member Functions

 font (font const &)=delete
 
fontoperator= (font const &)=delete
 
 font (font &&)=delete
 
fontoperator= (font &&)=delete
 
virtual bool loaded () const noexcept=0
 Return if the font is loaded.
 
virtual hi::glyph_id find_glyph (char32_t c) const noexcept=0
 Get the glyph for a code-point.
 
hi::glyph_ids find_glyph (grapheme g) const noexcept
 Get the glyphs for a grapheme.
 
virtual std::optional< hi::glyph_id > load_glyph (hi::glyph_id glyph_id, graphic_path &path) const noexcept=0
 
virtual bool load_glyph_metrics (hi::glyph_id glyph_id, glyph_metrics &metrics, hi::glyph_id lookahead_glyph_id=hi::glyph_id{}) const noexcept=0
 
virtual vector2 get_kerning (hi::glyph_id current_glyph, hi::glyph_id next_glyph) const noexcept=0
 Get the kerning between two glyphs.
 
virtual void substitution_and_kerning (iso_639 language, iso_15924 script, std::vector< substitution_and_kerning_type > &word) const noexcept=0
 Substitute and kern a run of glyphs.
 
glyph_atlas_infoatlas_info (glyph_ids const &glyphs) const noexcept
 
font_variant font_variant () const noexcept
 

Data Fields

std::string family_name
 The family name as parsed from the font file.
 
std::string sub_family_name
 The sub-family name as parsed from the font file.
 
bool monospace = false
 
bool serif = false
 
bool italic = false
 
bool condensed = false
 
font_weight weight = font_weight::Regular
 
float optical_size = 12.0
 
std::string features
 A string representing the features of a font.
 
hi::unicode_mask unicode_mask
 
hi::font_metrics metrics
 The metrics of a font.
 
std::vector< hi::font * > fallback_chain
 List of fonts to use as a fallback for this font.
 

Friends

std::string to_string (font const &rhs) noexcept
 

Detailed Description

A font. This class has information on how to shape text and get glyphs consisting of bezier contours.

Member Function Documentation

◆ find_glyph() [1/2]

virtual hi::glyph_id v1::font::find_glyph ( char32_t c) const
pure virtualnoexcept

Get the glyph for a code-point.

Returns
glyph-id, or invalid when not found or error.

Implemented in v1::true_type_font.

◆ find_glyph() [2/2]

hi::glyph_ids v1::font::find_glyph ( grapheme g) const
noexcept

Get the glyphs for a grapheme.

Returns
a set of glyph-ids, or invalid when not found or error.

◆ get_kerning()

virtual vector2 v1::font::get_kerning ( hi::glyph_id current_glyph,
hi::glyph_id next_glyph ) const
pure virtualnoexcept

Get the kerning between two glyphs.

Parameters
current_glyphThe glyph on the left
next_glyphThe glyph on the right
Returns
The vector to add to the advance of the current_glyph.

Implemented in v1::true_type_font.

◆ load_glyph()

virtual std::optional< hi::glyph_id > v1::font::load_glyph ( hi::glyph_id glyph_id,
graphic_path & path ) const
pure virtualnoexcept

Load a glyph into a path. The glyph is directly loaded from the font file.

Parameters
glyph_idthe id of a glyph inside the font.
pathThe path constructed by the loader.
Returns
empty on failure, or the glyphID of the metrics to use.

Implemented in v1::true_type_font.

◆ load_glyph_metrics()

virtual bool v1::font::load_glyph_metrics ( hi::glyph_id glyph_id,
glyph_metrics & metrics,
hi::glyph_id lookahead_glyph_id = hi::glyph_id{} ) const
pure virtualnoexcept

Load a glyph into a path. The glyph is directly loaded from the font file.

Parameters
glyph_idthe id of a glyph inside the font.
metricsThe metrics constructed by the loader.
lookahead_glyph_idThe id of a glyph to the right, needed for kerning.
Returns
true on success, false on error.

Implemented in v1::true_type_font.

◆ loaded()

virtual bool v1::font::loaded ( ) const
pure virtualnoexcept

Return if the font is loaded.

Returns
true if the font is fully loaded, false if only metadata of the font is available.

Implemented in v1::true_type_font.

◆ substitution_and_kerning()

virtual void v1::font::substitution_and_kerning ( iso_639 language,
iso_15924 script,
std::vector< substitution_and_kerning_type > & word ) const
pure virtualnoexcept

Substitute and kern a run of glyphs.

Parameters
languageThe language that the word is written in.
scriptThe script that the word is written in.
[in,out]

A run of glyphs, from the same font, font-size and script of a word.

Implemented in v1::true_type_font.

Field Documentation

◆ fallback_chain

std::vector<hi::font *> v1::font::fallback_chain

List of fonts to use as a fallback for this font.

◆ family_name

std::string v1::font::family_name

The family name as parsed from the font file.

Examples: "Helvetica", "Times New Roman"

◆ features

std::string v1::font::features

A string representing the features of a font.

This will be a comma separated list of features, mostly tables like 'kern' and 'GPOS'.

◆ metrics

hi::font_metrics v1::font::metrics

The metrics of a font.

Note
: unit is 'em'.

◆ sub_family_name

std::string v1::font::sub_family_name

The sub-family name as parsed from the font file.

Examples: "Regular", "ItalicBold"


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