summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-09-01 22:52:51 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-09-02 20:08:00 +0300
commitf82de8d930f853353f6bbad7e2f20ca45516d90d (patch)
treeef4c402714047f55c6c516b0ffdbedfe00b598cc
parent9f1bf3dd956061ea7d73d348cd918fb9742d6664 (diff)
#6225 Fix tbular number width inconsistency
Renamed mXAdvance into mXAdvanceRaw to make it clearer that value shouldn't be used directly.
-rw-r--r--indra/llrender/llfontfreetype.cpp18
-rw-r--r--indra/llrender/llfontfreetype.h2
-rw-r--r--indra/llrender/llfontgl.cpp15
3 files changed, 19 insertions, 16 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index 5af6b61513..bd4df8983c 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -113,7 +113,7 @@ LLFontGlyphInfo::LLFontGlyphInfo(U32 index, EFontGlyphType glyph_type)
mChar(0),
mWidth(0), // In pixels
mHeight(0), // In pixels
- mXAdvance(0.f), // In pixels
+ mXAdvanceRaw(0.f), // In pixels
mYAdvance(0.f), // In pixels
mXBitmapOffset(0), // Offset to the origin in the bitmap
mYBitmapOffset(0), // Offset to the origin in the bitmap
@@ -131,7 +131,7 @@ LLFontGlyphInfo::LLFontGlyphInfo(const LLFontGlyphInfo& fgi)
, mChar(fgi.mChar)
, mWidth(fgi.mWidth)
, mHeight(fgi.mHeight)
- , mXAdvance(fgi.mXAdvance)
+ , mXAdvanceRaw(fgi.mXAdvanceRaw)
, mYAdvance(fgi.mYAdvance)
, mXBitmapOffset(fgi.mXBitmapOffset)
, mYBitmapOffset(fgi.mYBitmapOffset)
@@ -354,14 +354,14 @@ F32 LLFontFreetype::getXAdvance(llwchar wch) const
{
return mMaxDigitWidth;
}
- return gi->mXAdvance;
+ return gi->mXAdvanceRaw;
}
else
{
char_glyph_info_map_t::iterator found_it = mCharGlyphInfoMap.find((llwchar)0);
if (found_it != mCharGlyphInfoMap.end())
{
- return found_it->second->mXAdvance;
+ return found_it->second->mXAdvanceRaw;
}
}
@@ -380,7 +380,7 @@ F32 LLFontFreetype::getXAdvance(const LLFontGlyphInfo* glyph) const
return mMaxDigitWidth;
}
- return glyph->mXAdvance;
+ return glyph->mXAdvanceRaw;
}
F32 LLFontFreetype::getXKerning(llwchar char_left, llwchar char_right) const
@@ -635,15 +635,15 @@ LLFontGlyphInfo* LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, l
gi->mLsbDelta = (S32)fontp->mFTFace->glyph->lsb_delta;
gi->mRsbDelta = (S32)fontp->mFTFace->glyph->rsb_delta;
// Convert these from 26.6 units to float pixels.
- gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
+ gi->mXAdvanceRaw = fontp->mFTFace->glyph->advance.x / 64.f;
gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
if (mWeight > 0 && wch >= '0' && wch <= '9')
{
// Digits are supposed to be preloaded, and buffers
- // refresh when new chars get added, so this lazy load
- // should not cause any issues.
- mMaxDigitWidth = llmax(mMaxDigitWidth, gi->mXAdvance);
+ // refresh when new chars get added (mGeneration),
+ // so this lazy load should not cause any issues.
+ mMaxDigitWidth = llmax(mMaxDigitWidth, gi->mXAdvanceRaw);
}
insertGlyphInfo(wch, gi);
diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h
index 3191ca8df7..608313b4d6 100644
--- a/indra/llrender/llfontfreetype.h
+++ b/indra/llrender/llfontfreetype.h
@@ -83,7 +83,7 @@ struct LLFontGlyphInfo
// Metrics
S32 mWidth; // In pixels
S32 mHeight; // In pixels
- F32 mXAdvance; // In pixels
+ F32 mXAdvanceRaw; // In pixels, don't use directly, use getXAdvance() for tabular numbers to work correctly.
F32 mYAdvance; // In pixels
// Information for actually rendering
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index bb5a12375e..3995daae16 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
@@ -673,12 +674,14 @@ 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)
if (scaled_max_pixels < cur_x + width_padding)
@@ -743,7 +746,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) )
{