From a78b7458a9e5cfa7d720ad3ef7f2780db124135a Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Mon, 30 Jul 2018 17:53:09 +0100 Subject: [PATCH] Bug 1478720 - Increase the fractional adjustment applied to 'opsz' on macOS to avoid using the font's default setting, which may be mishandled by Core Text. r=lsalzman --- gfx/thebes/gfxMacFont.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 0d7f6cdaa46d..e3c25cf399c9 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -56,11 +56,12 @@ gfxMacFont::gfxMacFont(const RefPtr& aUnscaledFont, // Because of a Core Text bug, we need to ensure that if the font has // an 'opsz' axis, it is always explicitly set, and NOT to the font's - // default value. (See bug 1457417.) + // default value. (See bug 1457417, bug 1478720.) // We record the result of searching the font's axes in the font entry, // so that this only has to be done by the first instance created for // a given font resource. const uint32_t kOpszTag = HB_TAG('o','p','s','z'); + const float kOpszFudgeAmount = 0.01f; if (!aFontEntry->mCheckedForOpszAxis) { aFontEntry->mCheckedForOpszAxis = true; @@ -79,8 +80,8 @@ gfxMacFont::gfxMacFont(const RefPtr& aUnscaledFont, // to explicitly set the default value. aFontEntry->mAdjustedDefaultOpsz = axis.mDefaultValue == axis.mMinValue - ? axis.mDefaultValue + 0.001f - : axis.mDefaultValue - 0.001f; + ? axis.mDefaultValue + kOpszFudgeAmount + : axis.mDefaultValue - kOpszFudgeAmount; } } @@ -97,7 +98,7 @@ gfxMacFont::gfxMacFont(const RefPtr& aUnscaledFont, auto& value = vars[index].mValue; auto& axis = aFontEntry->mOpszAxis; value = fmin(fmax(value, axis.mMinValue), axis.mMaxValue); - if (std::abs(value - axis.mDefaultValue) < 0.001f) { + if (std::abs(value - axis.mDefaultValue) < kOpszFudgeAmount) { value = aFontEntry->mAdjustedDefaultOpsz; } }