summaryrefslogtreecommitdiff
path: root/indra/llrender/llfontgl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llfontgl.cpp')
-rw-r--r--indra/llrender/llfontgl.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index bb5a12375e..89da15ed43 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -349,8 +349,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
F32 x_offset = 0.0f;
if (mFontFreetype->getFontWeight() > 0 && fgi->mChar >= '0' && fgi->mChar <= '9' && mFontFreetype->getMaxDigitWidth() > 0.0f)
{
- // use mXAdvance directly here, since we don't want to get max width instead.
- x_offset = (mFontFreetype->getMaxDigitWidth() - fgi->mXAdvance) * 0.5f;
+ // getXAdvance will return max digit width.
+ // use mXAdvanceRaw directly here, since we don't want to get max width instead.
+ x_offset = (mFontFreetype->getMaxDigitWidth() - fgi->mXAdvanceRaw) * 0.5f;
}
// Draw the text at the appropriate location
@@ -613,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;
@@ -673,21 +679,25 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch
}
}
+ F32 advance = mFontFreetype->getXAdvance(fgi);
+
// account for glyphs that run beyond the starting point for the next glyphs
width_padding = llmax( 0.f, // always use positive padding amount
- width_padding - fgi->mXAdvance, // previous padding left over after advance of current character
- (F32)(fgi->mWidth + fgi->mXBearing) - fgi->mXAdvance); // difference between width of this character and advance to next character
+ width_padding - advance, // previous padding left over after advance of current character
+ (F32)(fgi->mWidth + fgi->mXBearing) - advance); // difference between width of this character and advance to next character
- cur_x += fgi->mXAdvance;
+ 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);
@@ -743,7 +753,7 @@ S32 LLFontGL::firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_
// other characters just use advance
F32 width = (i == start)
? (F32)(fgi->mWidth + fgi->mXBearing) // use actual width for last character
- : fgi->mXAdvance; // use advance for all other characters
+ : mFontFreetype->getXAdvance(fgi); // use advance for all other characters
if( scaled_max_pixels < (total_width + width) )
{