7#include "unicode_grapheme_cluster_break.hpp"
8#include "unicode_description.hpp"
10namespace hi::inline v1 {
13 unicode_grapheme_cluster_break previous = unicode_grapheme_cluster_break::Other;
15 bool first_character =
true;
16 bool in_extended_pictograph =
false;
20 previous = unicode_grapheme_cluster_break::Other;
22 first_character =
true;
23 in_extended_pictograph =
false;
51void wrap_lines(
auto first,
auto last,
float max_width,
auto get_width,
auto get_code_point,
auto set_code_point)
noexcept
53 using enum unicode_general_category;
55 auto it_at_last_space = last;
56 float width_at_last_space = 0.0;
57 float current_width = 0.0;
59 for (
auto it = first; it != last; ++it) {
60 hilet code_point = get_code_point(*it);
61 hilet description = unicode_description::find(code_point);
62 hilet general_category = description->general_category();
64 if (general_category == Zp || general_category == Zl) {
66 it_at_last_space = last;
67 width_at_last_space = 0.0f;
71 }
else if (general_category == Zs) {
73 it_at_last_space = it;
74 width_at_last_space = current_width;
77 current_width += get_width(*it);
78 if (current_width >= max_width && it_at_last_space != last) {
80 set_code_point(*it, U
'\u2028');
81 it_at_last_space = last;
82 width_at_last_space = 0.0f;
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23
Definition unicode_text_segmentation.hpp:12