HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
text_shaper_line.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_shaper_char.hpp"
8#include "font_metrics.hpp"
9#include "../unicode/unicode_bidi_class.hpp"
10#include "../geometry/axis_aligned_rectangle.hpp"
11#include "../alignment.hpp"
12#include <vector>
13
14namespace hi::inline v1 {
15
17public:
18 using iterator = std::vector<text_shaper_char>::iterator;
19 using const_iterator = std::vector<text_shaper_char>::const_iterator;
21
24 iterator first;
25
28 iterator last;
29
35
39
42 size_t line_nr;
43
46 float y;
47
57
60 float width;
61
69 unicode_general_category last_category;
70
76
87 size_t line_nr,
88 const_iterator begin,
89 iterator first,
90 iterator last,
91 float width,
92 hi::font_metrics const &metrics) noexcept;
93
94 [[nodiscard]] constexpr size_t size() const noexcept
95 {
96 return columns.size();
97 }
98
99 [[nodiscard]] constexpr iterator front() const noexcept
100 {
101 return columns.front();
102 }
103
104 [[nodiscard]] constexpr iterator back() const noexcept
105 {
106 return columns.back();
107 }
108
109 iterator operator[](size_t index) const noexcept
110 {
111 hi_assert_bounds(index, columns);
112 return columns[index];
113 }
114
115 void layout(horizontal_alignment alignment, float min_x, float max_x, float sub_pixel_width) noexcept;
116
121 [[nodiscard]] std::pair<const_iterator,bool> get_nearest(point2 position) const noexcept;
122};
123
124}
DOXYGEN BUG.
Definition algorithm.hpp:15
unicode_bidi_class
Bidirectional class Unicode Standard Annex #9: https://unicode.org/reports/tr9/.
Definition unicode_bidi_class.hpp:17
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
The metrics of a font.
Definition font_metrics.hpp:15
Definition text_shaper_line.hpp:16
size_t line_nr
The line number of this line, counted from top to bottom.
Definition text_shaper_line.hpp:42
unicode_general_category last_category
Category of the last character on the line.
Definition text_shaper_line.hpp:69
std::pair< const_iterator, bool > get_nearest(point2 position) const noexcept
Get the character nearest to position.
text_shaper_line(size_t line_nr, const_iterator begin, iterator first, iterator last, float width, hi::font_metrics const &metrics) noexcept
Construct a line.
float width
The width of this line, excluding trailing white space, glyph morphing and kerning.
Definition text_shaper_line.hpp:60
font_metrics metrics
The maximum metrics of the font of each glyph on this line.
Definition text_shaper_line.hpp:38
float y
Position of the base-line of this line.
Definition text_shaper_line.hpp:46
iterator first
The first character in the line, in logical order.
Definition text_shaper_line.hpp:24
unicode_bidi_class paragraph_direction
The writing direction of the paragraph.
Definition text_shaper_line.hpp:75
column_vector columns
Iterators to the characters in the text.
Definition text_shaper_line.hpp:34
iterator last
One beyond the last character in the line, in logical order.
Definition text_shaper_line.hpp:28
aarectangle rectangle
The rectangle of the line.
Definition text_shaper_line.hpp:56
T back(T... args)
T front(T... args)
T size(T... args)