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

#include <hikogui/font/font_font.hpp>

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

Data Structures

struct  shape_run_result_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.
 
glyph_id find_glyph (char32_t c) const noexcept
 Get the glyph for a code-point.
 
lean_vector< glyph_idfind_glyph (grapheme g) const
 Get the glyphs for a grapheme.
 
virtual graphic_path get_path (hi::glyph_id glyph_id) const =0
 Load a glyph into a path.
 
virtual float get_advance (hi::glyph_id glyph_id) const =0
 Get the advance for a glyph.
 
virtual glyph_metrics get_metrics (hi::glyph_id glyph_id) const =0
 Load a glyph into a path.
 
virtual shape_run_result_type shape_run (iso_639 language, iso_15924 script, gstring run) const =0
 Shape a run of graphemes.
 
glyph_atlas_infoatlas_info (glyph_id glyph) const
 
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
 
font_style style = font_style::normal
 
bool condensed = false
 
font_weight weight = font_weight::regular
 
float optical_size = 12.0
 
font_char_map char_map
 A optimized character map.
 
std::string features
 A string representing the features of a font.
 
font_metrics_em 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]

glyph_id v1::font::find_glyph ( char32_t c) const
inlinenoexcept

Get the glyph for a code-point.

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

◆ find_glyph() [2/2]

lean_vector< glyph_id > v1::font::find_glyph ( grapheme g) const
inline

Get the glyphs for a grapheme.

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

◆ get_advance()

virtual float v1::font::get_advance ( hi::glyph_id glyph_id) const
pure virtual

Get the advance for a glyph.

Parameters
glyph_idThe glyph to look up the advance for.
Returns
The advance for the glyph.
Exceptions
std::exceptionIf there was an error looking up the glyph.

Implemented in v1::true_type_font.

◆ get_metrics()

virtual glyph_metrics v1::font::get_metrics ( hi::glyph_id glyph_id) const
pure virtual

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.

◆ get_path()

virtual graphic_path v1::font::get_path ( hi::glyph_id glyph_id) const
pure virtual

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.
Returns
The path loaded from the font file.
Exceptions
std::exceptionIf there was an error while loading the path. Recommend to disable the font 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.

◆ shape_run()

virtual shape_run_result_type v1::font::shape_run ( iso_639 language,
iso_15924 script,
gstring run ) const
pure virtual

Shape a run of graphemes.

A run of graphemes is a piece of text that is:

  • from the same style,
  • from the same font,
  • from the same language and script, and
  • on the same line.

A run needs to be shaped by the font-file itself as it handles:

  • language/script depended glyph substitution for ligatures, accents and cursive text.
  • language/script depended glyph positioning for kerning, accents and cursive text.
Parameters
languageThe language of this run of graphemes.
scriptThe script of this run of graphemes.
runThe run of graphemes.
Returns
The glyphs and coordinates to display, and coordinates of grapheme for interaction.

Implemented in v1::true_type_font.

Field Documentation

◆ char_map

font_char_map v1::font::char_map

A optimized character map.

This character map is always available even if the font is not loaded.

◆ 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

font_metrics_em v1::font::metrics

The metrics of a font.

◆ 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: