Skip to content

Commit 876de8d

Browse files
committed
Bug 1884909 - Resolve the real family name during CoreTextFontList::InitSystemFontNames, so that font fallback finds it as expected. r=gfx-reviewers,bradwerth
This restores the equivalent behavior of GetRealFamilyName in the old Cocoa-based code that we used prior to bug 1884314. (See https://hg.mozilla.org/mozilla-central/annotate/02aeca6d94b127379287a276a0f0d7958dc4efaa/gfx/thebes/gfxMacPlatformFontList.mm#l415) Dropping this function during the migration from Cocoa to Core Text APIs meant that the macOS system font was recorded under the "virtual" family name .AppleSystemUIFont instead of its "real" name .SF NS. This seemed harmless enough, but not quite... it interferes with finding the system font in CoreTextFontList::PlatformGlobalFontFallback, if that's the font that Core Text chooses to return for a given character. As a result, the bugs/1721223-1.html testcase changed from using the system font to finding and loading a Meetei Mayek font (at least on my system) that also happens to include the subscript-s letter; but that fallback happens asynchronously as this font hasn't yet been initialized, and that broke the test. This restores the prior behavior, by porting the GetRealFamilyName functionality to the Core Text-based implementation. Differential Revision: https://phabricator.services.mozilla.com/D204590
1 parent ff75a43 commit 876de8d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

gfx/thebes/CoreTextFontList.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,11 +1863,26 @@ void CoreTextFontList::ReadFaceNamesForFamily(
18631863
}
18641864
}
18651865

1866+
static CFStringRef CopyRealFamilyName(CTFontRef aFont) {
1867+
AutoCFRelease<CFStringRef> psName = CTFontCopyPostScriptName(aFont);
1868+
AutoCFRelease<CGFontRef> cgFont =
1869+
CGFontCreateWithFontName(CFStringRef(psName));
1870+
if (!cgFont) {
1871+
return CTFontCopyFamilyName(aFont);
1872+
}
1873+
AutoCFRelease<CTFontRef> ctFont =
1874+
CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr);
1875+
if (!ctFont) {
1876+
return CTFontCopyFamilyName(aFont);
1877+
}
1878+
return CTFontCopyFamilyName(ctFont);
1879+
}
1880+
18661881
void CoreTextFontList::InitSystemFontNames() {
18671882
// text font family
18681883
AutoCFRelease<CTFontRef> font = CTFontCreateUIFontForLanguage(
18691884
kCTFontUIFontSystem, 0.0, nullptr); // TODO: language
1870-
AutoCFRelease<CFStringRef> name = CTFontCopyFamilyName(font);
1885+
AutoCFRelease<CFStringRef> name = CopyRealFamilyName(font);
18711886

18721887
nsAutoString familyName;
18731888
GetStringForCFString(name, familyName);

0 commit comments

Comments
 (0)