From 737870d844f00d78e4dd99c3901054f0a202a3f4 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Sat, 11 Nov 2023 10:36:17 +0000 Subject: [PATCH] Bug 1721612 - Fix AdjustAdvancesForSyntheticBold to reliably handle negative adjustments. r=gfx-reviewers,lsalzman This method (as its name suggests) was originally created to handle synthetic-bold, which only ever increases the advance, and so its use of an unsigned value for the adjustment worked ok. But when applying tracking, the adjustment may be negative, and assigning this to a uint32_t value takes us into undefined-behavior territory. It seems this worked "as expected" on x86_64 (using modulo arithmetic), but on arm64 the value just clamped to zero, and the intended negative tracking doesn't get applied. Making it an int32_t results in consistent behavior across both architectures. Differential Revision: https://phabricator.services.mozilla.com/D193288 --- gfx/thebes/gfxFont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 9755ac4cff2a6..19b0f5d3eabc9 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -843,7 +843,7 @@ bool gfxShapedText::FilterIfIgnorable(uint32_t aIndex, uint32_t aCh) { void gfxShapedText::AdjustAdvancesForSyntheticBold(float aSynBoldOffset, uint32_t aOffset, uint32_t aLength) { - uint32_t synAppUnitOffset = aSynBoldOffset * mAppUnitsPerDevUnit; + int32_t synAppUnitOffset = aSynBoldOffset * mAppUnitsPerDevUnit; CompressedGlyph* charGlyphs = GetCharacterGlyphs(); for (uint32_t i = aOffset; i < aOffset + aLength; ++i) { CompressedGlyph* glyphData = charGlyphs + i;