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, float dpi_scale) noexcept
 
void initialize_glyph (hi::font_book &font_book, hi::font const &font) noexcept
 Initialize the glyph based on the grapheme.
 
void initialize_glyph (hi::font_book &font_book) noexcept
 Initialize the glyph based on the grapheme.
 
void replace_glyph (char32_t code_point) noexcept
 Called by the bidi-algorithm to mirror glyphs.
 
hi::font_metrics font_metrics () const noexcept
 Get the scaled font metrics for this character.
 
vector2 get_kerning (text_shaper_char const &next) const noexcept
 

Data Fields

hi::grapheme grapheme
 The grapheme.
 
hi::text_style style
 The style of how to display the grapheme.
 
float dpi_scale = 1.0f
 The scale to resize the font's size to match the physical display.
 
hi::glyph_ids glyph
 The glyph representing one or more graphemes.
 
hi::glyph_metrics metrics
 The glyph metrics of the currently 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_description const * description
 The unicode description of the grapheme.
 
unicode_bidi_class direction
 The text direction for this glyph.
 
unicode_script script
 The script of this character.
 
float scale = 1.0f
 The scale of the glyph for displaying on the screen.
 
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()

hi::font_metrics 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 ( hi::font_book & font_book)
noexcept

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_book & font_book,
hi::font const & font )
noexcept

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)
noexcept

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.

◆ description

unicode_description const* v1::text_shaper_char::description

The unicode description of the grapheme.

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

◆ dpi_scale

float v1::text_shaper_char::dpi_scale = 1.0f

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

◆ glyph

hi::glyph_ids v1::text_shaper_char::glyph

The glyph representing one or more graphemes.

The glyph will change during shaping of the text:

  1. The initial 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.

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

◆ 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 currently glyph.

The metrics are scaled by scale.

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

◆ scale

float v1::text_shaper_char::scale = 1.0f

The scale of the glyph for displaying on the screen.

◆ script

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