Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 140854d

Browse files
committed
Bug 1690235. Fix creating variation CTFonts. r=lsalzman, a=pascalc
This is an alternate approach to aadbc6deca05. CTFontCreateWithGraphicsFont seems to give "LastResort" when used on a system CGFont with variation applied on 10.12-10.14. We can avoid that by using CTFontCreateWithGraphicsFont with a variation descriptor. I'm only applying this approach to cairo for now to mimimize the risk of this breaking something or causing the crashes that we were seeing before. See servo/core-foundation-rs#439 for a standalone test case. Differential Revision: https://phabricator.services.mozilla.com/D104581
1 parent 0b5c733 commit 140854d

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

gfx/2d/ScaledFontMac.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifdef MOZ_WIDGET_UIKIT
1919
# include <CoreFoundation/CoreFoundation.h>
2020
#endif
21-
#include "gfxPlatform.h" // just for HasVariationFontSupport()
2221
#include "nsCocoaFeatures.h"
2322
#include "mozilla/gfx/Logging.h"
2423

@@ -375,17 +374,6 @@ bool UnscaledFontMac::GetFontDescriptor(FontDescriptorOutput aCb,
375374
return false;
376375
}
377376

378-
// Bug 1690235: using a font descriptor may fail for variation fonts
379-
// on systems prior to 10.15, so we return false in this case.
380-
if (gfxPlatform::GetPlatform()->HasVariationFontSupport() &&
381-
!nsCocoaFeatures::OnCatalinaOrLater()) {
382-
CFDataRef data = CGFontCopyTableForTag(mFont, 0x66766172); // 'fvar'
383-
if (data) {
384-
CFRelease(data);
385-
return false;
386-
}
387-
}
388-
389377
AutoRelease<CFStringRef> psname(CGFontCopyPostScriptName(mFont));
390378
if (!psname) {
391379
return false;

gfx/cairo/cairo/src/cairo-quartz-font.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize)
364364
// XXX Does this need to behave differently for installed fonts on High
365365
// Sierra, as in other similar places (bug 1455569)?
366366

367-
if (!Gecko_OnSierraExactly()) {
367+
CFStringRef name = CGFontCopyPostScriptName(aCGFont);
368+
// CTFontCreateWithGraphicsFont seems to give "LastResort"
369+
// when used on a system CGFont with variation applied
370+
bool system_font = CFStringHasPrefix(name, CFSTR("."));
371+
372+
if (!Gecko_OnSierraExactly() && !system_font) {
368373
return CTFontCreateWithGraphicsFont(aCGFont, aSize, NULL, NULL);
369374
}
370375

0 commit comments

Comments
 (0)