Changeset 228044 in webkit
- Timestamp:
- Feb 2, 2018 8:22:04 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228043 r228044 1 2018-02-02 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Test fix after r227995 4 https://bugs.webkit.org/show_bug.cgi?id=180951 5 6 Unreviewed. 7 8 Webfonts shouldn't be run through CTFontDescriptorCreateMatchingFontDescriptor(). 9 Also, unify macOS's and iOS's implementation of FontCache::lastResortFallbackFont(). 10 11 Covered by existing tests. 12 13 * platform/graphics/cocoa/FontCacheCoreText.cpp: 14 (WebCore::FontDatabase::collectionForFamily): 15 (WebCore::FontDatabase::fontForPostScriptName): 16 (WebCore::addAttributesForInstalledFonts): 17 (WebCore::addAttributesForWebFonts): 18 (WebCore::installedFontMandatoryAttributes): 19 (WebCore::FontCache::lastResortFallbackFont): 20 (WebCore::addAttributesForUserInstalledFonts): Deleted. 21 (WebCore::mandatoryAttributesForUserInstalledFonts): Deleted. 22 * platform/graphics/cocoa/FontCacheCoreText.h: 23 * platform/graphics/ios/FontCacheIOS.mm: 24 (WebCore::FontCache::lastResortFallbackFont): Deleted. 25 * platform/graphics/mac/FontCacheMac.mm: 26 (WebCore::FontCache::lastResortFallbackFont): Deleted. 27 * platform/graphics/mac/FontCustomPlatformData.cpp: 28 (WebCore::FontCustomPlatformData::fontPlatformData): 29 1 30 2018-02-02 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 31 -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r227995 r228044 892 892 auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 893 893 CFDictionaryAddValue(attributes.get(), kCTFontFamilyNameAttribute, familyNameString.get()); 894 addAttributesFor UserInstalledFonts(attributes.get(), m_allowUserInstalledFonts);894 addAttributesForInstalledFonts(attributes.get(), m_allowUserInstalledFonts); 895 895 auto fontDescriptorToMatch = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get())); 896 RetainPtr<CFSetRef> mandatoryAttributes = mandatoryAttributesForUserInstalledFonts(m_allowUserInstalledFonts);896 RetainPtr<CFSetRef> mandatoryAttributes = installedFontMandatoryAttributes(m_allowUserInstalledFonts); 897 897 if (auto matches = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(fontDescriptorToMatch.get(), mandatoryAttributes.get()))) { 898 898 auto count = CFArrayGetCount(matches.get()); … … 922 922 CFDictionaryAddValue(attributes.get(), kCTFontEnabledAttribute, kCFBooleanTrue); 923 923 CFDictionaryAddValue(attributes.get(), nameAttribute, postScriptNameString.get()); 924 addAttributesFor UserInstalledFonts(attributes.get(), m_allowUserInstalledFonts);924 addAttributesForInstalledFonts(attributes.get(), m_allowUserInstalledFonts); 925 925 auto fontDescriptorToMatch = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get())); 926 RetainPtr<CFSetRef> mandatoryAttributes = mandatoryAttributesForUserInstalledFonts(m_allowUserInstalledFonts);926 RetainPtr<CFSetRef> mandatoryAttributes = installedFontMandatoryAttributes(m_allowUserInstalledFonts); 927 927 auto match = adoptCF(CTFontDescriptorCreateMatchingFontDescriptor(fontDescriptorToMatch.get(), mandatoryAttributes.get())); 928 928 return InstalledFont(match.get()); … … 1414 1414 } 1415 1415 1416 void addAttributesFor UserInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts allowUserInstalledFonts)1416 void addAttributesForInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts allowUserInstalledFonts) 1417 1417 { 1418 1418 #if CAN_DISALLOW_USER_INSTALLED_FONTS … … 1429 1429 } 1430 1430 1431 RetainPtr<CFSetRef> mandatoryAttributesForUserInstalledFonts(AllowUserInstalledFonts allowUserInstalledFonts) 1431 void addAttributesForWebFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts allowUserInstalledFonts) 1432 { 1433 #if CAN_DISALLOW_USER_INSTALLED_FONTS 1434 if (allowUserInstalledFonts == AllowUserInstalledFonts::No) { 1435 CTFontFallbackOption fallbackOption = kCTFontFallbackOptionSystem; 1436 auto fallbackOptionNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &fallbackOption)); 1437 CFDictionaryAddValue(attributes, kCTFontFallbackOptionAttribute, fallbackOptionNumber.get()); 1438 } 1439 #else 1440 UNUSED_PARAM(attributes); 1441 UNUSED_PARAM(allowUserInstalledFonts); 1442 #endif 1443 } 1444 1445 RetainPtr<CFSetRef> installedFontMandatoryAttributes(AllowUserInstalledFonts allowUserInstalledFonts) 1432 1446 { 1433 1447 #if CAN_DISALLOW_USER_INSTALLED_FONTS … … 1442 1456 } 1443 1457 1444 } 1458 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription) 1459 { 1460 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 1461 // the default that the user would get without changing any prefs. 1462 if (RefPtr<Font> font = fontForFamily(fontDescription, AtomicString("Times", AtomicString::ConstructFromLiteral))) 1463 return *font; 1464 1465 // The Times fallback will almost always work, but in the highly unusual case where 1466 // the user doesn't have it, we fall back on Lucida Grande because that's 1467 // guaranteed to be there, according to Nathan Taylor. This is good enough 1468 // to avoid a crash at least. 1469 return *fontForFamily(fontDescription, AtomicString("Lucida Grande", AtomicString::ConstructFromLiteral), nullptr, nullptr, { }, false); 1470 } 1471 1472 } -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
r227776 r228044 57 57 bool requiresCustomFallbackFont(UChar32 character); 58 58 FontSelectionCapabilities capabilitiesForFontDescriptor(CTFontDescriptorRef); 59 void addAttributesForUserInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts); 60 RetainPtr<CFSetRef> mandatoryAttributesForUserInstalledFonts(AllowUserInstalledFonts); 59 void addAttributesForInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts); 60 void addAttributesForWebFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts); 61 RetainPtr<CFSetRef> installedFontMandatoryAttributes(AllowUserInstalledFonts); 61 62 62 63 } -
trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm
r220506 r228044 74 74 return nullptr; 75 75 return getCachedFontPlatformData(description, *family); 76 }77 78 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)79 {80 return *fontForFamily(fontDescription, AtomicString(".PhoneFallback", AtomicString::ConstructFromLiteral));81 76 } 82 77 -
trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
r225087 r228044 127 127 } 128 128 129 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)130 {131 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick132 // the default that the user would get without changing any prefs.133 if (RefPtr<Font> font = fontForFamily(fontDescription, AtomicString("Times", AtomicString::ConstructFromLiteral)))134 return *font;135 136 // The Times fallback will almost always work, but in the highly unusual case where137 // the user doesn't have it, we fall back on Lucida Grande because that's138 // guaranteed to be there, according to Nathan Taylor. This is good enough139 // to avoid a crash at least.140 return *fontForFamily(fontDescription, AtomicString("Lucida Grande", AtomicString::ConstructFromLiteral), nullptr, nullptr, { }, false);141 }142 143 129 #endif // PLATFORM(MAC) 144 130 -
trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
r227776 r228044 39 39 { 40 40 auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 41 addAttributesFor UserInstalledFonts(attributes.get(), fontDescription.shouldAllowUserInstalledFonts());41 addAttributesForWebFonts(attributes.get(), fontDescription.shouldAllowUserInstalledFonts()); 42 42 auto modifiedFontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithAttributes(m_fontDescriptor.get(), attributes.get())); 43 RetainPtr<CFSetRef> mandatoryAttributes = mandatoryAttributesForUserInstalledFonts(fontDescription.shouldAllowUserInstalledFonts()); 44 auto matchingFontDescriptor = adoptCF(CTFontDescriptorCreateMatchingFontDescriptor(modifiedFontDescriptor.get(), mandatoryAttributes.get())); 45 ASSERT(matchingFontDescriptor); 43 ASSERT(modifiedFontDescriptor); 46 44 47 45 int size = fontDescription.computedPixelSize(); 48 46 FontOrientation orientation = fontDescription.orientation(); 49 47 FontWidthVariant widthVariant = fontDescription.widthVariant(); 50 RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m atchingFontDescriptor.get(), size, nullptr));48 RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(modifiedFontDescriptor.get(), size, nullptr)); 51 49 font = preparePlatformFont(font.get(), fontDescription, &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, fontDescription.computedSize()); 52 50 ASSERT(font);
Note: See TracChangeset
for help on using the changeset viewer.