<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[215159] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/215159">215159</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2017-04-08 20:32:21 -0700 (Sat, 08 Apr 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasttextvariationsfontselectionpropertiesexpectedhtml">trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCacheCoreTextcpp">trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextvariationsgxwidthexpectedhtml">trunk/LayoutTests/fast/text/variations/gx-width-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttextvariationsgxwidthhtml">trunk/LayoutTests/fast/text/variations/gx-width.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (215158 => 215159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-04-09 02:51:19 UTC (rev 215158)
+++ trunk/LayoutTests/ChangeLog        2017-04-09 03:32:21 UTC (rev 215159)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-04-08  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Variation Fonts] Width values of GX fonts are not mapped correctly
+        https://bugs.webkit.org/show_bug.cgi?id=170367
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/variations/font-selection-properties-expected.html:
+        * fast/text/variations/gx-width-expected.html: Added.
+        * fast/text/variations/gx-width.html: Added.
+
</ins><span class="cx"> 2017-04-08  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         A synchronous DecodingOptions should be compatible with any asynchronous sizeForDrawing DecodingOptions
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextvariationsfontselectionpropertiesexpectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html (215158 => 215159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html        2017-04-09 02:51:19 UTC (rev 215158)
+++ trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html        2017-04-09 03:32:21 UTC (rev 215159)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="cx"> This test makes sure that the font selection properties affect font variations.
</span><del>-&lt;div style=&quot;font-family: Boxis; font-variation-settings: 'wdth' 5.6666;&quot;&gt;Hello&lt;/div&gt;
</del><ins>+&lt;div style=&quot;font-family: Boxis; font-variation-settings: 'wdth' 3.25;&quot;&gt;Hello&lt;/div&gt;
</ins><span class="cx"> &lt;div style=&quot;font-family: Boxis; font-variation-settings: 'wdth' 100;&quot;&gt;Hello&lt;/div&gt;
</span><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextvariationsgxwidthexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/variations/gx-width-expected.html (0 => 215159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/variations/gx-width-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/variations/gx-width-expected.html        2017-04-09 03:32:21 UTC (rev 215159)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that the default width maps to a value of 1 on a GX-style variation font's 'wdth' axis.
+&lt;div style=&quot;font: 100px 'Skia'; font-variation-settings: 'wdth' 1;&quot;&gt;Hello&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextvariationsgxwidthhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/variations/gx-width.html (0 => 215159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/variations/gx-width.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/variations/gx-width.html        2017-04-09 03:32:21 UTC (rev 215159)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that the default width maps to a value of 1 on a GX-style variation font's 'wdth' axis.
+&lt;div style=&quot;font: 100px 'Skia';&quot;&gt;Hello&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (215158 => 215159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-04-09 02:51:19 UTC (rev 215158)
+++ trunk/Source/WebCore/ChangeLog        2017-04-09 03:32:21 UTC (rev 215159)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-04-08  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Variation Fonts] Width values of GX fonts are not mapped correctly
+        https://bugs.webkit.org/show_bug.cgi?id=170367
+
+        Reviewed by Simon Fraser.
+
+        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.
+
</ins><span class="cx"> 2017-04-08  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream Mac] Revert change of Mac video capture format
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCacheCoreTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (215158 => 215159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp        2017-04-09 02:51:19 UTC (rev 215158)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp        2017-04-09 03:32:21 UTC (rev 215159)
</span><span class="lines">@@ -464,25 +464,36 @@
</span><span class="cx">     return (value + 109.3) / 523.7;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline float denormalizeWidth(float value)
</del><ins>+static inline float denormalizeSlope(float value)
</ins><span class="cx"> {
</span><del>-    if (value &lt; 125)
-        return (value - 100) / 50;
-    return (value - 50) / 150;
</del><ins>+    return value / 300;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline float denormalizeSlope(float value)
</del><ins>+static inline float denormalizeVariationWidth(float value)
</ins><span class="cx"> {
</span><del>-    return value / 300;
</del><ins>+    if (value &lt;= 125)
+        return value / 100;
+    if (value &lt;= 150)
+        return (value + 125) / 200;
+    return (value + 400) / 400;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if !HAS_CORE_TEXT_WIDTH_ATTRIBUTE || ENABLE(VARIATION_FONTS)
</del><ins>+#if ENABLE(VARIATION_FONTS) || !HAS_CORE_TEXT_WIDTH_ATTRIBUTE
+static inline float normalizeVariationWidth(float value)
+{
+    if (value &lt;= 1.25)
+        return value * 100;
+    if (value &lt;= 1.375)
+        return value * 200 - 125;
+    return value * 400 - 400;
+}
+#endif
+
+#if !HAS_CORE_TEXT_WIDTH_ATTRIBUTE
</ins><span class="cx"> static inline float normalizeWidth(float value)
</span><span class="cx"> {
</span><del>-    if (value &lt; 0.5)
-        return value * 50 + 100;
-    return value * 150 + 50;
</del><ins>+    return normalizeVariationWidth(value + 1);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -569,7 +580,7 @@
</span><span class="cx">         float slope = fontSelectionRequest.slope;
</span><span class="cx">         if (needsConversion) {
</span><span class="cx">             weight = denormalizeWeight(weight);
</span><del>-            width = denormalizeWidth(width);
</del><ins>+            width = denormalizeVariationWidth(width);
</ins><span class="cx">             slope = denormalizeSlope(slope);
</span><span class="cx">         }
</span><span class="cx">         applyVariation({{'w', 'g', 'h', 't'}}, weight);
</span><span class="lines">@@ -964,7 +975,7 @@
</span><span class="cx">         if (result.weight)
</span><span class="cx">             result.weight = {{ normalizeWeight(result.weight.value().minimum), normalizeWeight(result.weight.value().maximum) }};
</span><span class="cx">         if (result.width)
</span><del>-            result.width = {{ normalizeWidth(result.width.value().minimum), normalizeWidth(result.width.value().maximum) }};
</del><ins>+            result.width = {{ normalizeVariationWidth(result.width.value().minimum), normalizeVariationWidth(result.width.value().maximum) }};
</ins><span class="cx">         if (result.slope)
</span><span class="cx">             result.slope = {{ normalizeSlope(result.slope.value().minimum), normalizeSlope(result.slope.value().maximum) }};
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>