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/module.hpp"
9#include "../unicode/module.hpp"
10#include "../geometry/module.hpp"
11#include <vector>
12
13namespace hi::inline v1 {
14
16public:
17 using iterator = std::vector<text_shaper_char>::iterator;
18 using const_iterator = std::vector<text_shaper_char>::const_iterator;
20
23 iterator first;
24
27 iterator last;
28
34
38
41 size_t line_nr;
42
45 float y;
46
55 aarectangle rectangle;
56
59 float width;
60
68 unicode_general_category last_category;
69
74 unicode_bidi_class paragraph_direction;
75
86 size_t line_nr,
87 const_iterator begin,
88 iterator first,
89 iterator last,
90 float width,
91 hi::font_metrics const &metrics) noexcept;
92
93 [[nodiscard]] constexpr size_t size() const noexcept
94 {
95 return columns.size();
96 }
97
98 [[nodiscard]] constexpr iterator front() const noexcept
99 {
100 return columns.front();
101 }
102
103 [[nodiscard]] constexpr iterator back() const noexcept
104 {
105 return columns.back();
106 }
107
108 iterator operator[](size_t index) const noexcept
109 {
110 hi_assert_bounds(index, columns);
111 return columns[index];
112 }
113
114 void layout(horizontal_alignment alignment, float min_x, float max_x, float sub_pixel_width) noexcept;
115
120 [[nodiscard]] std::pair<const_iterator,bool> get_nearest(point2 position) const noexcept;
121};
122
123}
#define hi_assert_bounds(x,...)
Assert if a value is within bounds.
Definition assert.hpp:225
DOXYGEN BUG.
Definition algorithm.hpp:13
The metrics of a font.
Definition font_metrics.hpp:15
Definition text_shaper_line.hpp:15
size_t line_nr
The line number of this line, counted from top to bottom.
Definition text_shaper_line.hpp:41
unicode_general_category last_category
Category of the last character on the line.
Definition text_shaper_line.hpp:68
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:59
font_metrics metrics
The maximum metrics of the font of each glyph on this line.
Definition text_shaper_line.hpp:37
float y
Position of the base-line of this line.
Definition text_shaper_line.hpp:45
iterator first
The first character in the line, in logical order.
Definition text_shaper_line.hpp:23
unicode_bidi_class paragraph_direction
The writing direction of the paragraph.
Definition text_shaper_line.hpp:74
column_vector columns
Iterators to the characters in the text.
Definition text_shaper_line.hpp:33
iterator last
One beyond the last character in the line, in logical order.
Definition text_shaper_line.hpp:27
aarectangle rectangle
The rectangle of the line.
Definition text_shaper_line.hpp:55
T back(T... args)
T front(T... args)
T size(T... args)