Changeset 217272 in webkit


Ignore:
Timestamp:
May 23, 2017 12:37:42 AM (7 years ago)
Author:
mmaxfield@apple.com
Message:

Update font-style's implementation in the font selection algorithm
https://bugs.webkit.org/show_bug.cgi?id=169453

Reviewed by Simon Fraser.

Source/WebCore:

Previously, we were treating "font-style: oblique" exactly the same as "font-style: italic".
These values were parsed to the same internal data type. However, variation fonts may have two
distinct axes: 'slnt' and 'ital'. Therefore, we need to keep a bool of state which represents
which of these two axes we should be setting when we apply font variations. We can do this by
making the "font-style" parser a "custom" parser. The implementation of these custom functions
will set both the italic value on the FontDescription as well as this extra bool.

We don't, however, want to treat these values as distinct for the purposese of font selection.
The fact that we treat oblique fonts the same as italic fonts is a feature, not a bug. Therefore,
the font selection algorithm is not made aware of this distinction. This is why we don't want to
package up the bool and FontSelectionValue into a class: font selection only cares about the
FontSelectionValue, so conceptually they shouldn't be joined. (The FontSelectionValue already
exists within a collection of all the things font selection needs to know about.)

Now that there is this extra bit of state on the FontDescription, we can do a little better when
computing the result of getComputedStyle(). Previously, we were always returning "italic" even
when "oblique" was specified. Now, we can return the correct one. However, this extra bit of
state is not kept on the CSSFontFace (because it doesn't need to be), which means we can only
improve the computed style of an element, rather than the cssText of an @font-face rule.

Test: fast/text/font-style-parse.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
(WebCore::fontStyleFromStyle):
(WebCore::fontShorthandValueForSelectionProperties):

  • css/CSSComputedStyleDeclaration.h:
  • css/CSSFontFaceSet.h:
  • css/CSSProperties.json:
  • css/FontFace.cpp:

(WebCore::FontFace::style):

  • css/FontSelectionValueInlines.h:

(WebCore::fontStyleKeyword):

  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::convertFontStyle): Deleted.

  • css/StyleBuilderCustom.h:

(WebCore::StyleBuilderCustom::applyInitialFontStyle):
(WebCore::StyleBuilderCustom::applyInheritFontStyle):
(WebCore::StyleBuilderCustom::applyValueFontStyle):

  • platform/graphics/FontCache.h:

(WebCore::FontDescriptionKey::makeFlagsKey):

  • platform/graphics/FontDescription.cpp:

(WebCore::FontDescription::FontDescription):

  • platform/graphics/FontDescription.h:

(WebCore::FontDescription::shouldUseItalicVariationAxis):
(WebCore::FontDescription::setShouldUseItalicVariationAxis):
(WebCore::FontDescription::operator==):
(WebCore::FontCascadeDescription::initialShouldUseItalicVariationAxis):

  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):

  • platform/graphics/mac/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

LayoutTests:

  • fast/text/font-style-parse-expected.txt:
  • fast/text/font-style-parse.html:
  • platform/mac-elcapitan/fast/text/font-style-parse-expected.txt:
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r217268 r217272  
     12017-05-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Update font-style's implementation in the font selection algorithm
     4        https://bugs.webkit.org/show_bug.cgi?id=169453
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/text/font-style-parse-expected.txt:
     9        * fast/text/font-style-parse.html:
     10        * platform/mac-elcapitan/fast/text/font-style-parse-expected.txt:
     11
    1122017-05-22  Per Arne Vollan  <pvollan@apple.com>
    213
  • trunk/LayoutTests/fast/text/font-style-parse-expected.txt

    r214507 r217272  
    77PASS window.getComputedStyle(document.getElementById('test7')).fontStyle is "normal"
    88PASS window.getComputedStyle(document.getElementById('test8')).fontStyle is "italic"
    9 PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "italic"
     9PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "oblique"
    1010PASS window.getComputedStyle(document.getElementById('test10')).fontStyle is "normal"
    1111PASS window.getComputedStyle(document.getElementById('test11')).fontStyle is "normal"
     
    2020PASS window.getComputedStyle(document.getElementById('test20')).fontStyle is "normal"
    2121PASS window.getComputedStyle(document.getElementById('test21')).fontStyle is "oblique 14deg"
     22PASS window.getComputedStyle(document.getElementById('test22')).fontStyle is "oblique"
    2223PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times"
    2324PASS window.getComputedStyle(document.getElementById('test2')).font is "16px/18px Times"
     
    2829PASS window.getComputedStyle(document.getElementById('test7')).font is "normal normal normal normal 16px/18px Times"
    2930PASS window.getComputedStyle(document.getElementById('test8')).font is "italic normal normal normal 16px/18px Times"
    30 PASS window.getComputedStyle(document.getElementById('test9')).font is "italic normal normal normal 16px/18px Times"
     31PASS window.getComputedStyle(document.getElementById('test9')).font is "oblique normal normal normal 16px/18px Times"
    3132PASS window.getComputedStyle(document.getElementById('test10')).font is "normal normal normal normal 16px/18px Times"
    3233PASS window.getComputedStyle(document.getElementById('test11')).font is "normal normal normal normal 16px/18px Times"
     
    4142PASS window.getComputedStyle(document.getElementById('test20')).font is "normal normal normal normal 16px/18px Times"
    4243PASS window.getComputedStyle(document.getElementById('test21')).font is "48px/49px 'Helvetica Neue'"
     44PASS window.getComputedStyle(document.getElementById('test22')).font is "oblique normal normal normal 16px/18px Times"
    4345PASS document.getElementById('test1').style.font is ""
    4446PASS document.getElementById('test15').style.font is "italic 100 48px/49px 'Helvetica Neue'"
  • trunk/LayoutTests/fast/text/font-style-parse.html

    r214507 r217272  
    2727<div id="test20" style="font: 13deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue';"></div>
    2828<div id="test21" style="font: oblique 14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue';"></div>
     29<div id="test22" style="font-style: oblique 20deg;"></div>
    2930</div>
    3031<script>
     
    3738shouldBeEqualToString("window.getComputedStyle(document.getElementById('test7')).fontStyle", "normal");
    3839shouldBeEqualToString("window.getComputedStyle(document.getElementById('test8')).fontStyle", "italic");
    39 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).fontStyle", "italic");
     40shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).fontStyle", "oblique");
    4041shouldBeEqualToString("window.getComputedStyle(document.getElementById('test10')).fontStyle", "normal");
    4142shouldBeEqualToString("window.getComputedStyle(document.getElementById('test11')).fontStyle", "normal");
     
    5051shouldBeEqualToString("window.getComputedStyle(document.getElementById('test20')).fontStyle", "normal");
    5152shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).fontStyle", "oblique 14deg");
     53shouldBeEqualToString("window.getComputedStyle(document.getElementById('test22')).fontStyle", "oblique");
    5254
    5355shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).font", "normal normal normal normal 16px/18px Times");
     
    5961shouldBeEqualToString("window.getComputedStyle(document.getElementById('test7')).font", "normal normal normal normal 16px/18px Times");
    6062shouldBeEqualToString("window.getComputedStyle(document.getElementById('test8')).font", "italic normal normal normal 16px/18px Times");
    61 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).font", "italic normal normal normal 16px/18px Times");
     63shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).font", "oblique normal normal normal 16px/18px Times");
    6264shouldBeEqualToString("window.getComputedStyle(document.getElementById('test10')).font", "normal normal normal normal 16px/18px Times");
    6365shouldBeEqualToString("window.getComputedStyle(document.getElementById('test11')).font", "normal normal normal normal 16px/18px Times");
     
    7274shouldBeEqualToString("window.getComputedStyle(document.getElementById('test20')).font", "normal normal normal normal 16px/18px Times");
    7375shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).font", "48px/49px 'Helvetica Neue'");
     76shouldBeEqualToString("window.getComputedStyle(document.getElementById('test22')).font", "oblique normal normal normal 16px/18px Times");
    7477
    7578shouldBeEqualToString("document.getElementById('test1').style.font", "");
  • trunk/LayoutTests/platform/mac-elcapitan/fast/text/font-style-parse-expected.txt

    r214552 r217272  
    77PASS window.getComputedStyle(document.getElementById('test7')).fontStyle is "normal"
    88PASS window.getComputedStyle(document.getElementById('test8')).fontStyle is "italic"
    9 PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "italic"
     9PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "oblique"
    1010PASS window.getComputedStyle(document.getElementById('test10')).fontStyle is "normal"
    1111PASS window.getComputedStyle(document.getElementById('test11')).fontStyle is "normal"
     
    2020PASS window.getComputedStyle(document.getElementById('test20')).fontStyle is "normal"
    2121FAIL window.getComputedStyle(document.getElementById('test21')).fontStyle should be oblique 14deg. Was normal.
     22FAIL window.getComputedStyle(document.getElementById('test22')).fontStyle should be oblique. Was normal.
    2223PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times"
    2324FAIL window.getComputedStyle(document.getElementById('test2')).font should be 16px/18px Times. Was normal normal normal normal 16px/18px Times.
     
    2829PASS window.getComputedStyle(document.getElementById('test7')).font is "normal normal normal normal 16px/18px Times"
    2930PASS window.getComputedStyle(document.getElementById('test8')).font is "italic normal normal normal 16px/18px Times"
    30 PASS window.getComputedStyle(document.getElementById('test9')).font is "italic normal normal normal 16px/18px Times"
     31PASS window.getComputedStyle(document.getElementById('test9')).font is "oblique normal normal normal 16px/18px Times"
    3132PASS window.getComputedStyle(document.getElementById('test10')).font is "normal normal normal normal 16px/18px Times"
    3233PASS window.getComputedStyle(document.getElementById('test11')).font is "normal normal normal normal 16px/18px Times"
     
    4142PASS window.getComputedStyle(document.getElementById('test20')).font is "normal normal normal normal 16px/18px Times"
    4243FAIL window.getComputedStyle(document.getElementById('test21')).font should be 48px/49px 'Helvetica Neue'. Was normal normal normal normal 16px/18px Times.
     44FAIL window.getComputedStyle(document.getElementById('test22')).font should be oblique normal normal normal 16px/18px Times. Was normal normal normal normal 16px/18px Times.
    4345PASS document.getElementById('test1').style.font is ""
    4446PASS document.getElementById('test15').style.font is "italic 100 48px/49px 'Helvetica Neue'"
  • trunk/Source/WebCore/ChangeLog

    r217267 r217272  
     12017-05-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Update font-style's implementation in the font selection algorithm
     4        https://bugs.webkit.org/show_bug.cgi?id=169453
     5
     6        Reviewed by Simon Fraser.
     7
     8        Previously, we were treating "font-style: oblique" exactly the same as "font-style: italic".
     9        These values were parsed to the same internal data type. However, variation fonts may have two
     10        distinct axes: 'slnt' and 'ital'. Therefore, we need to keep a bool of state which represents
     11        which of these two axes we should be setting when we apply font variations. We can do this by
     12        making the "font-style" parser a "custom" parser. The implementation of these custom functions
     13        will set both the italic value on the FontDescription as well as this extra bool.
     14
     15        We don't, however, want to treat these values as distinct for the purposese of font selection.
     16        The fact that we treat oblique fonts the same as italic fonts is a feature, not a bug. Therefore,
     17        the font selection algorithm is not made aware of this distinction. This is why we don't want to
     18        package up the bool and FontSelectionValue into a class: font selection only cares about the
     19        FontSelectionValue, so conceptually they shouldn't be joined. (The FontSelectionValue already
     20        exists within a collection of all the things font selection needs to know about.)
     21
     22        Now that there is this extra bit of state on the FontDescription, we can do a little better when
     23        computing the result of getComputedStyle(). Previously, we were always returning "italic" even
     24        when "oblique" was specified. Now, we can return the correct one. However, this extra bit of
     25        state is not kept on the CSSFontFace (because it doesn't need to be), which means we can only
     26        improve the computed style of an element, rather than the cssText of an @font-face rule.
     27
     28        Test: fast/text/font-style-parse.html
     29
     30        * css/CSSComputedStyleDeclaration.cpp:
     31        (WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
     32        (WebCore::fontStyleFromStyle):
     33        (WebCore::fontShorthandValueForSelectionProperties):
     34        * css/CSSComputedStyleDeclaration.h:
     35        * css/CSSFontFaceSet.h:
     36        * css/CSSProperties.json:
     37        * css/FontFace.cpp:
     38        (WebCore::FontFace::style):
     39        * css/FontSelectionValueInlines.h:
     40        (WebCore::fontStyleKeyword):
     41        * css/StyleBuilderConverter.h:
     42        (WebCore::StyleBuilderConverter::convertFontStyle): Deleted.
     43        * css/StyleBuilderCustom.h:
     44        (WebCore::StyleBuilderCustom::applyInitialFontStyle):
     45        (WebCore::StyleBuilderCustom::applyInheritFontStyle):
     46        (WebCore::StyleBuilderCustom::applyValueFontStyle):
     47        * platform/graphics/FontCache.h:
     48        (WebCore::FontDescriptionKey::makeFlagsKey):
     49        * platform/graphics/FontDescription.cpp:
     50        (WebCore::FontDescription::FontDescription):
     51        * platform/graphics/FontDescription.h:
     52        (WebCore::FontDescription::shouldUseItalicVariationAxis):
     53        (WebCore::FontDescription::setShouldUseItalicVariationAxis):
     54        (WebCore::FontDescription::operator==):
     55        (WebCore::FontCascadeDescription::initialShouldUseItalicVariationAxis):
     56        * platform/graphics/cocoa/FontCacheCoreText.cpp:
     57        (WebCore::preparePlatformFont):
     58        (WebCore::fontWithFamily):
     59        (WebCore::FontCache::createFontPlatformData):
     60        (WebCore::FontCache::systemFallbackForCharacters):
     61        * platform/graphics/mac/FontCustomPlatformData.cpp:
     62        (WebCore::FontCustomPlatformData::fontPlatformData):
     63
    1642017-05-22  Myles C. Maxfield  <mmaxfield@apple.com>
    265
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r217236 r217272  
    19681968}
    19691969
    1970 Ref<CSSFontStyleValue> ComputedStyleExtractor::fontStyleFromStyleValue(FontSelectionValue italic)
    1971 {
    1972     if (auto keyword = fontStyleKeyword(italic))
     1970Ref<CSSFontStyleValue> ComputedStyleExtractor::fontStyleFromStyleValue(FontSelectionValue italic, FontStyleAxis fontStyleAxis)
     1971{
     1972    if (auto keyword = fontStyleKeyword(italic, fontStyleAxis))
    19731973        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(keyword.value()));
    19741974    return fontNonKeywordStyleFromStyleValue(italic);
     
    19771977static Ref<CSSFontStyleValue> fontStyleFromStyle(const RenderStyle& style)
    19781978{
    1979     return ComputedStyleExtractor::fontStyleFromStyleValue(style.fontDescription().italic());
     1979    return ComputedStyleExtractor::fontStyleFromStyleValue(style.fontDescription().italic(), style.fontDescription().fontStyleAxis());
    19801980}
    19811981
     
    26112611        return CSSFontValue::create();
    26122612
    2613     if (auto italic = fontStyleKeyword(fontDescription.italic()))
     2613    if (auto italic = fontStyleKeyword(fontDescription.italic(), fontDescription.fontStyleAxis()))
    26142614        computedFont->style = CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(italic.value()));
    26152615    else
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h

    r214433 r217272  
    2222
    2323#include "CSSStyleDeclaration.h"
     24#include "FontDescription.h"
    2425#include "RenderStyleConstants.h"
    2526#include "SVGRenderStyleDefs.h"
     
    7273    static Ref<CSSPrimitiveValue> fontStretchFromStyleValue(FontSelectionValue);
    7374    static Ref<CSSFontStyleValue> fontNonKeywordStyleFromStyleValue(FontSelectionValue);
    74     static Ref<CSSFontStyleValue> fontStyleFromStyleValue(FontSelectionValue);
     75    static Ref<CSSFontStyleValue> fontStyleFromStyleValue(FontSelectionValue, FontStyleAxis);
    7576
    7677private:
  • trunk/Source/WebCore/css/CSSFontFaceSet.h

    r214359 r217272  
    5252    }
    5353    ~CSSFontFaceSet();
    54 
    55     static FontSelectionValue convertFontWeightFromValue(const CSSValue&);
    56     static FontSelectionValue convertFontStretchFromValue(const CSSValue&);
    57     static FontSelectionValue convertFontStyleFromValue(const CSSValue&);
    5854
    5955    void addClient(CSSFontFaceSetClient&);
  • trunk/Source/WebCore/css/CSSProperties.json

    r217236 r217272  
    308308            ],
    309309            "codegen-properties": {
    310                 "name-for-methods": "Italic",
     310                "custom": "All",
    311311                "font-property": true,
    312                 "high-priority": true,
    313                 "converter": "FontStyle"
     312                "high-priority": true
    314313            },
    315314            "specification": {
  • trunk/Source/WebCore/css/FontFace.cpp

    r216079 r217272  
    290290    auto style = m_backing->italic();
    291291
    292     auto minimum = ComputedStyleExtractor::fontStyleFromStyleValue(style.minimum);
    293     auto maximum = ComputedStyleExtractor::fontStyleFromStyleValue(style.maximum);
     292    auto minimum = ComputedStyleExtractor::fontStyleFromStyleValue(style.minimum, FontStyleAxis::ital);
     293    auto maximum = ComputedStyleExtractor::fontStyleFromStyleValue(style.maximum, FontStyleAxis::ital);
    294294
    295295    if (minimum.get().equals(maximum.get()))
  • trunk/Source/WebCore/css/FontSelectionValueInlines.h

    r213464 r217272  
    122122}
    123123
    124 inline std::optional<CSSValueID> fontStyleKeyword(FontSelectionValue style)
     124inline std::optional<CSSValueID> fontStyleKeyword(FontSelectionValue style, FontStyleAxis axis)
    125125{
    126126    if (style == normalItalicValue())
    127127        return CSSValueNormal;
    128128    if (style == italicValue())
    129         return CSSValueItalic;
     129        return axis == FontStyleAxis::ital ? CSSValueItalic : CSSValueOblique;
    130130    return std::nullopt;
    131131}
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r214564 r217272  
    12391239}
    12401240
    1241 inline FontSelectionValue StyleBuilderConverter::convertFontStyle(StyleResolver&, const CSSValue& value)
    1242 {
    1243     return convertFontStyleFromValue(value);
    1244 }
    1245 
    12461241#if ENABLE(VARIATION_FONTS)
    12471242inline FontVariationSettings StyleBuilderConverter::convertFontVariationSettings(StyleResolver&, const CSSValue& value)
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r215375 r217272  
    8282    DECLARE_PROPERTY_CUSTOM_HANDLERS(FontFamily);
    8383    DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSize);
     84    DECLARE_PROPERTY_CUSTOM_HANDLERS(FontStyle);
    8485#if ENABLE(CSS_IMAGE_RESOLUTION)
    8586    DECLARE_PROPERTY_CUSTOM_HANDLERS(ImageResolution);
     
    15831584}
    15841585
     1586inline void StyleBuilderCustom::applyInitialFontStyle(StyleResolver& styleResolver)
     1587{
     1588    auto fontDescription = styleResolver.fontDescription();
     1589    fontDescription.setItalic(FontCascadeDescription::initialItalic());
     1590    fontDescription.setFontStyleAxis(FontCascadeDescription::initialFontStyleAxis());
     1591    styleResolver.setFontDescription(fontDescription);
     1592}
     1593
     1594inline void StyleBuilderCustom::applyInheritFontStyle(StyleResolver& styleResolver)
     1595{
     1596    auto fontDescription = styleResolver.fontDescription();
     1597    fontDescription.setItalic(styleResolver.parentFontDescription().italic());
     1598    fontDescription.setFontStyleAxis(styleResolver.parentFontDescription().fontStyleAxis());
     1599    styleResolver.setFontDescription(fontDescription);
     1600}
     1601
     1602inline void StyleBuilderCustom::applyValueFontStyle(StyleResolver& styleResolver, CSSValue& value)
     1603{
     1604    auto& fontStyleValue = downcast<CSSFontStyleValue>(value);
     1605    auto fontDescription = styleResolver.fontDescription();
     1606    fontDescription.setItalic(StyleBuilderConverter::convertFontStyleFromValue(fontStyleValue));
     1607    fontDescription.setFontStyleAxis(fontStyleValue.fontStyleValue->valueID() == CSSValueItalic ? FontStyleAxis::ital : FontStyleAxis::slnt);
     1608    styleResolver.setFontDescription(fontDescription);
     1609}
     1610
    15851611inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver, CSSValue& value)
    15861612{
  • trunk/Source/WebCore/platform/graphics/FontCache.h

    r216944 r217272  
    123123    {
    124124        static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags");
    125         unsigned first = static_cast<unsigned>(description.script()) << 12
     125        unsigned first = static_cast<unsigned>(description.script()) << 13
     126            | static_cast<unsigned>(description.fontStyleAxis() == FontStyleAxis::slnt) << 12
    126127            | static_cast<unsigned>(description.opticalSizing()) << 11
    127128            | static_cast<unsigned>(description.textRenderingMode()) << 9
     
    276277};
    277278
    278 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings&, FontSelectionRequest, const FontVariationSettings&, FontOpticalSizing, float size);
     279RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings&, FontSelectionRequest, const FontVariationSettings&, FontOpticalSizing, float size, FontStyleAxis);
    279280SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
    280281RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest, float size);
  • trunk/Source/WebCore/platform/graphics/FontDescription.cpp

    r214467 r217272  
    7979    , m_variantEastAsianRuby(static_cast<unsigned>(FontVariantEastAsianRuby::Normal))
    8080    , m_opticalSizing(static_cast<unsigned>(FontOpticalSizing::Enabled))
     81    , m_fontStyleAxis(FontCascadeDescription::initialFontStyleAxis() == FontStyleAxis::ital)
    8182{
    8283}
  • trunk/Source/WebCore/platform/graphics/FontDescription.h

    r214364 r217272  
    9797    }
    9898    FontOpticalSizing opticalSizing() const { return static_cast<FontOpticalSizing>(m_opticalSizing); }
     99    FontStyleAxis fontStyleAxis() const { return m_fontStyleAxis ? FontStyleAxis::ital : FontStyleAxis::slnt; }
    99100
    100101    void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
     
    130131    void setVariantEastAsianRuby(FontVariantEastAsianRuby variant) { m_variantEastAsianRuby = static_cast<unsigned>(variant); }
    131132    void setOpticalSizing(FontOpticalSizing sizing) { m_opticalSizing = static_cast<unsigned>(sizing); }
     133    void setFontStyleAxis(FontStyleAxis axis) { m_fontStyleAxis = axis == FontStyleAxis::ital; }
    132134
    133135private:
     
    162164    unsigned m_variantEastAsianRuby : 1; // FontVariantEastAsianRuby
    163165    unsigned m_opticalSizing : 1; // FontOpticalSizing
     166    unsigned m_fontStyleAxis : 1; // Whether "font-style: italic" or "font-style: oblique 20deg" was specified
    164167};
    165168
     
    194197        && m_variantEastAsianWidth == other.m_variantEastAsianWidth
    195198        && m_variantEastAsianRuby == other.m_variantEastAsianRuby
    196         && m_opticalSizing == other.m_opticalSizing;
     199        && m_opticalSizing == other.m_opticalSizing
     200        && m_fontStyleAxis == other.m_fontStyleAxis;
    197201}
    198202
     
    266270    // Initial values for font properties.
    267271    static FontSelectionValue initialItalic() { return normalItalicValue(); }
     272    static FontStyleAxis initialFontStyleAxis() { return FontStyleAxis::slnt; }
    268273    static FontSelectionValue initialWeight() { return normalWeightValue(); }
    269274    static FontSelectionValue initialStretch() { return normalStretchValue(); }
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r216217 r217272  
    498498#endif
    499499
    500 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, FontSelectionRequest fontSelectionRequest, const FontVariationSettings& variations, FontOpticalSizing fontOpticalSizing, float size)
     500RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, FontSelectionRequest fontSelectionRequest, const FontVariationSettings& variations, FontOpticalSizing fontOpticalSizing, float size, FontStyleAxis axis)
    501501{
    502502    bool alwaysAddVariations = false;
     
    511511    UNUSED_PARAM(fontFaceCapabilities);
    512512    UNUSED_PARAM(size);
     513    UNUSED_PARAM(axis);
    513514#endif
    514515
     
    593594        applyVariation({{'w', 'g', 'h', 't'}}, weight);
    594595        applyVariation({{'w', 'd', 't', 'h'}}, width);
    595         applyVariation({{'s', 'l', 'n', 't'}}, slope);
     596        if (axis == FontStyleAxis::ital)
     597            applyVariation({{'i', 't', 'a', 'l'}}, 1);
     598        else
     599            applyVariation({{'s', 'l', 'n', 't'}}, slope);
    596600    }
    597601
     
    11631167}
    11641168
    1165 static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const TextRenderingMode& textRenderingMode, FontSelectionRequest fontSelectionRequest, FontOpticalSizing fontOpticalSizing, float size)
     1169static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const TextRenderingMode& textRenderingMode, FontSelectionRequest fontSelectionRequest, FontOpticalSizing fontOpticalSizing, float size, FontStyleAxis axis)
    11661170{
    11671171    if (family.isEmpty())
     
    11711175    if (!foundFont)
    11721176        foundFont = platformFontLookupWithFamily(family, request, size);
    1173     return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, featureSettings, variantSettings, fontSelectionRequest, variationSettings, fontOpticalSizing, size);
     1177    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, featureSettings, variantSettings, fontSelectionRequest, variationSettings, fontOpticalSizing, size, axis);
    11741178}
    11751179
     
    12101214    float size = fontDescription.computedPixelSize();
    12111215
    1212     auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size);
     1216    auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size, fontDescription.fontStyleAxis());
    12131217
    12141218#if PLATFORM(MAC)
     
    12211225        autoActivateFont(family.string(), size);
    12221226
    1223         font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size);
     1227        font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size, fontDescription.fontStyleAxis());
    12241228    }
    12251229#endif
     
    13091313    const FontPlatformData& platformData = originalFontData->platformData();
    13101314    auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
    1311     result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, { }, description.featureSettings(), description.variantSettings(), description.fontSelectionRequest(), description.variationSettings(), description.opticalSizing(), description.computedSize());
     1315    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, { }, description.featureSettings(), description.variantSettings(), description.fontSelectionRequest(), description.variationSettings(), description.opticalSizing(), description.computedSize(), description.fontStyleAxis());
    13121316    if (!result)
    13131317        return lastResortFallbackFont(description);
  • trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp

    r217241 r217272  
    4141    FontWidthVariant widthVariant = fontDescription.widthVariant();
    4242    RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
    43     font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.fontSelectionRequest(), fontDescription.variationSettings(), fontDescription.opticalSizing(), fontDescription.computedSize());
     43    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.fontSelectionRequest(), fontDescription.variationSettings(), fontDescription.opticalSizing(), fontDescription.computedSize(), fontDescription.fontStyleAxis());
    4444    ASSERT(font);
    4545    return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
  • trunk/Source/WebCore/platform/text/TextFlags.h

    r214364 r217272  
    357357};
    358358
     359// https://www.microsoft.com/typography/otspec/fvar.htm#VAT
     360enum class FontStyleAxis {
     361    slnt,
     362    ital
     363};
     364
    359365}
Note: See TracChangeset for help on using the changeset viewer.