Title: [188591] trunk
Revision
188591
Author
mmaxfi...@apple.com
Date
2015-08-18 12:19:49 -0700 (Tue, 18 Aug 2015)

Log Message

[Cocoa] Honor the 'trak' table by opting in via text-rendering: optimizeLegibility
https://bugs.webkit.org/show_bug.cgi?id=148119
<rdar://problem/22291561>

Reviewed by Tim Horton.

Source/WebCore:

When the author has opted in by specifying "text-rendering: optimizeLegibility;", we should
honor the font's 'trak' table. We do this by specifying kCTFontOpticalSizeAttribute at font
creation time, and by using CTFontGetAdvancesForGlyphs() instead of
CGFontGetGlyphAdvancesForStyle().

Test: fast/text/trak-optimizeLegibility.html

* platform/graphics/FontCache.h:
(WebCore::FontDescriptionKey::makeFlagKey): Make our caches sensitive to TextRenderingMode.
* platform/graphics/FontPlatformData.cpp:
(WebCore::FontPlatformData::FontPlatformData): Add a TextRenderingMode member variable.
(WebCore::FontPlatformData::operator=): Update to consult with the new member.
* platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformData::textRenderingMode): Getter.
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont): Specify kCTFontOpticalSizeAttribute.
(WebCore::applyFontFeatureSettings): Deleted.
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::canUseFastGlyphAdvanceGetter): Use CTFontGetAdvancesForGlyphs() if we are
optimizeLegibility.
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::FontPlatformData): Pass the TextRenderingMode around.
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::FontCache::getSystemFontFallbackForCharacters): Update to call renamed function.
(WebCore::FontCache::createFontPlatformData): Ditto.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::fontWithFamily): Ditto.
(WebCore::FontCache::systemFallbackForCharacters): Ditto.
(WebCore::FontCache::createFontPlatformData): Ditto.
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData): Ditto.
* platform/spi/cocoa/CoreTextSPI.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Ditto.

LayoutTests:

This test will fail until we stop mocking the system font on El Capitan. Until then,
this patch will commit the test failure as an expected result.

* fast/text/trak-optimizeLegibility-expected.html: Added
* fast/text/trak-optimizeLegibility.html: Added

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (188590 => 188591)


--- trunk/LayoutTests/ChangeLog	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/LayoutTests/ChangeLog	2015-08-18 19:19:49 UTC (rev 188591)
@@ -1,3 +1,17 @@
+2015-08-18  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] Honor the 'trak' table by opting in via text-rendering: optimizeLegibility
+        https://bugs.webkit.org/show_bug.cgi?id=148119
+        <rdar://problem/22291561>
+
+        Reviewed by Tim Horton.
+
+        This test will fail until we stop mocking the system font on El Capitan. Until then,
+        this patch will commit the test failure as an expected result.
+
+        * fast/text/trak-optimizeLegibility-expected.html: Added
+        * fast/text/trak-optimizeLegibility.html: Added
+
 2015-08-18  Chris Dumez  <cdu...@apple.com>
 
         Make our bindings' GetOwnPropertySlot() behave according to specification

Added: trunk/LayoutTests/fast/text/trak-optimizeLegibility-expected.txt (0 => 188591)


--- trunk/LayoutTests/fast/text/trak-optimizeLegibility-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/trak-optimizeLegibility-expected.txt	2015-08-18 19:19:49 UTC (rev 188591)
@@ -0,0 +1,12 @@
+PASS first.getClientRects().length is 1
+PASS third.getClientRects().length is 1
+FAIL first.getClientRects()[0].right should be within 4 of 346. Was 364.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This test makes sure that you can opt-in to honoring the 'trak' table by specifying text-rendering: optimizeLegibility. The first and third lines below should have the same width. The middle one can (but doesn't have to) have a different width.
+hamburgefonstiv
+
+hamburgefonstiv
+
+hamburgefonstiv

Added: trunk/LayoutTests/fast/text/trak-optimizeLegibility.html (0 => 188591)


--- trunk/LayoutTests/fast/text/trak-optimizeLegibility.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/trak-optimizeLegibility.html	2015-08-18 19:19:49 UTC (rev 188591)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+This test makes sure that you can opt-in to honoring the 'trak' table by specifying text-rendering: optimizeLegibility.
+The first and third lines below should have the same width. The middle one can (but doesn't have to) have a different width.
+<p><span id="first" style="font: 50px '-apple-system'; font-weight: 300;">hamburgefonstiv</span></p>
+<p><span id="second" style="font: 50px '.SFNSText-Light' '.SFUIDisplay-Light';">hamburgefonstiv</span></p>
+<p><span id="third" style="font: 50px '.SFNSText-Light' '.SFUIDisplay-Light'; text-rendering: optimizeLegibility;">hamburgefonstiv</span></p>
+<script>
+var first = document.getElementById("first");
+var third = document.getElementById("third");
+shouldBe("first.getClientRects().length", "1");
+shouldBe("third.getClientRects().length", "1");
+shouldBeCloseTo("first.getClientRects()[0].right", third.getClientRects()[0].right, 4);
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/platform/ios-simulator/fast/text/trak-optimizeLegibility-expected.txt (0 => 188591)


--- trunk/LayoutTests/platform/ios-simulator/fast/text/trak-optimizeLegibility-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/text/trak-optimizeLegibility-expected.txt	2015-08-18 19:19:49 UTC (rev 188591)
@@ -0,0 +1,12 @@
+PASS first.getClientRects().length is 1
+PASS third.getClientRects().length is 1
+PASS first.getClientRects()[0].right is within 4 of 369
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This test makes sure that you can opt-in to honoring the 'trak' table by specifying text-rendering: optimizeLegibility. The first and third lines below should have the same width. The middle one can (but doesn't have to) have a different width.
+hamburgefonstiv
+
+hamburgefonstiv
+
+hamburgefonstiv

Modified: trunk/LayoutTests/platform/mac/TestExpectations (188590 => 188591)


--- trunk/LayoutTests/platform/mac/TestExpectations	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2015-08-18 19:19:49 UTC (rev 188591)
@@ -1296,3 +1296,6 @@
 
 # Started to fail after r188390
 webkit.org/b/148042 http/tests/media/video-buffered-range-contains-currentTime.html [ Pass Failure ]
+
+# This test tests a particular system font, which is only on iOS and El Capitan.
+webkit.org/b/148119 [ Mavericks Yosemite ] fast/text/trak-optimizeLegibility.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (188590 => 188591)


--- trunk/Source/WebCore/ChangeLog	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/ChangeLog	2015-08-18 19:19:49 UTC (rev 188591)
@@ -1,3 +1,46 @@
+2015-08-18  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] Honor the 'trak' table by opting in via text-rendering: optimizeLegibility
+        https://bugs.webkit.org/show_bug.cgi?id=148119
+        <rdar://problem/22291561>
+
+        Reviewed by Tim Horton.
+
+        When the author has opted in by specifying "text-rendering: optimizeLegibility;", we should
+        honor the font's 'trak' table. We do this by specifying kCTFontOpticalSizeAttribute at font
+        creation time, and by using CTFontGetAdvancesForGlyphs() instead of
+        CGFontGetGlyphAdvancesForStyle().
+
+        Test: fast/text/trak-optimizeLegibility.html
+
+        * platform/graphics/FontCache.h:
+        (WebCore::FontDescriptionKey::makeFlagKey): Make our caches sensitive to TextRenderingMode.
+        * platform/graphics/FontPlatformData.cpp:
+        (WebCore::FontPlatformData::FontPlatformData): Add a TextRenderingMode member variable.
+        (WebCore::FontPlatformData::operator=): Update to consult with the new member.
+        * platform/graphics/FontPlatformData.h:
+        (WebCore::FontPlatformData::textRenderingMode): Getter.
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont): Specify kCTFontOpticalSizeAttribute.
+        (WebCore::applyFontFeatureSettings): Deleted.
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::canUseFastGlyphAdvanceGetter): Use CTFontGetAdvancesForGlyphs() if we are
+        optimizeLegibility.
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::FontPlatformData): Pass the TextRenderingMode around.
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::FontCache::getSystemFontFallbackForCharacters): Update to call renamed function.
+        (WebCore::FontCache::createFontPlatformData): Ditto.
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::fontWithFamily): Ditto.
+        (WebCore::FontCache::systemFallbackForCharacters): Ditto.
+        (WebCore::FontCache::createFontPlatformData): Ditto.
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData): Ditto.
+        * platform/spi/cocoa/CoreTextSPI.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Ditto.
+
 2015-08-18  Chris Dumez  <cdu...@apple.com>
 
         Make our bindings' GetOwnPropertySlot() behave according to specification

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (188590 => 188591)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2015-08-18 19:19:49 UTC (rev 188591)
@@ -105,7 +105,8 @@
     static unsigned makeFlagKey(const FontDescription& description)
     {
         static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags");
-        return static_cast<unsigned>(description.script()) << 9
+        return static_cast<unsigned>(description.script()) << 11
+            | static_cast<unsigned>(description.textRenderingMode()) << 9
             | static_cast<unsigned>(description.smallCaps()) << 8
             | static_cast<unsigned>(description.fontSynthesis()) << 6
             | static_cast<unsigned>(description.widthVariant()) << 4
@@ -215,7 +216,7 @@
 };
 
 #if PLATFORM(COCOA)
-RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef, const FontFeatureSettings*);
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings*);
 #endif
 
 #if !PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp (188590 => 188591)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp	2015-08-18 19:19:49 UTC (rev 188591)
@@ -43,25 +43,26 @@
 {
 }
 
-FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant)
+FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)
     : m_syntheticBold(syntheticBold)
     , m_syntheticOblique(syntheticOblique)
     , m_orientation(orientation)
     , m_size(size)
     , m_widthVariant(widthVariant)
+    , m_textRenderingMode(textRenderingMode)
 {
 }
 
 #if USE(CG)
-FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant)
-    : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant)
+FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)
+    : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode)
 {
     m_cgFont = cgFont;
 }
 #endif
 
 FontPlatformData::FontPlatformData(const FontPlatformData& source)
-    : FontPlatformData(source.m_size, source.m_syntheticBold, source.m_syntheticOblique, source.m_orientation, source.m_widthVariant)
+    : FontPlatformData(source.m_size, source.m_syntheticBold, source.m_syntheticOblique, source.m_orientation, source.m_widthVariant, source.m_textRenderingMode)
 {
     m_isHashTableDeletedValue = source.m_isHashTableDeletedValue;
     m_isColorBitmapFont = source.m_isColorBitmapFont;
@@ -81,6 +82,7 @@
     m_size = other.m_size;
     m_widthVariant = other.m_widthVariant;
     m_isColorBitmapFont = other.m_isColorBitmapFont;
+    m_textRenderingMode = other.m_textRenderingMode;
 
     return platformDataAssign(other);
 }

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (188590 => 188591)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2015-08-18 19:19:49 UTC (rev 188591)
@@ -81,14 +81,14 @@
     FontPlatformData();
     FontPlatformData(const FontPlatformData&);
     FontPlatformData(const FontDescription&, const AtomicString& family);
-    FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
+    FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, TextRenderingMode = AutoTextRendering);
 
 #if PLATFORM(COCOA)
-    WEBCORE_EXPORT FontPlatformData(CTFontRef, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
+    WEBCORE_EXPORT FontPlatformData(CTFontRef, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, TextRenderingMode = AutoTextRendering);
 #endif
 
 #if USE(CG)
-    FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant);
+    FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant, TextRenderingMode);
 #endif
 
 #if PLATFORM(WIN)
@@ -136,6 +136,7 @@
     bool isColorBitmapFont() const { return m_isColorBitmapFont; }
     FontOrientation orientation() const { return m_orientation; }
     FontWidthVariant widthVariant() const { return m_widthVariant; }
+    TextRenderingMode textRenderingMode() const { return m_textRenderingMode; }
     bool isForTextCombine() const { return widthVariant() != RegularWidth; } // Keep in sync with callers of FontDescription::setWidthVariant().
 
     void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
@@ -151,7 +152,7 @@
         return m_font ? m_font->hash() : 0;
 #elif OS(DARWIN)
         ASSERT(m_font || !m_cgFont || isEmoji());
-        uintptr_t flags = static_cast<uintptr_t>(m_isHashTableDeletedValue << 4 | isEmoji() << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique);
+        uintptr_t flags = static_cast<uintptr_t>(m_isHashTableDeletedValue << 6 | m_textRenderingMode << 4 | isEmoji() << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique);
 #if USE(APPKIT)
         uintptr_t fontHash = (uintptr_t)m_font.get();
 #else
@@ -175,7 +176,8 @@
             && m_syntheticOblique == other.m_syntheticOblique
             && m_isColorBitmapFont == other.m_isColorBitmapFont
             && m_orientation == other.m_orientation
-            && m_widthVariant == other.m_widthVariant;
+            && m_widthVariant == other.m_widthVariant
+            && m_textRenderingMode == other.m_textRenderingMode;
     }
 
     bool isHashTableDeletedValue() const
@@ -216,6 +218,7 @@
     FontOrientation m_orientation { Horizontal };
     float m_size { 0 };
     FontWidthVariant m_widthVariant { RegularWidth };
+    TextRenderingMode m_textRenderingMode { AutoTextRendering };
 
 private:
 #if PLATFORM(COCOA)

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


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-08-18 19:19:49 UTC (rev 188591)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "FontCache.h"
 
+#include "CoreTextSPI.h"
 #include <CoreText/SFNTLayoutTypes.h>
 
 #include <wtf/NeverDestroyed.h>
@@ -137,19 +138,26 @@
 #endif
 }
 
-RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef originalFont, const FontFeatureSettings* features)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* features)
 {
-    if (!originalFont || !features || !features->size())
+    if (!originalFont || ((!features || !features->size()) && (textRenderingMode != OptimizeLegibility)))
         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));
+    RetainPtr<CFMutableDictionaryRef> attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    if (features && features->size()) {
+        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));
+        }
+        CFDictionaryAddValue(attributes.get(), kCTFontFeatureSettingsAttribute, featureArray.get());
     }
-    CFArrayRef featureArrayPtr = featureArray.get();
-    RetainPtr<CFDictionaryRef> dictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)&kCTFontFeatureSettingsAttribute, (const void**)&featureArrayPtr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-    RetainPtr<CTFontDescriptorRef> descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(dictionary.get()));
+    if (textRenderingMode == OptimizeLegibility) {
+        CGFloat size = CTFontGetSize(originalFont);
+        RetainPtr<CFNumberRef> sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &size));
+        CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, sizeNumber.get());
+    }
+    RetainPtr<CTFontDescriptorRef> descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
     return adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get()));
 }
 

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (188590 => 188591)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-08-18 19:19:49 UTC (rev 188591)
@@ -457,13 +457,9 @@
 static inline bool canUseFastGlyphAdvanceGetter(const Font& font, Glyph glyph, CGSize& advance, bool& populatedAdvance)
 {
     const FontPlatformData& platformData = font.platformData();
-    // Fast getter doesn't take custom tracking into account
-    if (font.hasCustomTracking())
+    // Fast getter doesn't doesn't work for emoji, bitmap fonts, or take custom tracking into account
+    if (font.hasCustomTracking() || platformData.isEmoji() || platformData.textRenderingMode() == OptimizeLegibility)
         return false;
-    // Fast getter doesn't work for emoji
-    if (platformData.isEmoji())
-        return false;
-    // ... or for any bitmap fonts in general
     if (advanceForColorBitmapFont(platformData, glyph, advance)) {
         populatedAdvance = true;
         return false;

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (188590 => 188591)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2015-08-18 19:19:49 UTC (rev 188591)
@@ -41,8 +41,8 @@
 // These CoreText Text Spacing feature selectors are not defined in CoreText.
 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidth, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };
 
-FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant)
-    : FontPlatformData(adoptCF(CTFontCopyGraphicsFont(font, NULL)).get(), size, syntheticBold, syntheticOblique, orientation, widthVariant)
+FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)
+    : FontPlatformData(adoptCF(CTFontCopyGraphicsFont(font, NULL)).get(), size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode)
 {
     ASSERT_ARG(font, font);
     m_font = font;

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


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-08-18 19:19:49 UTC (rev 188591)
@@ -92,7 +92,7 @@
     if (!substituteFont)
         return nullptr;
 
-    substituteFont = applyFontFeatureSettings(substituteFont.get(), description.featureSettings());
+    substituteFont = preparePlatformFont(substituteFont.get(), description.textRenderingMode(), description.featureSettings());
 
     CTFontSymbolicTraits originalTraits = CTFontGetSymbolicTraits(ctFont);
     CTFontSymbolicTraits actualTraits = 0;
@@ -718,7 +718,7 @@
     if (!ctFont)
         return nullptr;
 
-    ctFont = applyFontFeatureSettings(ctFont.get(), fontDescription.featureSettings());
+    ctFont = preparePlatformFont(ctFont.get(), fontDescription.textRenderingMode(), fontDescription.featureSettings());
 
     CTFontSymbolicTraits actualTraits = 0;
     if (isFontWeightBold(fontDescription.weight()) || fontDescription.italic())
@@ -729,7 +729,7 @@
     bool syntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && (traits & kCTFontTraitBold) && !(actualTraits & kCTFontTraitBold) && !isAppleColorEmoji;
     bool syntheticOblique = (fontDescription.fontSynthesis() & FontSynthesisStyle) && (traits & kCTFontTraitItalic) && !(actualTraits & kCTFontTraitItalic) && !isAppleColorEmoji;
 
-    auto result = std::make_unique<FontPlatformData>(ctFont.get(), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
+    auto result = std::make_unique<FontPlatformData>(ctFont.get(), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.textRenderingMode());
     if (isAppleColorEmoji)
         result->setIsEmoji(true);
     return result;

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


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-08-18 19:19:49 UTC (rev 188591)
@@ -264,7 +264,7 @@
 // Family name is somewhat of a misnomer here. We first attempt to find an exact match
 // comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
 // we then do a search based on the family names of the installed fonts.
-static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, const FontFeatureSettings* featureSettings, float size)
+static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, const FontFeatureSettings* featureSettings, TextRenderingMode textRenderingMode, float size)
 {
     if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, desiredTraits, size))
         return specialCase.value();
@@ -287,7 +287,7 @@
 
     NSString *desiredFamily = family;
     RetainPtr<CTFontRef> foundFont = adoptCF(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size));
-    foundFont = applyFontFeatureSettings(foundFont.get(), featureSettings);
+    foundFont = preparePlatformFont(foundFont.get(), textRenderingMode, featureSettings);
     if (!foundFont)
         return nil;
     font = CFBridgingRelease(CFRetain(foundFont.get()));
@@ -297,6 +297,7 @@
 #else
 
     UNUSED_PARAM(featureSettings);
+    UNUSED_PARAM(textRenderingMode);
 
     NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight >= FontWeight600 ? NSBoldFontMask : 0);
     if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) {
@@ -520,7 +521,7 @@
     const FontPlatformData& platformData = originalFontData->platformData();
     NSFont *nsFont = platformData.nsFont();
     RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), description.locale(), characters, length);
-    result = applyFontFeatureSettings(result.get(), description.featureSettings());
+    result = preparePlatformFont(result.get(), description.textRenderingMode(), description.featureSettings());
     if (!result)
         return nullptr;
 
@@ -679,7 +680,7 @@
     NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
     float size = fontDescription.computedPixelSize();
 
-    NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size);
+    NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.textRenderingMode(), size);
     if (!nsFont) {
         if (!shouldAutoActivateFontIfNeeded(family))
             return nullptr;
@@ -688,7 +689,7 @@
         // Ignore the result because we want to use our own algorithm to actually find the font.
         [NSFont fontWithName:family size:size];
 
-        nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size);
+        nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.textRenderingMode(), size);
         if (!nsFont)
             return nullptr;
     }
@@ -703,7 +704,7 @@
     bool syntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && isAppKitFontWeightBold(toAppKitFontWeight(fontDescription.weight())) && !isAppKitFontWeightBold(actualWeight);
     bool syntheticOblique = (fontDescription.fontSynthesis() & FontSynthesisStyle) && (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
 
-    return std::make_unique<FontPlatformData>(toCTFont(platformFont), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
+    return std::make_unique<FontPlatformData>(toCTFont(platformFont), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.textRenderingMode());
 }
 
 } // namespace WebCore

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


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2015-08-18 19:19:49 UTC (rev 188591)
@@ -41,10 +41,10 @@
     FontWidthVariant widthVariant = fontDescription.widthVariant();
 #if CORETEXT_WEB_FONTS
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
-    font = applyFontFeatureSettings(font.get(), fontDescription.featureSettings());
-    return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant);
+    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), fontDescription.featureSettings());
+    return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
 #else
-    return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant);
+    return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
 #endif
 }
 

Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (188590 => 188591)


--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2015-08-18 19:19:49 UTC (rev 188591)
@@ -49,6 +49,7 @@
 typedef void (*CTUniCharDisposeCallback)(const UniChar* chars, void* refCon);
 
 extern const CFStringRef kCTFontReferenceURLAttribute;
+extern const CFStringRef kCTFontOpticalSizeAttribute;
 
 #if PLATFORM(COCOA)
 #if !USE(APPLE_INTERNAL_SDK)

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (188590 => 188591)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2015-08-18 19:15:44 UTC (rev 188590)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2015-08-18 19:19:49 UTC (rev 188591)
@@ -1261,7 +1261,7 @@
 
     ASSERT(fontDescriptor);
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
-    font = applyFontFeatureSettings(font.get(), fontDescription.featureSettings());
+    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), 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