|
Lines 264-270
static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, F
a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec1
|
| 264 |
// Family name is somewhat of a misnomer here. We first attempt to find an exact match |
264 |
// Family name is somewhat of a misnomer here. We first attempt to find an exact match |
| 265 |
// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails |
265 |
// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails |
| 266 |
// we then do a search based on the family names of the installed fonts. |
266 |
// we then do a search based on the family names of the installed fonts. |
| 267 |
static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, float size) |
267 |
static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, const FontFeatureSettings* featureSettings, float size) |
| 268 |
{ |
268 |
{ |
| 269 |
if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, desiredTraits, size)) |
269 |
if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, desiredTraits, size)) |
| 270 |
return specialCase.value(); |
270 |
return specialCase.value(); |
|
Lines 286-297
static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desire
a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec2
|
| 286 |
requestedTraits |= kCTFontBoldTrait; |
286 |
requestedTraits |= kCTFontBoldTrait; |
| 287 |
|
287 |
|
| 288 |
NSString *desiredFamily = family; |
288 |
NSString *desiredFamily = family; |
| 289 |
font = CFBridgingRelease(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size)); |
289 |
RetainPtr<CTFontRef> foundFont = adoptCF(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size)); |
|
|
290 |
if (!foundFont) |
| 291 |
return nil; |
| 292 |
if (featureSettings && featureSettings->size()) |
| 293 |
foundFont = applyFontFeatureSettings(foundFont.get(), *featureSettings); |
| 294 |
font = CFBridgingRelease(CFRetain(foundFont.get())); |
| 290 |
availableFamily = [font familyName]; |
295 |
availableFamily = [font familyName]; |
| 291 |
chosenWeight = [fontManager weightOfFont:font]; |
296 |
chosenWeight = [fontManager weightOfFont:font]; |
| 292 |
|
297 |
|
| 293 |
#else |
298 |
#else |
| 294 |
|
299 |
|
|
|
300 |
UNUSED_PARAM(featureSettings); |
| 301 |
|
| 295 |
NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight >= FontWeight600 ? NSBoldFontMask : 0); |
302 |
NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight >= FontWeight600 ? NSBoldFontMask : 0); |
| 296 |
if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) { |
303 |
if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) { |
| 297 |
if (!availableFamily) { |
304 |
if (!availableFamily) { |
|
Lines 506-511
RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr
a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec3
|
| 506 |
const FontPlatformData& platformData = originalFontData->platformData(); |
513 |
const FontPlatformData& platformData = originalFontData->platformData(); |
| 507 |
NSFont *nsFont = platformData.nsFont(); |
514 |
NSFont *nsFont = platformData.nsFont(); |
| 508 |
RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length); |
515 |
RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length); |
|
|
516 |
if (result && description.featureSettings() && description.featureSettings()->size()) |
| 517 |
result = applyFontFeatureSettings(result.get(), *description.featureSettings()); |
| 509 |
if (!result) |
518 |
if (!result) |
| 510 |
return nullptr; |
519 |
return nullptr; |
| 511 |
|
520 |
|
|
Lines 664-670
std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe
a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec4
|
| 664 |
NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0; |
673 |
NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0; |
| 665 |
float size = fontDescription.computedPixelSize(); |
674 |
float size = fontDescription.computedPixelSize(); |
| 666 |
|
675 |
|
| 667 |
NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), size); |
676 |
NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size); |
| 668 |
if (!nsFont) { |
677 |
if (!nsFont) { |
| 669 |
if (!shouldAutoActivateFontIfNeeded(family)) |
678 |
if (!shouldAutoActivateFontIfNeeded(family)) |
| 670 |
return nullptr; |
679 |
return nullptr; |
|
Lines 673-679
std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe
a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec5
|
| 673 |
// Ignore the result because we want to use our own algorithm to actually find the font. |
682 |
// Ignore the result because we want to use our own algorithm to actually find the font. |
| 674 |
[NSFont fontWithName:family size:size]; |
683 |
[NSFont fontWithName:family size:size]; |
| 675 |
|
684 |
|
| 676 |
nsFont = fontWithFamily(family, traits, fontDescription.weight(), size); |
685 |
nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size); |
| 677 |
if (!nsFont) |
686 |
if (!nsFont) |
| 678 |
return nullptr; |
687 |
return nullptr; |
| 679 |
} |
688 |
} |