HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
text_shaper_char.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "text_style.hpp"
8#include "../font/module.hpp"
9#include "../unicode/module.hpp"
10#include "../geometry/module.hpp"
11
12namespace hi::inline v1 {
13class font_book;
14
16public:
19 hi::grapheme grapheme;
20
23 hi::text_style style;
24
27 float dpi_scale = 1.0f;
28
39 hi::glyph_ids glyph;
40
45 hi::glyph_metrics metrics;
46
49 size_t line_nr;
50
53 size_t column_nr;
54
62
83 aarectangle rectangle;
84
87 unicode_general_category general_category;
88
93 unicode_bidi_class direction;
94
102
105 float scale = 1.0f;
106
112 float width = 0.0f;
113
116 bool is_trailing_white_space = false;
117
124 bool glyph_is_initial = false;
125
126 [[nodiscard]] text_shaper_char(hi::grapheme const& grapheme, text_style const& style, float dpi_scale) noexcept;
127
133 void initialize_glyph(hi::font_book const& font_book, hi::font const& font) noexcept;
134
140 void initialize_glyph(hi::font_book& font_book) noexcept;
141
150 void replace_glyph(char32_t code_point) noexcept;
151
154 [[nodiscard]] hi::font_metrics font_metrics() const noexcept
155 {
156 return scale * glyph.font().metrics;
157 }
158
159 [[nodiscard]] friend bool operator==(text_shaper_char const& lhs, char32_t const& rhs) noexcept
160 {
161 return lhs.grapheme == rhs;
162 }
163
164 [[nodiscard]] friend bool operator==(text_shaper_char const& lhs, char const& rhs) noexcept
165 {
166 return lhs.grapheme == rhs;
167 }
168
169private:
172 void set_glyph(hi::glyph_ids&& new_glyph) noexcept;
173};
174
175} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:13
Definition font.hpp:30
font_book keeps track of multiple fonts.
Definition font_book.hpp:31
A high-level geometric point Part of the high-level vec, point, mat and color types.
Definition point2.hpp:23
ISO-15924 script code.
Definition iso_15924.hpp:17
Definition text_shaper_char.hpp:15
size_t line_nr
The line number where this character is located, counting from top to bottom line.
Definition text_shaper_char.hpp:49
void initialize_glyph(hi::font_book &font_book) noexcept
Initialize the glyph based on the grapheme.
unicode_bidi_class direction
The text direction for this glyph.
Definition text_shaper_char.hpp:93
hi::font_metrics font_metrics() const noexcept
Get the scaled font metrics for this character.
Definition text_shaper_char.hpp:154
hi::grapheme grapheme
The grapheme.
Definition text_shaper_char.hpp:19
hi::glyph_ids glyph
The glyph representing one or more graphemes.
Definition text_shaper_char.hpp:39
point2 position
Position of the character.
Definition text_shaper_char.hpp:61
hi::glyph_metrics metrics
The glyph metrics of the currently glyph.
Definition text_shaper_char.hpp:45
iso_15924 script
The script of this character.
Definition text_shaper_char.hpp:101
unicode_general_category general_category
The general category of this grapheme.
Definition text_shaper_char.hpp:87
size_t column_nr
The column number where the character is located on the line, counting from left to right in display ...
Definition text_shaper_char.hpp:53
aarectangle rectangle
The rectangle for this character.
Definition text_shaper_char.hpp:83
void initialize_glyph(hi::font_book const &font_book, hi::font const &font) noexcept
Initialize the glyph based on the grapheme.
hi::text_style style
The style of how to display the grapheme.
Definition text_shaper_char.hpp:23
void replace_glyph(char32_t code_point) noexcept
Called by the bidi-algorithm to mirror glyphs.
Definition text_style.hpp:172
A grapheme-cluster, what a user thinks a character is.
Definition grapheme.hpp:44