7#include "text_shaper_char.hpp"
8#include "text_shaper_line.hpp"
9#include "text_cursor.hpp"
10#include "text_style.hpp"
11#include "../layout/box_constraints.hpp"
12#include "../font/module.hpp"
13#include "../geometry/module.hpp"
14#include "../unicode/module.hpp"
18namespace hi::inline
v1 {
37 using char_iterator = char_vector::iterator;
38 using char_const_iterator = char_vector::const_iterator;
39 using char_reference = char_vector::reference;
40 using char_const_reference = char_vector::const_reference;
42 using line_iterator = line_vector::iterator;
43 using line_const_iterator = line_vector::const_iterator;
91 std::string_view
text,
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
161 [[nodiscard]] aarectangle
162 bounding_rectangle(
float maximum_line_width,
float line_spacing = 1.0f,
float paragraph_spacing = 1.5f) noexcept;
176 [[nodiscard]]
void layout(
177 aarectangle rectangle,
179 extent2 sub_pixel_size,
180 float line_spacing = 1.0f,
181 float paragraph_spacing = 1.5f) noexcept;
185 [[nodiscard]] aarectangle rectangle() const noexcept
194 return _text_direction;
204 return resolve(_alignment, _text_direction == unicode_bidi_class::L);
214 [[nodiscard]] char_const_iterator
get_it(
size_t index)
const noexcept;
225 return get_it(cursor.index());
236 [[nodiscard]] char_const_iterator
get_it(
size_t column,
size_t row)
const noexcept;
247 return get_it(column_row.first, column_row.second);
264 return get_column_line(get_it(index));
274 return get_column_line(cursor.index());
282 [[nodiscard]]
size_t get_index(text_shaper::char_const_iterator it)
const noexcept;
301 [[nodiscard]]
text_cursor get_before_cursor(
size_t index) const noexcept;
308 [[nodiscard]]
text_cursor get_after_cursor(
size_t index) const noexcept;
317 return get_before_cursor(get_index(it));
327 return get_after_cursor(get_index(it));
390 [[nodiscard]] char_const_iterator
move_left_char(char_const_iterator it)
const noexcept;
397 [[nodiscard]] char_const_iterator
move_right_char(char_const_iterator it)
const noexcept;
453 unicode_bidi_class _text_direction;
471 aarectangle _rectangle;
482 aarectangle rectangle,
484 extent2 sub_pixel_size,
486 float paragraph_spacing)
noexcept;
494 void position_glyphs(aarectangle rectangle, extent2 sub_pixel_size)
noexcept;
498 void resolve_script() noexcept;
504 get_line_metrics(
text_shaper::char_const_iterator first,
text_shaper::char_const_iterator last) const noexcept;
512 [[nodiscard]]
float get_text_height(
std::vector<
size_t> const& lines) const noexcept;
DOXYGEN BUG.
Definition algorithm.hpp:13
font_book keeps track of multiple fonts.
Definition font_book.hpp:31
The metrics of a font.
Definition font_metrics.hpp:15
Horizontal/Vertical alignment combination.
Definition alignment.hpp:239
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
A variant of text.
Definition label.hpp:31
A cursor-position in text.
Definition text_cursor.hpp:22
Text shaper.
Definition text_shaper.hpp:34
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:262
char_const_iterator get_it(text_cursor cursor) const noexcept
Get the character at the cursor.
Definition text_shaper.hpp:223
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.
aarectangle bounding_rectangle(float maximum_line_width, float line_spacing=1.0f, float paragraph_spacing=1.5f) noexcept
Get bounding rectangle.
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:325
unicode_bidi_class text_direction() const noexcept
Get the text-direction as a whole.
Definition text_shaper.hpp:192
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.
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:245
text_cursor get_begin_cursor() const noexcept
Get the cursor at the beginning of the document.
alignment resolved_alignment() const noexcept
Get the resolved alignment of the text.
Definition text_shaper.hpp:202
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:272
text_cursor get_right_cursor(text_shaper::char_const_iterator it) const noexcept
Get the cursor right of the character in display order.
char_const_iterator move_left_char(char_const_iterator it) const noexcept
Get the character to the left.
text_shaper(hi::font_book &font_book, gstring const &text, text_style const &style, float dpi_scale, hi::alignment alignment, bool left_to_right, iso_15924 script=iso_15924{"Zyyy"}) noexcept
Construct a text_shaper with a text and alignment.
Definition text_style.hpp:172
Definition unicode_bidi.hpp:18