24 end =
string + bx::strLen(
string);
26 BX_ASSERT(
end >=
string,
"");
30 if(
font.line_gap > line_gap_)
32 line_gap_ =
font.line_gap;
35 if((
font.ascender -
font.descender) > line_height_)
37 height_ -= line_height_;
38 line_height_ =
font.ascender -
font.descender;
39 height_ += line_height_;
47 for(; *
string &&
string <
end; ++string)
54 if(codepoint == L
'\n')
56 height_ += line_gap_ +
font.ascender -
font.descender;
57 line_gap_ =
font.line_gap;
58 line_height_ =
font.ascender -
font.descender;
62 float kerning = manager_->
get_kerning(font_handle, previous_codepoint, codepoint);
71 BX_ASSERT(
false,
"Glyph not found");
74 previous_codepoint = codepoint;
78 BX_ASSERT(state ==
UTF8_ACCEPT,
"The string is not well-formed");
114 uint32_t current_line = 0;
116 const char* ptr = str.getPtr();
118 while(ptr != str.getTerm() && (current_line < first_line))
120 for(; ptr != str.getTerm(); ++ptr)
124 if(codepoint == L
'\n')
134 BX_ASSERT(state ==
UTF8_ACCEPT,
"The string is not well-formed");
137 while(ptr != str.getTerm() && (current_line < last_line))
139 for(; ptr != str.getTerm(); ++ptr)
143 if(codepoint == L
'\n')
153 BX_ASSERT(state ==
UTF8_ACCEPT,
"The string is not well-formed");
text_line_metrics(const font_info &info)
auto get_line_count(const bx::StringView &str) const -> uint32_t
Return the number of text line in the given text.
void get_sub_text(const bx::StringView &str, uint32_t first_line, uint32_t last_line, const char *&begin, const char *&end)
Return the first and last character visible in the [first_line, last_line] range.
auto clear_text() -> void
Clear the width and height of the measured text.
auto append_text(font_handle handle, const char *str, const char *end=nullptr) -> void
Append an ASCII/utf-8 string to the metrics helper.
text_metrics(font_manager *manager)