Title: [188168] trunk/Source/WebCore
Revision
188168
Author
mmaxfi...@apple.com
Date
2015-08-07 14:55:17 -0700 (Fri, 07 Aug 2015)

Log Message

Post-review comments on r188146
https://bugs.webkit.org/show_bug.cgi?id=147793

Reviewed by Daniel Bates.

No new tests because there is no behavior change.

* platform/graphics/FontCache.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::appendTrueTypeFeature):
(WebCore::appendOpenTypeFeature):
(WebCore::applyFontFeatureSettings):
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::FontCache::getSystemFontFallbackForCharacters):
(WebCore::FontCache::createFontPlatformData):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::fontWithFamily):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::updateCachedSystemFontDescription):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (188167 => 188168)


--- trunk/Source/WebCore/ChangeLog	2015-08-07 21:49:42 UTC (rev 188167)
+++ trunk/Source/WebCore/ChangeLog	2015-08-07 21:55:17 UTC (rev 188168)
@@ -1,5 +1,30 @@
 2015-08-07  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        Post-review comments on r188146
+        https://bugs.webkit.org/show_bug.cgi?id=147793
+
+        Reviewed by Daniel Bates.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/FontCache.h:
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::appendTrueTypeFeature):
+        (WebCore::appendOpenTypeFeature):
+        (WebCore::applyFontFeatureSettings):
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::FontCache::getSystemFontFallbackForCharacters):
+        (WebCore::FontCache::createFontPlatformData):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::fontWithFamily):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::updateCachedSystemFontDescription):
+
+2015-08-07  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         [Cocoa] Font fallback is not language-sensitive
         https://bugs.webkit.org/show_bug.cgi?id=147390
 

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (188167 => 188168)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2015-08-07 21:49:42 UTC (rev 188167)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2015-08-07 21:55:17 UTC (rev 188168)
@@ -215,7 +215,7 @@
 };
 
 #if PLATFORM(COCOA)
-RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef, const FontFeatureSettings&);
+RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef, const FontFeatureSettings*);
 #endif
 
 #if !PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (188167 => 188168)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-08-07 21:49:42 UTC (rev 188167)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-08-07 21:55:17 UTC (rev 188168)
@@ -28,11 +28,9 @@
 
 namespace WebCore {
 
-static inline void appendTrueTypeFeature(CFMutableArrayRef features, const FontFeature& feature)
+static inline void appendTrueTypeFeature(CFMutableArrayRef, const FontFeature&)
 {
-    // FIXME: We should map OpenType feature strings to the TrueType feature type identifiers listed in <CoreText/SFNTLayoutTypes.h>
-    UNUSED_PARAM(features);
-    UNUSED_PARAM(feature);
+    // FIXME: We should map OpenType feature strings to the TrueType feature type identifiers listed in <CoreText/SFNTLayoutTypes.h>.
 }
 
 static inline void appendOpenTypeFeature(CFMutableArrayRef features, const FontFeature& feature)
@@ -41,9 +39,9 @@
     RetainPtr<CFStringRef> featureKey = feature.tag().string().createCFString();
     int rawFeatureValue = feature.value();
     RetainPtr<CFNumberRef> featureValue = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &rawFeatureValue));
-    CFStringRef featureDictionaryKeys[] = {kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue};
-    CFTypeRef featureDictionaryValues[] = {featureKey.get(), featureValue.get()};
-    RetainPtr<CFDictionaryRef> featureDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)featureDictionaryKeys, featureDictionaryValues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    CFStringRef featureDictionaryKeys[] = { kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue };
+    CFTypeRef featureDictionaryValues[] = { featureKey.get(), featureValue.get() };
+    RetainPtr<CFDictionaryRef> featureDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)featureDictionaryKeys, featureDictionaryValues, WTF_ARRAY_LENGTH(featureDictionaryValues), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
     CFArrayAppendValue(features, featureDictionary.get());
 #else
     UNUSED_PARAM(features);
@@ -51,12 +49,15 @@
 #endif
 }
 
-RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef originalFont, const FontFeatureSettings& features)
+RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef originalFont, const FontFeatureSettings* features)
 {
-    RetainPtr<CFMutableArrayRef> featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &kCFTypeArrayCallBacks));
-    for (size_t i = 0; i < features.size(); ++i) {
-        appendTrueTypeFeature(featureArray.get(), features[i]);
-        appendOpenTypeFeature(featureArray.get(), features[i]);
+    if (!originalFont || !features || !features->size())
+        return originalFont;
+
+    RetainPtr<CFMutableArrayRef> featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features->size(), &kCFTypeArrayCallBacks));
+    for (size_t i = 0; i < features->size(); ++i) {
+        appendTrueTypeFeature(featureArray.get(), features->at(i));
+        appendOpenTypeFeature(featureArray.get(), features->at(i));
     }
     CFArrayRef featureArrayPtr = featureArray.get();
     RetainPtr<CFDictionaryRef> dictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)&kCTFontFeatureSettingsAttribute, (const void**)&featureArrayPtr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));

Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (188167 => 188168)


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-08-07 21:49:42 UTC (rev 188167)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-08-07 21:55:17 UTC (rev 188168)
@@ -91,8 +91,7 @@
     if (!substituteFont)
         return nullptr;
 
-    if (substituteFont && description.featureSettings() && description.featureSettings()->size())
-        substituteFont = applyFontFeatureSettings(substituteFont.get(), *description.featureSettings());
+    substituteFont = applyFontFeatureSettings(substituteFont.get(), description.featureSettings());
 
     CTFontSymbolicTraits originalTraits = CTFontGetSymbolicTraits(ctFont);
     CTFontSymbolicTraits actualTraits = 0;
@@ -701,8 +700,7 @@
     if (!ctFont)
         return nullptr;
 
-    if (ctFont && fontDescription.featureSettings() && fontDescription.featureSettings()->size())
-        ctFont = applyFontFeatureSettings(ctFont.get(), *fontDescription.featureSettings());
+    ctFont = applyFontFeatureSettings(ctFont.get(), fontDescription.featureSettings());
 
     CTFontSymbolicTraits actualTraits = 0;
     if (isFontWeightBold(fontDescription.weight()) || fontDescription.italic())

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (188167 => 188168)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-08-07 21:49:42 UTC (rev 188167)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-08-07 21:55:17 UTC (rev 188168)
@@ -287,10 +287,9 @@
 
     NSString *desiredFamily = family;
     RetainPtr<CTFontRef> foundFont = adoptCF(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size));
+    foundFont = applyFontFeatureSettings(foundFont.get(), featureSettings);
     if (!foundFont)
         return nil;
-    if (featureSettings && featureSettings->size())
-        foundFont = applyFontFeatureSettings(foundFont.get(), *featureSettings);
     font = CFBridgingRelease(CFRetain(foundFont.get()));
     availableFamily = [font familyName];
     chosenWeight = [fontManager weightOfFont:font];
@@ -521,8 +520,7 @@
     const FontPlatformData& platformData = originalFontData->platformData();
     NSFont *nsFont = platformData.nsFont();
     RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), description.locale(), characters, length);
-    if (result && description.featureSettings() && description.featureSettings()->size())
-        result = applyFontFeatureSettings(result.get(), *description.featureSettings());
+    result = applyFontFeatureSettings(result.get(), description.featureSettings());
     if (!result)
         return nullptr;
 

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp (188167 => 188168)


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2015-08-07 21:49:42 UTC (rev 188167)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2015-08-07 21:55:17 UTC (rev 188168)
@@ -41,8 +41,7 @@
     FontWidthVariant widthVariant = fontDescription.widthVariant();
 #if CORETEXT_WEB_FONTS
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
-    if (font && fontDescription.featureSettings() && fontDescription.featureSettings()->size())
-        font = applyFontFeatureSettings(font.get(), *fontDescription.featureSettings());
+    font = applyFontFeatureSettings(font.get(), fontDescription.featureSettings());
     return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant);
 #else
     return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant);

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (188167 => 188168)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2015-08-07 21:49:42 UTC (rev 188167)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2015-08-07 21:55:17 UTC (rev 188168)
@@ -1261,8 +1261,7 @@
 
     ASSERT(fontDescriptor);
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
-    if (font && fontDescription.featureSettings() && fontDescription.featureSettings()->size())
-        font = applyFontFeatureSettings(font.get(), *fontDescription.featureSettings());
+    font = applyFontFeatureSettings(font.get(), fontDescription.featureSettings());
     fontDescription.setIsAbsoluteSize(true);
     fontDescription.setOneFamily(textStyle);
     fontDescription.setSpecifiedSize(CTFontGetSize(font.get()));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to