7#include "text_shaper_char.hpp"
8#include "text_shaper_line.hpp"
9#include "text_cursor.hpp"
10#include "glyph_metrics.hpp"
11#include "font_metrics.hpp"
12#include "text_style.hpp"
13#include "glyph_ids.hpp"
15#include "../unicode/unicode_description.hpp"
16#include "../unicode/unicode_break_opportunity.hpp"
17#include "../unicode/grapheme.hpp"
18#include "../unicode/gstring.hpp"
23namespace hi::inline v1 {
42 using char_iterator = char_vector::iterator;
43 using char_const_iterator = char_vector::const_iterator;
45 using line_iterator = line_vector::iterator;
46 using line_const_iterator = line_vector::const_iterator;
89 unicode_script script = unicode_script::Common)
noexcept;
93 std::string_view text,
96 unicode_script script = unicode_script::Common)
noexcept;
98 [[nodiscard]]
bool empty() const noexcept
100 return _text.empty();
103 [[nodiscard]]
size_t size() const noexcept
108 [[nodiscard]] char_iterator begin() noexcept
110 return _text.begin();
113 [[nodiscard]] char_const_iterator
begin() const noexcept
115 return _text.begin();
118 [[nodiscard]] char_const_iterator cbegin() const noexcept
120 return _text.cbegin();
123 [[nodiscard]] char_iterator
end() noexcept
128 [[nodiscard]] char_const_iterator
end() const noexcept
133 [[nodiscard]] char_const_iterator cend() const noexcept
138 auto const &lines() const noexcept
164 float maximum_line_width,
166 float line_spacing = 1.0f,
167 float paragraph_spacing = 1.5f) noexcept;
189 [[nodiscard]]
void layout(
193 unicode_bidi_class writing_direction,
195 float line_spacing = 1.0f,
196 float paragraph_spacing = 1.5f)
noexcept;
212 [[nodiscard]] char_const_iterator
get_it(
size_t index)
const noexcept;
223 return get_it(cursor.index());
234 [[nodiscard]] char_const_iterator
get_it(
size_t column,
size_t row)
const noexcept;
245 return get_it(column_row.first, column_row.second);
262 return get_column_line(get_it(index));
272 return get_column_line(cursor.index());
280 [[nodiscard]]
size_t get_index(text_shaper::char_const_iterator it)
const noexcept;
299 [[nodiscard]]
text_cursor get_before_cursor(
size_t index) const noexcept;
306 [[nodiscard]]
text_cursor get_after_cursor(
size_t index) const noexcept;
315 return get_before_cursor(get_index(it));
325 return get_after_cursor(get_index(it));
388 [[nodiscard]] char_const_iterator
move_left_char(char_const_iterator it)
const noexcept;
395 [[nodiscard]] char_const_iterator
move_right_char(char_const_iterator it)
const noexcept;
445 unicode_script _script;
476 unicode_bidi_class writing_direction,
478 float paragraph_spacing)
noexcept;
488 void position_glyphs(
492 unicode_bidi_class writing_direction)
noexcept;
496 void resolve_script() noexcept;
vertical_alignment
Vertical alignment.
Definition alignment.hpp:17
horizontal_alignment
Definition alignment.hpp:31
Definition alignment.hpp:64
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
A rectangle / parallelogram in 3D space.
Definition rectangle.hpp:20
font_book keeps track of multiple fonts.
Definition font_book.hpp:30
The metrics of a font.
Definition font_metrics.hpp:15
Definition text_cursor.hpp:18
Text shaper.
Definition text_shaper.hpp:39
char_const_iterator get_it(size_t column, size_t row) const noexcept
Get the character at column and row in display order.
std::pair< text_cursor, text_cursor > select_paragraph(text_cursor cursor) const noexcept
Get the selection for a paragraph at the cursor.
std::pair< size_t, size_t > get_column_line(size_t index) const noexcept
Get the column and line of a character.
Definition text_shaper.hpp:260
char_const_iterator get_it(text_cursor cursor) const noexcept
Get the character at the cursor.
Definition text_shaper.hpp:221
std::pair< text_cursor, text_cursor > select_sentence(text_cursor cursor) const noexcept
Get the selection for the sentence at the cursor.
bool is_on_left(text_cursor cursor) const noexcept
Check if the cursor is on the left side of the character in display order.
bool is_on_right(text_cursor cursor) const noexcept
Check if the cursor is on the right side of the character in display order.
text_cursor get_after_cursor(text_shaper::char_const_iterator it) const noexcept
Get the cursor after the character in logical order.
Definition text_shaper.hpp:323
aarectangle rectangle() const noexcept
The rectangle used when laying out the text.
Definition text_shaper.hpp:200
std::pair< text_cursor, text_cursor > select_char(text_cursor cursor) const noexcept
Get the selection for the character at the cursor.
std::pair< size_t, size_t > get_column_line(text_shaper::char_const_iterator it) const noexcept
Get the column and line of a character.
text_cursor get_left_cursor(text_shaper::char_const_iterator it) const noexcept
Get the cursor left of the character in display order.
std::pair< text_cursor, text_cursor > select_word(text_cursor cursor) const noexcept
Get the selection for the word at the cursor.
std::pair< aarectangle, float > bounding_rectangle(float maximum_line_width, vertical_alignment alignment, float line_spacing=1.0f, float paragraph_spacing=1.5f) noexcept
Get bounding rectangle.
size_t get_index(text_shaper::char_const_iterator it) const noexcept
Get the index of the character in logical order.
char_const_iterator get_it(size_t index) const noexcept
Get the character at index in logical order.
std::pair< text_cursor, text_cursor > select_document(text_cursor cursor) const noexcept
Get the selection for a paragraph at the cursor.
text_cursor get_nearest_cursor(point2 point) const noexcept
find the nearest character.
char_const_iterator move_right_char(char_const_iterator it) const noexcept
Get the character to the right.
char_const_iterator get_it(std::pair< size_t, size_t > column_row) const noexcept
Get the character at column and row in display order.
Definition text_shaper.hpp:243
text_cursor get_begin_cursor() const noexcept
Get the cursor at the beginning of the document.
std::pair< size_t, size_t > get_column_line(text_cursor cursor) const noexcept
Get the column and line of a character.
Definition text_shaper.hpp:270
text_cursor get_right_cursor(text_shaper::char_const_iterator it) const noexcept
Get the cursor right of the character in display order.
text_shaper(hi::font_book &font_book, gstring const &text, text_style const &style, float dpi_scale, unicode_script script=unicode_script::Common) noexcept
Construct a text_shaper with a text and alignment.
char_const_iterator move_left_char(char_const_iterator it) const noexcept
Get the character to the left.
Definition text_style.hpp:18