diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-09-01 23:17:31 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-09-02 20:08:00 +0300 |
| commit | d2ab29022bcec8e0c226d91de14daea6d69c71be (patch) | |
| tree | 2f060f6d6e8ada4ed68d805d466831e199e65651 /indra/llrender | |
| parent | f82de8d930f853353f6bbad7e2f20ca45516d90d (diff) | |
#6225 Improve font width checks
by making maxDrawableChars match closer to render()
Diffstat (limited to 'indra/llrender')
| -rw-r--r-- | indra/llrender/llfontgl.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 3995daae16..89da15ed43 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -614,10 +614,15 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch S32 start_of_last_word = 0; bool in_word = false; - // avoid S32 overflow when max_pixels == S32_MAX by staying in floating point F32 scaled_max_pixels = max_pixels * sScaleX; + if (scaled_max_pixels >= (F32)S32_MAX) + { + scaled_max_pixels = (F32)S32_MAX; + } + F32 width_padding = 0.f; + const S32 LAST_CHARACTER = LLFontFreetype::LAST_CHAR_FULL; LLFontGlyphInfo* next_glyph = NULL; S32 i; @@ -683,14 +688,16 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch cur_x += advance; - // clip if current character runs past scaled_max_pixels (using width_padding) + // Clip if current character runs past scaled_max_pixels (using width_padding) if (scaled_max_pixels < cur_x + width_padding) { clip = true; break; } - if (((i+1) < max_chars) && wchars[i+1]) + if (((i+1) < max_chars) + && wchars[i+1] + && (wchars[i + 1] < LAST_CHARACTER)) { // Kern this puppy. next_glyph = mFontFreetype->getGlyphInfo(wchars[i+1], EFontGlyphType::Unspecified); |
