Bug 1961387 - Account for scaling of color-bitmap fonts when setting up the font-unit scale factor. r=gfx-reviewers,lsalzman

This fixes the problem of color-bitmap Noto Color Emoji getting incorrect
glyph advances in vertical mode. Without the scaling correction here, we
end up with a constant glyph advance regardless of the font size, just
based on the "natural" size of the bitmap glyphs rather than the size
we're actually scaling them to.

Differential Revision: https://phabricator.services.mozilla.com/D248080
This commit is contained in:
Jonathan Kew
2025-05-08 17:42:11 +00:00
committed by jkew@mozilla.com
parent 601f1106cf
commit 9fbffc4e67

View File

@@ -351,9 +351,10 @@ void gfxFT2FontBase::InitMetrics() {
// we can get units_per_EM from the 'head' table instead; otherwise,
// we don't have a unitsPerEm value so we can't compute/use yScale or
// mFUnitsConvFactor (x scale).
const TT_Header* head =
static_cast<TT_Header*>(FT_Get_Sfnt_Table(face, ft_sfnt_head));
if (head) {
if (const TT_Header* head =
static_cast<TT_Header*>(FT_Get_Sfnt_Table(face, ft_sfnt_head))) {
gfxFloat emUnit = head->Units_Per_EM;
mFUnitsConvFactor = ftMetrics.x_ppem / emUnit;
// Bug 1267909 - Even if the font is not explicitly scalable,
// if the face has color bitmaps, it should be treated as scalable
// and scaled to the desired size. Metrics based on y_ppem need
@@ -366,9 +367,8 @@ void gfxFT2FontBase::InitMetrics() {
mMetrics.maxDescent *= adjustScale;
mMetrics.maxAdvance *= adjustScale;
lineHeight *= adjustScale;
mFUnitsConvFactor *= adjustScale;
}
gfxFloat emUnit = head->Units_Per_EM;
mFUnitsConvFactor = ftMetrics.x_ppem / emUnit;
yScale = emHeight / emUnit;
}
}