Title: [191331] trunk
Revision
191331
Author
mmaxfi...@apple.com
Date
2015-10-19 21:55:27 -0700 (Mon, 19 Oct 2015)

Log Message

FontCascade::typesettingFeatures() is not privy to font-variant-* nor font-feature-settings
https://bugs.webkit.org/show_bug.cgi?id=149775

Reviewed by Darin Adler.

Source/WebCore:

This patch has two pieces:

We used to have a boolean, enableLigatures, which affected how we perform shaping in both our
simple and complex text codepaths. However, in this brave new world of font-feature-settings
and font-variant-*, there are many properties which may affect shaping (and multiple kinds
of ligatures). This patch renames this boolean to requiresShaping, and teaches it about all
the various properties which affect text shaping.

Similarly, one of the places which used this enableLigatures boolean was to tell CoreText
if it should disable ligatures. However, we now have much finer-grained control over
ligatures during font creation. This patch moves the responsibility of dictating which
font features should be enabled entirely to the Font. Therefore, getCFStringAttributes()
doesn't know anything about ligatures anymore; the logic inside font creation is used
instead.

An added benefit of moving all the font feature logic to one place is that we can implement
the feature resolution algorithm described in the CSS3 fonts spec. This patch adds a test to
makes sure that text-rendering, font-feature-settings, and font-variant-* play together
nicely.

Test: fast/text/multiple-feature-properties.html

* platform/graphics/Font.cpp:
(WebCore::Font::applyTransforms):
* platform/graphics/Font.h:
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::FontCascade):
(WebCore::FontCascade::operator=):
(WebCore::FontCascade::update):
(WebCore::FontCascade::drawText):
(WebCore::FontCascade::drawEmphasisMarks):
(WebCore::FontCascade::width):
(WebCore::FontCascade::adjustSelectionRectForText):
(WebCore::FontCascade::offsetForPosition):
(WebCore::FontCascade::codePath):
(WebCore::FontCascade::floatWidthForSimpleText):
* platform/graphics/FontCascade.h:
(WebCore::FontCascade::requiresShaping):
(WebCore::FontCascade::computeRequiresShaping):
(WebCore::FontCascade::enableLigatures): Deleted.
(WebCore::FontCascade::computeEnableLigatures): Deleted.
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::WidthIterator):
(WebCore::WidthIterator::applyFontTransforms):
* platform/graphics/WidthIterator.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::canRenderCombiningCharacterSequence):
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
* platform/graphics/mac/SimpleFontDataCoreText.cpp:
(WebCore::Font::getCFStringAttributes):
* svg/SVGFontData.h:

LayoutTests:

* fast/text/multiple-feature-properties-expected.html: Added.
* fast/text/multiple-feature-properties.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191330 => 191331)


--- trunk/LayoutTests/ChangeLog	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/LayoutTests/ChangeLog	2015-10-20 04:55:27 UTC (rev 191331)
@@ -1,3 +1,13 @@
+2015-10-19  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        FontCascade::typesettingFeatures() is not privy to font-variant-* nor font-feature-settings
+        https://bugs.webkit.org/show_bug.cgi?id=149775
+
+        Reviewed by Darin Adler.
+
+        * fast/text/multiple-feature-properties-expected.html: Added.
+        * fast/text/multiple-feature-properties.html: Added.
+
 2015-10-19  Tim Horton  <timothy_hor...@apple.com>
 
         Don't dump GestureEvent constructor attributes for now

Added: trunk/LayoutTests/fast/text/multiple-feature-properties-expected.html (0 => 191331)


--- trunk/LayoutTests/fast/text/multiple-feature-properties-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/multiple-feature-properties-expected.html	2015-10-20 04:55:27 UTC (rev 191331)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that feature resolution order is honored. For more information, click <a href="" The test passes if there is a particular sequence of Xs and check marks below.
+<div style="font-family: FontWithFeaturesOTF;">
+<span>B</span>
+<span>B</span>
+<span>A</span>
+<span>B</span>
+<span>A</span>
+<span>B</span>
+<span>A</span>
+<span>B</span>
+<span>B</span>
+<span>A</span>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/multiple-feature-properties.html (0 => 191331)


--- trunk/LayoutTests/fast/text/multiple-feature-properties.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/multiple-feature-properties.html	2015-10-20 04:55:27 UTC (rev 191331)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that feature resolution order is honored. For more information, click <a href="" The test passes if there is a particular sequence of Xs and check marks below.
+<div style="font-family: FontWithFeaturesOTF;">
+<span style="font-variant-ligatures: common-ligatures; text-rendering: optimizeSpeed;">C</span>
+<span style="font-variant-ligatures: no-common-ligatures; text-rendering: optimizeSpeed;">C</span>
+<span style="font-variant-ligatures: common-ligatures; text-rendering: optimizeLegibility;">C</span>
+<span style="font-variant-ligatures: no-common-ligatures; text-rendering: optimizeLegibility;">C</span>
+<span style="font-feature-settings: 'liga' 1, 'clig' 1; text-rendering: optimizeSpeed;">C</span>
+<span style="font-feature-settings: 'liga' 0, 'clig' 0; text-rendering: optimizeSpeed;">C</span>
+<span style="font-feature-settings: 'liga' 1, 'clig' 1; text-rendering: optimizeLegibility;">C</span>
+<span style="font-feature-settings: 'liga' 0, 'clig' 0; text-rendering: optimizeLegibility;">C</span>
+<span style="font-variant-ligatures: common-ligatures; font-feature-settings: 'liga' 0, 'clig' 0;">C</span>
+<span style="font-variant-ligatures: no-common-ligatures; font-feature-settings: 'liga' 1, 'clig' 1;">C</span>
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (191330 => 191331)


--- trunk/Source/WebCore/ChangeLog	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/ChangeLog	2015-10-20 04:55:27 UTC (rev 191331)
@@ -1,5 +1,67 @@
 2015-10-19  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        FontCascade::typesettingFeatures() is not privy to font-variant-* nor font-feature-settings
+        https://bugs.webkit.org/show_bug.cgi?id=149775
+
+        Reviewed by Darin Adler.
+
+        This patch has two pieces:
+
+        We used to have a boolean, enableLigatures, which affected how we perform shaping in both our
+        simple and complex text codepaths. However, in this brave new world of font-feature-settings
+        and font-variant-*, there are many properties which may affect shaping (and multiple kinds
+        of ligatures). This patch renames this boolean to requiresShaping, and teaches it about all
+        the various properties which affect text shaping.
+
+        Similarly, one of the places which used this enableLigatures boolean was to tell CoreText
+        if it should disable ligatures. However, we now have much finer-grained control over
+        ligatures during font creation. This patch moves the responsibility of dictating which
+        font features should be enabled entirely to the Font. Therefore, getCFStringAttributes()
+        doesn't know anything about ligatures anymore; the logic inside font creation is used
+        instead.
+
+        An added benefit of moving all the font feature logic to one place is that we can implement
+        the feature resolution algorithm described in the CSS3 fonts spec. This patch adds a test to
+        makes sure that text-rendering, font-feature-settings, and font-variant-* play together
+        nicely.
+
+        Test: fast/text/multiple-feature-properties.html
+
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::applyTransforms):
+        * platform/graphics/Font.h:
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::FontCascade):
+        (WebCore::FontCascade::operator=):
+        (WebCore::FontCascade::update):
+        (WebCore::FontCascade::drawText):
+        (WebCore::FontCascade::drawEmphasisMarks):
+        (WebCore::FontCascade::width):
+        (WebCore::FontCascade::adjustSelectionRectForText):
+        (WebCore::FontCascade::offsetForPosition):
+        (WebCore::FontCascade::codePath):
+        (WebCore::FontCascade::floatWidthForSimpleText):
+        * platform/graphics/FontCascade.h:
+        (WebCore::FontCascade::requiresShaping):
+        (WebCore::FontCascade::computeRequiresShaping):
+        (WebCore::FontCascade::enableLigatures): Deleted.
+        (WebCore::FontCascade::computeEnableLigatures): Deleted.
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::WidthIterator):
+        (WebCore::WidthIterator::applyFontTransforms):
+        * platform/graphics/WidthIterator.h:
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont):
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::Font::canRenderCombiningCharacterSequence):
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+        * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+        (WebCore::Font::getCFStringAttributes):
+        * svg/SVGFontData.h:
+
+2015-10-19  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         Shadow GraphicsContext's ImageInterpolationQuality inside GraphicsContextState
         https://bugs.webkit.org/show_bug.cgi?id=150306
 

Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/Font.cpp	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp	2015-10-20 04:55:27 UTC (rev 191331)
@@ -371,19 +371,19 @@
     return platformCreateScaledFont(fontDescription, scaleFactor);
 }
 
-bool Font::applyTransforms(GlyphBufferGlyph* glyphs, GlyphBufferAdvance* advances, size_t glyphCount, bool enableKerning, bool enableLigatures) const
+bool Font::applyTransforms(GlyphBufferGlyph* glyphs, GlyphBufferAdvance* advances, size_t glyphCount, bool enableKerning, bool requiresShaping) const
 {
     // We need to handle transforms on SVG fonts internally, since they are rendered internally.
     ASSERT(!isSVGFont());
 #if PLATFORM(COCOA)
-    CTFontTransformOptions options = (enableKerning ? kCTFontTransformApplyPositioning : 0) | (enableLigatures ? kCTFontTransformApplyShaping : 0);
+    CTFontTransformOptions options = (enableKerning ? kCTFontTransformApplyPositioning : 0) | (requiresShaping ? kCTFontTransformApplyShaping : 0);
     return CTFontTransformGlyphs(m_platformData.ctFont(), glyphs, reinterpret_cast<CGSize*>(advances), glyphCount, options);
 #else
     UNUSED_PARAM(glyphs);
     UNUSED_PARAM(advances);
     UNUSED_PARAM(glyphCount);
     UNUSED_PARAM(enableKerning);
-    UNUSED_PARAM(enableLigatures);
+    UNUSED_PARAM(requiresShaping);
     return false;
 #endif
 }

Modified: trunk/Source/WebCore/platform/graphics/Font.h (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/Font.h	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/Font.h	2015-10-20 04:55:27 UTC (rev 191331)
@@ -192,7 +192,7 @@
     bool shouldNotBeUsedForArabic() const { return m_shouldNotBeUsedForArabic; };
 #endif
 #if PLATFORM(COCOA)
-    CFDictionaryRef getCFStringAttributes(bool enableKerning, bool enableLigatures, FontOrientation) const;
+    CFDictionaryRef getCFStringAttributes(bool enableKerning, FontOrientation) const;
     bool hasCustomTracking() const { return isSystemFont(); }
 #endif
 
@@ -200,7 +200,7 @@
     bool canRenderCombiningCharacterSequence(const UChar*, size_t) const;
 #endif
 
-    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t glyphCount, bool enableKerning, bool enableLigatures) const;
+    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t glyphCount, bool enableKerning, bool requiresShaping) const;
 
 #if PLATFORM(COCOA) || PLATFORM(WIN)
     bool isSystemFont() const { return m_isSystemFont; }

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2015-10-20 04:55:27 UTC (rev 191331)
@@ -102,7 +102,7 @@
     , m_wordSpacing(0)
     , m_useBackslashAsYenSymbol(false)
     , m_enableKerning(false)
-    , m_enableLigatures(false)
+    , m_requiresShaping(false)
 {
 }
 
@@ -113,7 +113,7 @@
     , m_wordSpacing(wordSpacing)
     , m_useBackslashAsYenSymbol(useBackslashAsYenSignForFamily(fd.firstFamily()))
     , m_enableKerning(computeEnableKerning())
-    , m_enableLigatures(computeEnableKerning())
+    , m_requiresShaping(computeRequiresShaping())
 {
 }
 
@@ -125,7 +125,7 @@
     , m_wordSpacing(0)
     , m_useBackslashAsYenSymbol(false)
     , m_enableKerning(computeEnableKerning())
-    , m_enableLigatures(computeEnableKerning())
+    , m_requiresShaping(computeRequiresShaping())
 {
     m_fontDescription.setFontSmoothing(fontSmoothingMode);
 #if PLATFORM(IOS)
@@ -144,7 +144,7 @@
     , m_wordSpacing(other.m_wordSpacing)
     , m_useBackslashAsYenSymbol(other.m_useBackslashAsYenSymbol)
     , m_enableKerning(computeEnableKerning())
-    , m_enableLigatures(computeEnableKerning())
+    , m_requiresShaping(computeRequiresShaping())
 {
 }
 
@@ -156,7 +156,7 @@
     m_wordSpacing = other.m_wordSpacing;
     m_useBackslashAsYenSymbol = other.m_useBackslashAsYenSymbol;
     m_enableKerning = other.m_enableKerning;
-    m_enableLigatures = other.m_enableLigatures;
+    m_requiresShaping = other.m_requiresShaping;
     return *this;
 }
 
@@ -302,7 +302,7 @@
     m_fonts = retrieveOrAddCachedFonts(m_fontDescription, WTF::move(fontSelector));
     m_useBackslashAsYenSymbol = useBackslashAsYenSignForFamily(firstFamily());
     m_enableKerning = computeEnableKerning();
-    m_enableLigatures = computeEnableLigatures();
+    m_requiresShaping = computeRequiresShaping();
 }
 
 float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, int to, CustomFontNotReadyAction customFontNotReadyAction) const
@@ -317,7 +317,7 @@
 
     CodePath codePathToUse = codePath(run);
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePathToUse != Complex && (enableKerning() || enableLigatures()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
+    if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
         codePathToUse = Complex;
 
     if (codePathToUse != Complex)
@@ -336,7 +336,7 @@
 
     CodePath codePathToUse = codePath(run);
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePathToUse != Complex && (enableKerning() || enableLigatures()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
+    if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
         codePathToUse = Complex;
 
     if (codePathToUse != Complex)
@@ -357,9 +357,8 @@
             glyphOverflow = 0;
     }
 
-    bool hasKerningOrLigatures = enableKerning() || enableLigatures();
     bool hasWordSpacingOrLetterSpacing = wordSpacing() || letterSpacing();
-    float* cacheEntry = m_fonts->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), hasKerningOrLigatures, hasWordSpacingOrLetterSpacing, glyphOverflow);
+    float* cacheEntry = m_fonts->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), enableKerning() || requiresShaping(), hasWordSpacingOrLetterSpacing, glyphOverflow);
     if (cacheEntry && !std::isnan(*cacheEntry))
         return *cacheEntry;
 
@@ -509,7 +508,7 @@
 
     CodePath codePathToUse = codePath(run);
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePathToUse != Complex && (enableKerning() || enableLigatures()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
+    if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
         codePathToUse = Complex;
 
     if (codePathToUse != Complex)
@@ -521,7 +520,7 @@
 int FontCascade::offsetForPosition(const TextRun& run, float x, bool includePartialGlyphs) const
 {
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePath(run) != Complex && (!(enableKerning() || enableLigatures()) || isDrawnWithSVGFont(run)))
+    if (codePath(run) != Complex && (!(enableKerning() || requiresShaping()) || isDrawnWithSVGFont(run)))
         return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
 
     return offsetForPositionForComplexText(run, x, includePartialGlyphs);
@@ -594,12 +593,12 @@
         return Simple;
 #endif
 
-    // FIXME: This shouldn't be necessary because Font::applyTransforms() should perform all necessary shaping.
+    // Because Font::applyTransforms() doesn't know which features to enable/disable it the simple code path can’t properly handle feature or variant settings.
     if (m_fontDescription.featureSettings().size() > 0 || !m_fontDescription.variantSettings().isAllNormal())
         return Complex;
 
 #if !PLATFORM(COCOA)
-    if (run.length() > 1 && (enableKerning() || enableLigatures()))
+    if (run.length() > 1 && (enableKerning() || requiresShaping()))
         return Complex;
 #endif
 
@@ -1421,7 +1420,7 @@
 {
     WidthIterator it(this, run, fallbackFonts, glyphOverflow);
     GlyphBuffer glyphBuffer;
-    it.advance(run.length(), (enableKerning() || enableLigatures()) ? &glyphBuffer : nullptr);
+    it.advance(run.length(), (enableKerning() || requiresShaping()) ? &glyphBuffer : nullptr);
 
     if (glyphOverflow) {
         glyphOverflow->top = std::max<int>(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/FontCascade.h	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h	2015-10-20 04:55:27 UTC (rev 191331)
@@ -158,7 +158,7 @@
     FontRenderingMode renderingMode() const { return m_fontDescription.renderingMode(); }
 
     bool enableKerning() const { return m_enableKerning; }
-    bool enableLigatures() const { return m_enableLigatures; }
+    bool requiresShaping() const { return m_requiresShaping; }
 
     const AtomicString& firstFamily() const { return m_fontDescription.firstFamily(); }
     unsigned familyCount() const { return m_fontDescription.familyCount(); }
@@ -321,13 +321,12 @@
         return advancedTextRenderingMode();
     }
 
-    bool computeEnableLigatures() const
+    bool computeRequiresShaping() const
     {
-        auto ligatures = m_fontDescription.variantCommonLigatures();
-        if (ligatures == FontVariantLigatures::Yes)
+        if (!m_fontDescription.variantSettings().isAllNormal())
             return true;
-        if (ligatures == FontVariantLigatures::No)
-            return false;
+        if (m_fontDescription.featureSettings().size())
+            return true;
         return advancedTextRenderingMode();
     }
 
@@ -338,7 +337,7 @@
     float m_wordSpacing;
     mutable bool m_useBackslashAsYenSymbol;
     mutable unsigned m_enableKerning : 1; // Computed from m_fontDescription.
-    mutable unsigned m_enableLigatures : 1; // Computed from m_fontDescription.
+    mutable unsigned m_requiresShaping : 1; // Computed from m_fontDescription.
 };
 
 void invalidateFontCascadeCache();

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2015-10-20 04:55:27 UTC (rev 191331)
@@ -44,7 +44,7 @@
     , m_fallbackFonts(fallbackFonts)
     , m_accountForGlyphBounds(accountForGlyphBounds)
     , m_enableKerning(font->enableKerning())
-    , m_enableLigatures(font->enableLigatures())
+    , m_requiresShaping(font->requiresShaping())
     , m_forTextEmphasis(forTextEmphasis)
 {
     // If the padding is non-zero, count the number of spaces in the run
@@ -101,7 +101,7 @@
 {
     if (glyphBuffer && glyphBuffer->size() == (lastGlyphCount + 1) && isSoftBankEmoji(previousCharacter))
         return TransformsType::Forced;
-    if (m_run.length() <= 1 || !(m_enableKerning || m_enableLigatures))
+    if (m_run.length() <= 1 || !(m_enableKerning || m_requiresShaping))
         return TransformsType::None;
     return TransformsType::NotForced;
 }
@@ -138,7 +138,7 @@
         }
     } else
 #endif
-        font->applyTransforms(glyphBuffer->glyphs(lastGlyphCount), advances + lastGlyphCount, glyphBufferSize - lastGlyphCount, m_enableKerning, m_enableLigatures);
+        font->applyTransforms(glyphBuffer->glyphs(lastGlyphCount), advances + lastGlyphCount, glyphBufferSize - lastGlyphCount, m_enableKerning, m_requiresShaping);
 
     if (!ltr)
         glyphBuffer->reverse(lastGlyphCount, glyphBufferSize - lastGlyphCount);

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.h	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h	2015-10-20 04:55:27 UTC (rev 191331)
@@ -89,7 +89,7 @@
     HashSet<const Font*>* m_fallbackFonts { nullptr };
     bool m_accountForGlyphBounds { false };
     bool m_enableKerning { false };
-    bool m_enableLigatures { false };
+    bool m_requiresShaping { false };
     bool m_forTextEmphasis { false };
     float m_maxGlyphBoundingBoxY { std::numeric_limits<float>::min() };
     float m_minGlyphBoundingBoxY { std::numeric_limits<float>::max() };

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


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-10-20 04:55:27 UTC (rev 191331)
@@ -321,13 +321,29 @@
 
 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings& features, const FontVariantSettings& variantSettings)
 {
-    if (!originalFont || (!features.size() && (textRenderingMode != OptimizeLegibility) && variantSettings.isAllNormal()))
+    if (!originalFont || (!features.size() && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()))
         return originalFont;
 
-    // FIXME: We don't consult with the @font-face first, like the spec says we should.
+    // This algorithm is described at http://www.w3.org/TR/css3-fonts/#feature-precedence
 
-    // Spec says that font-feature-settings should override font-variant-*.
+    // Step 1: CoreText handles default features (such as required ligatures).
+
+    // Steps 2-3: Consult with @font-face
+    // FIXME: This is not yet implemented.
+
+    // Step 4: Font-variant
     auto fontFeatureSettingsFromVariants = computeFeatureSettingsFromVariants(variantSettings);
+
+    // Step 5: Other properties (text-rendering)
+    if (textRenderingMode == OptimizeSpeed) {
+        fontFeatureSettingsFromVariants.set(fontFeatureTag("liga"), 0);
+        fontFeatureSettingsFromVariants.set(fontFeatureTag("clig"), 0);
+        fontFeatureSettingsFromVariants.set(fontFeatureTag("dlig"), 0);
+        fontFeatureSettingsFromVariants.set(fontFeatureTag("hlig"), 0);
+        fontFeatureSettingsFromVariants.set(fontFeatureTag("calt"), 0);
+    }
+
+    // Step 6: Font-feature-settings
     for (auto& newFeature : features)
         fontFeatureSettingsFromVariants.set(newFeature.tag(), newFeature.value());
 

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


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-10-20 04:55:27 UTC (rev 191331)
@@ -475,7 +475,7 @@
 
     RetainPtr<CFTypeRef> fontEqualityObject = platformData().objectForEqualityCheck();
 
-    ProviderInfo info = { characters, length, getCFStringAttributes(false, false, platformData().orientation()) };
+    ProviderInfo info = { characters, length, getCFStringAttributes(false, platformData().orientation()) };
     RetainPtr<CTLineRef> line = adoptCF(CTLineCreateWithUniCharProvider(&provideStringAndAttributes, 0, &info));
 
     CFArrayRef runArray = CTLineGetGlyphRuns(line.get());

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2015-10-20 04:55:27 UTC (rev 191331)
@@ -217,7 +217,7 @@
 
         RetainPtr<WebCascadeList> cascadeList = adoptNS([[WebCascadeList alloc] initWithFont:&m_font character:baseCharacter]);
 
-        stringAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, font->getCFStringAttributes(m_font.enableKerning(), m_font.enableLigatures(), font->platformData().orientation())));
+        stringAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, font->getCFStringAttributes(m_font.enableKerning(), font->platformData().orientation())));
         static const void* attributeKeys[] = { kCTFontCascadeListAttribute };
         const void* values[] = { cascadeList.get() };
         RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, attributeKeys, values, sizeof(attributeKeys) / sizeof(*attributeKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
@@ -225,7 +225,7 @@
         RetainPtr<CTFontRef> fontWithCascadeList = adoptCF(CTFontCreateCopyWithAttributes(font->platformData().ctFont(), m_font.pixelSize(), 0, fontDescriptor.get()));
         CFDictionarySetValue(const_cast<CFMutableDictionaryRef>(stringAttributes.get()), kCTFontAttributeName, fontWithCascadeList.get());
     } else
-        stringAttributes = font->getCFStringAttributes(m_font.enableKerning(), m_font.enableLigatures(), font->platformData().orientation());
+        stringAttributes = font->getCFStringAttributes(m_font.enableKerning(), font->platformData().orientation());
 
     RetainPtr<CTLineRef> line;
 

Modified: trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp (191330 => 191331)


--- trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp	2015-10-20 04:55:27 UTC (rev 191331)
@@ -35,9 +35,9 @@
 
 namespace WebCore {
 
-CFDictionaryRef Font::getCFStringAttributes(bool enableKerning, bool enableLigatures, FontOrientation orientation) const
+CFDictionaryRef Font::getCFStringAttributes(bool enableKerning, FontOrientation orientation) const
 {
-    unsigned key = (enableKerning << 1 | enableLigatures) + 1;
+    unsigned key = static_cast<unsigned>(enableKerning) + 1;
     HashMap<unsigned, RetainPtr<CFDictionaryRef>>::AddResult addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>());
     RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.iterator->value;
     if (!addResult.isNewEntry)
@@ -54,12 +54,6 @@
         CFDictionarySetValue(mutableAttributes, kCTKernAttributeName, zeroKerningValue);
     }
 
-    if (!enableLigatures) {
-        const int zero = 0;
-        static CFNumberRef essentialLigaturesValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &zero);
-        CFDictionarySetValue(mutableAttributes, kCTLigatureAttributeName, essentialLigaturesValue);
-    }
-
     if (orientation == Vertical)
         CFDictionarySetValue(mutableAttributes, kCTVerticalFormsAttributeName, kCFBooleanTrue);
 

Modified: trunk/Source/WebCore/svg/SVGFontData.h (191330 => 191331)


--- trunk/Source/WebCore/svg/SVGFontData.h	2015-10-20 04:22:59 UTC (rev 191330)
+++ trunk/Source/WebCore/svg/SVGFontData.h	2015-10-20 04:55:27 UTC (rev 191331)
@@ -53,7 +53,7 @@
     bool fillBMPGlyphs(SVGFontElement*, GlyphPage*, UChar* buffer) const;
     bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage*, UChar* buffer) const;
 
-    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t, bool enableKerning, bool enableLigatures) const = delete;
+    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t, bool enableKerning, bool requiresShaping) const = delete;
 
     // Ths SVGFontFaceElement is kept alive --
     // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to