diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-04-15 13:32:43 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-04-15 22:27:56 +0300 |
| commit | 740516f01defb95879231b482db3cfd9f300c211 (patch) | |
| tree | 24d44f4e4d30603d8cb9c1823eb55d36fee74dc7 | |
| parent | a49792a88bb06f444c04026764a48d965da270ea (diff) | |
#2023 Fix lsb_delta and rsb_delta support
delta_correction should have been substructed, not added
| -rw-r--r-- | indra/llrender/llfontfreetype.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index b35d1f6a35..8d31d5d2ae 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -389,22 +389,28 @@ F32 LLFontFreetype::getXKerning(const LLFontGlyphInfo* left_glyph_info, const LL FT_Vector delta; - llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta)); + llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, FT_KERNING_UNFITTED, &delta)); // Apply the FreeType auto-hinter's subpixel side-bearing correction between // adjacent glyphs. When the hinter has shifted the right side of the left // glyph or the left side of the right glyph, (rsb_delta - lsb_delta) is the - // sub-pixel nudge that keeps spacing visually even. It combines cleanly with - // the ll_round() that callers apply after kerning: sub-pixel values only - // affect the rounded pen when they cross a half-pixel threshold, matching - // the classic FT_Pos +-32 snap. - S32 delta_correction = 0; - if (left_glyph_info) - delta_correction += left_glyph_info->mRsbDelta; - if (right_glyph_info) - delta_correction -= right_glyph_info->mLsbDelta; + // sub-pixel nudge that keeps spacing visually even. + F32 delta_correction = 0.0f; + if (left_glyph_info && right_glyph_info) + { + // According to FreeType docs, these delta values should only trigger + // discrete ±1 pixel adjustments when they cross certain thresholds. + // Substructing delta_diff from delta.x doesn't work as well as treating + // it as a thresholds + S32 delta_diff = left_glyph_info->mRsbDelta - right_glyph_info->mLsbDelta; + if (delta_diff > 32) + delta_correction = -1.0f; + else if (delta_diff < -31) + delta_correction = 1.0f; + } - return (delta.x + delta_correction) * (1.f / 64.f); + // ft_kerning_unfitted mode always returns 26.6 fixed-point values + return (F32)(delta.x * (1.f / 64.f)) + delta_correction; } bool LLFontFreetype::hasGlyph(llwchar wch) const |
