Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Match only one font name attribute at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Apr 24, 2020
1 parent b905aef commit 307fba5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions platform/darwin/src/local_glyph_rasterizer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,10 @@ CTFontDescriptorRef createFontDescriptor(const FontStack& fontStack) {
for (NSString *name in [fontNames subarrayWithRange:NSMakeRange(1, fontNames.count - 1)]) {
NSDictionary *fontAttributes = @{
(NSString *)kCTFontSizeAttribute: @(util::ONE_EM),
// The name could be any of these three attributes of the font.
// It’s OK if it doesn’t match all three; Core Text will pick
// the font that matches the most attributes.
// This attribute is technically supposed to be a font’s
// PostScript name, but Core Text will fall back to matching
// font display names and font family names.
(NSString *)kCTFontNameAttribute: name,
(NSString *)kCTFontDisplayNameAttribute: name,
(NSString *)kCTFontFamilyNameAttribute: name,
};

CTFontDescriptorRefHandle descriptor(CTFontDescriptorCreateWithAttributes((CFDictionaryRef)fontAttributes));
Expand All @@ -143,12 +141,12 @@ CTFontDescriptorRef createFontDescriptor(const FontStack& fontStack) {

CFStringRef keys[] = {
kCTFontSizeAttribute,
kCTFontNameAttribute, kCTFontDisplayNameAttribute, kCTFontFamilyNameAttribute,
kCTFontNameAttribute,
kCTFontCascadeListAttribute,
};
CFTypeRef values[] = {
(__bridge CFNumberRef)@(util::ONE_EM),
mainFontName, mainFontName, mainFontName,
mainFontName,
*fallbackDescriptors,
};

Expand Down

0 comments on commit 307fba5

Please sign in to comment.