Skip to content

Commit

Permalink
Bug 1721612 - Fix AdjustAdvancesForSyntheticBold to reliably handle n…
Browse files Browse the repository at this point in the history
…egative 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
  • Loading branch information
jfkthame committed Nov 11, 2023
1 parent 0332420 commit 737870d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gfx/thebes/gfxFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 737870d

Please sign in to comment.