author | Jonathan Kew <jkew@mozilla.com> |
Wed, 25 Apr 2018 14:03:44 +0100 | |
changeset 415633 | 2e9eda40f4770cc1fd2a2aa2263c1020445ef636 |
parent 415632 | ee068c7ae8f44f55c0d0cd004cba77b2c402a2db |
child 415634 | dead5fc07a1c7234e6876e43d555ce9185f6ba1c |
push id | 33901 |
push user | apavel@mozilla.com |
push date | Thu, 26 Apr 2018 06:05:37 +0000 |
treeherder | mozilla-central@b62ad926cf2a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jwatt |
bugs | 1454598 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -1061,16 +1061,20 @@ bool gfxFontconfigFontEntry::HasVariations() { if (mHasVariationsInitialized) { return mHasVariations; } mHasVariationsInitialized = true; mHasVariations = false; + if (!gfxPlatform::GetPlatform()->HasVariationFontSupport()) { + return mHasVariations; + } + // For installed fonts, query the fontconfig pattern rather than paying // the cost of loading a FT_Face that we otherwise might never need. if (!IsUserFont() || IsLocalUserFont()) { FcBool variable; if ((FcPatternGetBool(mFontPattern, FC_VARIABLE, 0, &variable) == FcResultMatch) && variable) { mHasVariations = true; } @@ -1203,17 +1207,20 @@ gfxFontconfigFontFamily::FindStyleVariat // figure out the psname/fullname and choose which to use as the facename nsAutoString psname, fullname; GetFaceNames(face, mName, psname, fullname); const nsAutoString& faceName = !psname.IsEmpty() ? psname : fullname; gfxFontconfigFontEntry *fontEntry = new gfxFontconfigFontEntry(faceName, face, mContainsAppFonts); - fontEntry->SetupVariationRanges(); + + if (gfxPlatform::GetPlatform()->HasVariationFontSupport()) { + fontEntry->SetupVariationRanges(); + } AddFontEntry(fontEntry); if (fontEntry->IsNormalStyle()) { numRegularFaces++; } if (LOG_FONTLIST_ENABLED()) {
--- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -1030,17 +1030,18 @@ gfxFontEntry::GetColorLayersInfo(uint32_ aDefaultColor, aLayerGlyphs, aLayerColors); } void gfxFontEntry::SetupVariationRanges() { - if (!HasVariations() || IsUserFont()) { + if (!gfxPlatform::GetPlatform()->HasVariationFontSupport() || + !HasVariations() || IsUserFont()) { return; } AutoTArray<gfxFontVariationAxis,4> axes; GetVariationAxes(axes); for (const auto& axis : axes) { switch (axis.mTag) { case HB_TAG('w','g','h','t'): // If the axis range looks like it doesn't fit the CSS font-weight @@ -1092,16 +1093,20 @@ gfxFontEntry::SetupVariationRanges() } } } void gfxFontEntry::GetVariationsForStyle(nsTArray<gfxFontVariation>& aResult, const gfxFontStyle& aStyle) { + if (!gfxPlatform::GetPlatform()->HasVariationFontSupport()) { + return; + } + // Resolve high-level CSS properties from the requested style // (font-{style,weight,stretch}) to the appropriate variations. float clampedWeight = Weight().Clamp(aStyle.weight).ToFloat(); aResult.AppendElement(gfxFontVariation{HB_TAG('w','g','h','t'), clampedWeight}); float clampedStretch = Stretch().Clamp(aStyle.stretch).Percentage(); aResult.AppendElement(gfxFontVariation{HB_TAG('w','d','t','h'),
--- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -283,17 +283,19 @@ MacOSFontEntry::CreateFontInstance(const return new gfxMacFont(unscaledFont, this, aFontStyle, aNeedsBold); } bool MacOSFontEntry::HasVariations() { if (!mHasVariationsInitialized) { mHasVariationsInitialized = true; - mHasVariations = HasFontTable(TRUETYPE_TAG('f','v','a','r')); + mHasVariations = + gfxPlatform::GetPlatform()->HasVariationFontSupport() && + HasFontTable(TRUETYPE_TAG('f','v','a','r')); } return mHasVariations; } void MacOSFontEntry::GetVariationAxes(nsTArray<gfxFontVariationAxis>& aVariationAxes) { @@ -924,17 +926,19 @@ gfxMacFontFamily::FindStyleVariations(Fo [facename hasSuffix:@"Oblique"]) { fontEntry->mStyleRange = SlantStyleRange(FontSlantStyle::Italic()); } if (macTraits & NSFixedPitchFontMask) { fontEntry->mFixedPitch = true; } - fontEntry->SetupVariationRanges(); + if (gfxPlatform::GetPlatform()->HasVariationFontSupport()) { + fontEntry->SetupVariationRanges(); + } if (LOG_FONTLIST_ENABLED()) { nsAutoCString weightString; fontEntry->Weight().ToString(weightString); nsAutoCString stretchString; fontEntry->Stretch().ToString(stretchString); LOG_FONTLIST(("(fontlist) added (%s) to family (%s)" " with style: %s weight: %s stretch: %s"
--- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -773,16 +773,19 @@ gfxPlatform::Init() gPlatform->PopulateScreenInfo(); gPlatform->ComputeTileSize(); #ifdef MOZ_ENABLE_FREETYPE Factory::SetFTLibrary(gPlatform->GetFTLibrary()); #endif + gPlatform->mHasVariationFontSupport = + gPlatform->CheckVariationFontSupport(); + nsresult rv; rv = gfxPlatformFontList::Init(); if (NS_FAILED(rv)) { MOZ_CRASH("Could not initialize gfxPlatformFontList"); } gPlatform->mScreenReferenceSurface = gPlatform->CreateOffscreenSurface(IntSize(1, 1), @@ -846,17 +849,17 @@ gfxPlatform::Init() #endif InitNullMetadata(); InitOpenGLConfig(); if (XRE_IsParentProcess()) { gfxVars::SetDXInterop2Blocked(IsDXInterop2Blocked()); Preferences::Unlock(FONT_VARIATIONS_PREF); - if (!gPlatform->CheckVariationFontSupport()) { + if (!gPlatform->HasVariationFontSupport()) { // Ensure variation fonts are disabled and the pref is locked. Preferences::SetBool(FONT_VARIATIONS_PREF, false, PrefValueKind::Default); Preferences::SetBool(FONT_VARIATIONS_PREF, false); Preferences::Lock(FONT_VARIATIONS_PREF); } }
--- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -719,16 +719,20 @@ public: * GPUProcessManager, in the UI process. */ virtual void ImportGPUDeviceData(const mozilla::gfx::GPUDeviceData& aData); virtual FT_Library GetFTLibrary() { return nullptr; } + bool HasVariationFontSupport() const { + return mHasVariationFontSupport; + } + // you probably want to use gfxVars::UseWebRender() instead of this static bool WebRenderPrefEnabled(); // you probably want to use gfxVars::UseWebRender() instead of this static bool WebRenderEnvvarEnabled(); protected: gfxPlatform(); virtual ~gfxPlatform(); @@ -809,16 +813,19 @@ protected: int8_t mOpenTypeSVGEnabled; int8_t mBidiNumeralOption; // whether to always search font cmaps globally // when doing system font fallback int8_t mFallbackUsesCmaps; + // Whether the platform supports rendering OpenType font variations + bool mHasVariationFontSupport; + // max character limit for words in word cache int32_t mWordCacheCharLimit; // max number of entries in word cache int32_t mWordCacheMaxEntries; uint64_t mTotalSystemMemory;
--- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -634,13 +634,14 @@ gfxPlatformMac::GetPlatformCMSOutputProf } ::CFRelease(iccp); } bool gfxPlatformMac::CheckVariationFontSupport() { - // We don't allow variation fonts to be enabled before 10.12, + // We don't allow variation fonts to be enabled before 10.13, // as although the Core Text APIs existed, they are known to be // fairly buggy. - return nsCocoaFeatures::OnSierraOrLater(); + // (Note that Safari also requires 10.13 for variation-font support.) + return nsCocoaFeatures::OnHighSierraOrLater(); }