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

Public Member Functions

 text_shaper_char (hi::grapheme const &grapheme, text_style const &style, hi::pixel_density pixel_density) noexcept
 
void initialize_glyph (hi::font const &font) noexcept
 Initialize the glyph based on the grapheme.
 
void initialize_glyph () noexcept
 Initialize the glyph based on the grapheme.
 
void replace_glyph (char32_t code_point) noexcept
 Called by the bidi-algorithm to mirror glyphs.
 
font_metrics_px font_metrics () const noexcept
 Get the scaled font metrics for this character.
 

Data Fields

hi::grapheme grapheme
 The grapheme.
 
hi::text_style style
 The style of how to display the grapheme.
 
pixel_density pixel_density
 The scale to resize the font's size to match the physical display.
 
hi::font_book::font_glyphs_type glyphs
 The glyph representing one or more graphemes.
 
hi::glyph_metrics metrics
 The glyph metrics of the current starter glyph.
 
size_t line_nr
 The line number where this character is located, counting from top to bottom line.
 
size_t column_nr
 The column number where the character is located on the line, counting from left to right in display order.
 
point2 position
 Position of the character.
 
aarectangle rectangle
 The rectangle for this character.
 
unicode_general_category general_category
 The general category of this grapheme.
 
unicode_bidi_class direction
 The text direction for this glyph.
 
iso_15924 script
 The script of this character.
 
au::Quantity< PixelsPerEm, float > font_size
 The font size in pixels, rounded so that the x-height is rounded to the nearest pixel.
 
float width = 0.0f
 The width used for this grapheme when folding lines.
 
bool is_trailing_white_space = false
 Set to true if this glyph is a white space at the end of a line.
 
bool glyph_is_initial = false
 The glyph is the initial glyph.
 

Friends

bool operator== (text_shaper_char const &lhs, char32_t const &rhs) noexcept
 
bool operator== (text_shaper_char const &lhs, char const &rhs) noexcept
 

Member Function Documentation

◆ font_metrics()

font_metrics_px v1::text_shaper_char::font_metrics ( ) const
inlinenoexcept

Get the scaled font metrics for this character.

◆ initialize_glyph() [1/2]

void v1::text_shaper_char::initialize_glyph ( )
inlinenoexcept

Initialize the glyph based on the grapheme.

Note
The glyph is only initialized when glyph_is_initial == false.
Postcondition
glyph, metrics and width are modified. glyph_is_initial is set to true.

◆ initialize_glyph() [2/2]

void v1::text_shaper_char::initialize_glyph ( hi::font const & font)
inlinenoexcept

Initialize the glyph based on the grapheme.

Note
The glyph is only initialized when glyph_is_initial == false.
Postcondition
glyph, metrics and width are modified. glyph_is_initial is set to true.

◆ replace_glyph()

void v1::text_shaper_char::replace_glyph ( char32_t code_point)
inlinenoexcept

Called by the bidi-algorithm to mirror glyphs.

The glyph is replaced with a glyph from the same font using the given code-point.

Precondition
glyph.num_grapheme == 1.
Postcondition
glyph and metrics are modified. glyph_is_initial is set to false.
Note
The width remains based on the original glyph.

Field Documentation

◆ column_nr

size_t v1::text_shaper_char::column_nr

The column number where the character is located on the line, counting from left to right in display order.

◆ direction

unicode_bidi_class v1::text_shaper_char::direction

The text direction for this glyph.

This is needed to figure out where the location of the insert cursor is compared to the character.

◆ font_size

au::Quantity<PixelsPerEm, float> v1::text_shaper_char::font_size

The font size in pixels, rounded so that the x-height is rounded to the nearest pixel.

◆ general_category

unicode_general_category v1::text_shaper_char::general_category

The general category of this grapheme.

◆ glyph_is_initial

bool v1::text_shaper_char::glyph_is_initial = false

The glyph is the initial glyph.

This flag is set to true after loading the initial glyph. This flag is set to false when the glyph is replaced by the bidi-algorithm or glyph-morphing.

◆ glyphs

hi::font_book::font_glyphs_type v1::text_shaper_char::glyphs

The glyph representing one or more graphemes.

The glyph will change during shaping of the text:

  1. The starter glyph, used for determining the width of the grapheme and the folding algorithm.
  2. The glyph representing a bracket may be replaced with a mirrored bracket by the bidi-algorithm.
  3. The glyph may be replaced by the font using the glyph-morphing algorithms for better continuation of cursive text and merging of graphemes into a ligature.

◆ grapheme

hi::grapheme v1::text_shaper_char::grapheme

The grapheme.

◆ is_trailing_white_space

bool v1::text_shaper_char::is_trailing_white_space = false

Set to true if this glyph is a white space at the end of a line.

◆ line_nr

size_t v1::text_shaper_char::line_nr

The line number where this character is located, counting from top to bottom line.

◆ metrics

hi::glyph_metrics v1::text_shaper_char::metrics

The glyph metrics of the current starter glyph.

The metrics are scaled by scale.

◆ pixel_density

pixel_density v1::text_shaper_char::pixel_density

The scale to resize the font's size to match the physical display.

◆ position

point2 v1::text_shaper_char::position

Position of the character.

For a non-ligature this is the origin of the glyph, where the actual glyph is located at position + metrics.bounding_rectangle. For ligatures the position is moved based on the advance of each character within the ligature.

◆ rectangle

aarectangle v1::text_shaper_char::rectangle

The rectangle for this character.

The rectangle is used for:

  • creating a selection box around the character.
  • creating cursors before, after and on the character.
  • converting mouse-position to character.

The attributes of the rectangle are:

  • left side is equal to the position.x
  • The width is the advance of the character within the ligature. Or if the glyph is not a ligature the width is the same as the advance.
  • The bottom is at the descender
  • The top is at the ascender

When multiple characters are converted to a ligature, the rectangle of each of those characters occupies a subsection of the ligature-glyph. In this case the left most character will contain the ligature-glyph, and the rest of the characters of the ligature will have empty glyphs.

◆ script

iso_15924 v1::text_shaper_char::script

The script of this character.

The script of the character is based on:

  • The actual script of this unicode character, or if unicode_script::Common;
  • The script of characters before/after this character in the same word, or if unicode_script::Common;
  • The script passed during construction of the text_shaper.

◆ style

hi::text_style v1::text_shaper_char::style

The style of how to display the grapheme.

◆ width

float v1::text_shaper_char::width = 0.0f

The width used for this grapheme when folding lines.

This width is based on the initial glyph's advance after converting the grapheme using the text-style into a glyph. This width excludes kerning and glyph-morphing.


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