Changeset 215159 in webkit


Ignore:
Timestamp:
Apr 8, 2017 8:32:21 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

[Variation Fonts] Width values of GX fonts are not mapped correctly
https://bugs.webkit.org/show_bug.cgi?id=170367

Reviewed by Simon Fraser.

Source/WebCore:

For some reason, when I performed my calculations for how to map the 'wdth' axis of GX-style
variation fonts, I thought that font-stretch: 100% should map to a variation value of 0.0.
Instead, this should map to 1.0.

Test: fast/text/variations/gx-width.html

  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::denormalizeSlope):
(WebCore::denormalizeVariationWidth):
(WebCore::normalizeVariationWidth):
(WebCore::normalizeWidth):
(WebCore::preparePlatformFont):
(WebCore::variationCapabilitiesForFontDescriptor):
(WebCore::denormalizeWidth): Deleted.

LayoutTests:

  • fast/text/variations/font-selection-properties-expected.html:
  • fast/text/variations/gx-width-expected.html: Added.
  • fast/text/variations/gx-width.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r215157 r215159  
     12017-04-08  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [Variation Fonts] Width values of GX fonts are not mapped correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=170367
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/text/variations/font-selection-properties-expected.html:
     9        * fast/text/variations/gx-width-expected.html: Added.
     10        * fast/text/variations/gx-width.html: Added.
     11
    1122017-04-08  Said Abou-Hallawa  <sabouhallawa@apple.com>
    213
  • trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html

    r214572 r215159  
    1111<body>
    1212This test makes sure that the font selection properties affect font variations.
    13 <div style="font-family: Boxis; font-variation-settings: 'wdth' 5.6666;">Hello</div>
     13<div style="font-family: Boxis; font-variation-settings: 'wdth' 3.25;">Hello</div>
    1414<div style="font-family: Boxis; font-variation-settings: 'wdth' 100;">Hello</div>
    1515</body>
  • trunk/Source/WebCore/ChangeLog

    r215158 r215159  
     12017-04-08  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [Variation Fonts] Width values of GX fonts are not mapped correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=170367
     5
     6        Reviewed by Simon Fraser.
     7
     8        For some reason, when I performed my calculations for how to map the 'wdth' axis of GX-style
     9        variation fonts, I thought that font-stretch: 100% should map to a variation value of 0.0.
     10        Instead, this should map to 1.0.
     11
     12        Test: fast/text/variations/gx-width.html
     13
     14        * platform/graphics/cocoa/FontCacheCoreText.cpp:
     15        (WebCore::denormalizeSlope):
     16        (WebCore::denormalizeVariationWidth):
     17        (WebCore::normalizeVariationWidth):
     18        (WebCore::normalizeWidth):
     19        (WebCore::preparePlatformFont):
     20        (WebCore::variationCapabilitiesForFontDescriptor):
     21        (WebCore::denormalizeWidth): Deleted.
     22
    1232017-04-08  Eric Carlson  <eric.carlson@apple.com>
    224
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r214594 r215159  
    465465}
    466466
    467 static inline float denormalizeWidth(float value)
    468 {
    469     if (value < 125)
    470         return (value - 100) / 50;
    471     return (value - 50) / 150;
    472 }
    473 
    474467static inline float denormalizeSlope(float value)
    475468{
    476469    return value / 300;
    477470}
    478 #endif
    479 
    480 #if !HAS_CORE_TEXT_WIDTH_ATTRIBUTE || ENABLE(VARIATION_FONTS)
     471
     472static inline float denormalizeVariationWidth(float value)
     473{
     474    if (value <= 125)
     475        return value / 100;
     476    if (value <= 150)
     477        return (value + 125) / 200;
     478    return (value + 400) / 400;
     479}
     480#endif
     481
     482#if ENABLE(VARIATION_FONTS) || !HAS_CORE_TEXT_WIDTH_ATTRIBUTE
     483static inline float normalizeVariationWidth(float value)
     484{
     485    if (value <= 1.25)
     486        return value * 100;
     487    if (value <= 1.375)
     488        return value * 200 - 125;
     489    return value * 400 - 400;
     490}
     491#endif
     492
     493#if !HAS_CORE_TEXT_WIDTH_ATTRIBUTE
    481494static inline float normalizeWidth(float value)
    482495{
    483     if (value < 0.5)
    484         return value * 50 + 100;
    485     return value * 150 + 50;
     496    return normalizeVariationWidth(value + 1);
    486497}
    487498#endif
     
    570581        if (needsConversion) {
    571582            weight = denormalizeWeight(weight);
    572             width = denormalizeWidth(width);
     583            width = denormalizeVariationWidth(width);
    573584            slope = denormalizeSlope(slope);
    574585        }
     
    965976            result.weight = {{ normalizeWeight(result.weight.value().minimum), normalizeWeight(result.weight.value().maximum) }};
    966977        if (result.width)
    967             result.width = {{ normalizeWidth(result.width.value().minimum), normalizeWidth(result.width.value().maximum) }};
     978            result.width = {{ normalizeVariationWidth(result.width.value().minimum), normalizeVariationWidth(result.width.value().maximum) }};
    968979        if (result.slope)
    969980            result.slope = {{ normalizeSlope(result.slope.value().minimum), normalizeSlope(result.slope.value().maximum) }};
Note: See TracChangeset for help on using the changeset viewer.