7#include "unicode_grapheme_cluster_break.hpp"
8#include "unicode_description.hpp"
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;
52void wrap_lines(
auto first,
auto last,
float max_width,
auto get_width,
auto get_code_point,
auto set_code_point)
noexcept
54 using enum unicode_general_category;
56 auto it_at_last_space = last;
57 float width_at_last_space = 0.0;
58 float current_width = 0.0;
60 for (
auto it = first; it != last; ++it) {
61 ttlet code_point = get_code_point(*it);
62 ttlet description = unicode_description_find(code_point);
63 ttlet general_category = description->general_category();
65 if (general_category == Zp || general_category == Zl) {
67 it_at_last_space = last;
68 width_at_last_space = 0.0f;
72 }
else if (general_category == Zs) {
74 it_at_last_space = it;
75 width_at_last_space = current_width;
78 current_width += get_width(*it);
79 if (current_width >= max_width && it_at_last_space != last) {
81 set_code_point(*it, U
'\u2028');
82 it_at_last_space = last;
83 width_at_last_space = 0.0f;
Definition unicode_text_segmentation.hpp:12