<!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>[188167] 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/188167">188167</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2015-08-07 14:49:42 -0700 (Fri, 07 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore:
[Cocoa] Font fallback is not language-sensitive
https://bugs.webkit.org/show_bug.cgi?id=147390

Reviewed by Dean Jackson.

We need to make our font fallback code sensitive to locale.

This patch rolls <a href="http://trac.webkit.org/projects/webkit/changeset/187729">r187729</a> back in. However, only particular versions of iOS and OS X are
performant enough to enable this language-sensitivity.

This patch also applies to iOS.

Test: fast/text/fallback-language-han.html

* platform/graphics/mac/FontCacheMac.mm:
(WebCore::lookupCTFont):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/mac/FontCacheIOS.mm:
(WebCore::FontCache::systemFallbackForCharacters):

LayoutTests:
[OS X] Font fallback is not language-sensitive
https://bugs.webkit.org/show_bug.cgi?id=147390

Reviewed by Dean Jackson.

This test is expected to fail most places.

* fast/text/fallback-language-han-expected.html: Added.
* fast/text/fallback-language-han.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/win/TestExpectations:
* platform/mac/TestExpectations:
* platform/iOS/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformeflTestExpectations">trunk/LayoutTests/platform/efl/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsiosFontCacheIOSmm">trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm">trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextfallbacklanguagehanexpectedhtml">trunk/LayoutTests/fast/text/fallback-language-han-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttextfallbacklanguagehanhtml">trunk/LayoutTests/fast/text/fallback-language-han.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/ChangeLog        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-08-07  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [OS X] Font fallback is not language-sensitive
+        https://bugs.webkit.org/show_bug.cgi?id=147390
+
+        Reviewed by Dean Jackson.
+
+        This test is expected to fail most places.
+
+        * fast/text/fallback-language-han-expected.html: Added.
+        * fast/text/fallback-language-han.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/win/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/iOS/TestExpectations:
+
</ins><span class="cx"> 2015-08-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move platform/mac/fast/scrolling/ tests into fast/scrolling/latching/
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextfallbacklanguagehanexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/fallback-language-han-expected.html (0 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/fallback-language-han-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/fallback-language-han-expected.html        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that the &quot;lang&quot; attribute is properly consulted when using fallback fonts. The first character
+is shown with a lang which represents Simplified Chinese, and the second character is shown with a lang which
+represents Traditional Chinese. The character is one which is drawn differently in the two languages, so the
+two characters should look different. This tests against a hardcoded font selection which should be the result of
+FontCache::systemFallbackForCharacters().
+&lt;div style=&quot;font: 200px Times;&quot;&gt;
+&lt;span lang=&quot;zh-Hans&quot; style=&quot;font-family: STSongti-SC-Regular;&quot;&gt;&amp;#x9ad4;&lt;/span&gt;
+&lt;span lang=&quot;zh-Hant&quot; style=&quot;font-family: STSongti-TC-Regular;&quot;&gt;&amp;#x9ad4;&lt;/span&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextfallbacklanguagehanhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/fallback-language-han.html (0 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/fallback-language-han.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/fallback-language-han.html        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that the &quot;lang&quot; attribute is properly consulted when using fallback fonts. The first character
+is shown with a lang which represents Simplified Chinese, and the second character is shown with a lang which
+represents Traditional Chinese. The character is one which is drawn differently in the two languages, so the
+two characters should look different. This tests against a hardcoded font selection which should be the result of
+FontCache::systemFallbackForCharacters().
+&lt;div style=&quot;font: 200px Times;&quot;&gt;
+&lt;span lang=&quot;zh-Hans&quot;&gt;&amp;#x9ad4;&lt;/span&gt;
+&lt;span lang=&quot;zh-Hant&quot;&gt;&amp;#x9ad4;&lt;/span&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformeflTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/efl/TestExpectations (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/efl/TestExpectations        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/efl/TestExpectations        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -2250,3 +2250,6 @@
</span><span class="cx"> webkit.org/b/146887 accessibility/table-fallback-roles-expose-element-attributes.html [ Failure ]
</span><span class="cx"> webkit.org/b/146887 accessibility/table-with-footer-section-above-body.html [ Failure ]
</span><span class="cx"> webkit.org/b/146887 accessibility/table-with-missing-aria-role-rows.html [ Failure ]
</span><ins>+
+# This test hardcodes the result of a platform-dependent font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/gtk/TestExpectations        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -2417,3 +2417,6 @@
</span><span class="cx"> # Test requires hardcoded font names, which I do not have for this port.
</span><span class="cx"> fast/text/han-generic-font-families.html [ WontFix ]
</span><span class="cx"> fast/text/hangul-generic-font-families.html [ WontFix ]
</span><ins>+
+# This test hardcodes the result of a platform-dependent font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -2699,3 +2699,6 @@
</span><span class="cx"> # This test depends on location, and it is impossible to mock the particular mechanism
</span><span class="cx"> # this test uses to determine location.
</span><span class="cx"> fast/text/softbank-emoji.html [ Failure Pass ]
</span><ins>+
+# This test hardcodes the result of the Mac font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -1310,3 +1310,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/147763 [ Mavericks ] accessibility/mac/loaded-notification.html [ Skip ]
</span><span class="cx"> webkit.org/b/147763 [ Yosemite ] accessibility/mac/loaded-notification.html [ Skip ]
</span><ins>+
+# Language-specific font fallback is disabled on certain versions of OS X
+webkit.org/b/147390 fast/text/fallback-language-han.html [ Failure ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/TestExpectations        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/win/TestExpectations        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -3146,3 +3146,6 @@
</span><span class="cx"> fast/repaint/block-inputrange-repaint.html [ Pass Failure ]
</span><span class="cx"> 
</span><span class="cx"> fast/inline/padding-ellipsis-right.html [ ImageOnlyFailure ]
</span><ins>+
+# This test hardcodes the result of a platform-dependent font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/Source/WebCore/ChangeLog        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-08-07  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Font fallback is not language-sensitive
+        https://bugs.webkit.org/show_bug.cgi?id=147390
+
+        Reviewed by Dean Jackson.
+
+        We need to make our font fallback code sensitive to locale.
+
+        This patch rolls r187729 back in. However, only particular versions of iOS and OS X are
+        performant enough to enable this language-sensitivity.
+
+        This patch also applies to iOS.
+
+        Test: fast/text/fallback-language-han.html
+
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::lookupCTFont):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/mac/FontCacheIOS.mm:
+        (WebCore::FontCache::systemFallbackForCharacters):
+
</ins><span class="cx"> 2015-08-07  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         RenderTheme::volumeSliderOffsetFromMuteButton should take const&amp; RenderBox.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosFontCacheIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -80,8 +80,14 @@
</span><span class="cx">     const FontPlatformData&amp; platformData = originalFontData-&gt;platformData();
</span><span class="cx">     CTFontRef ctFont = platformData.font();
</span><span class="cx"> 
</span><ins>+    RetainPtr&lt;CFStringRef&gt; localeString;
+#if __IPHONE_OS_VERSION_MIN_REQUIRED &gt; 90000
+    if (!description.locale().isNull())
+        localeString = description.locale().string().createCFString();
+#endif
+
</ins><span class="cx">     CFIndex coveredLength = 0;
</span><del>-    RetainPtr&lt;CTFontRef&gt; substituteFont = adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(ctFont, (const UTF16Char*)characters, (CFIndex)length, 0, &amp;coveredLength));
</del><ins>+    RetainPtr&lt;CTFontRef&gt; substituteFont = adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(ctFont, (const UTF16Char*)characters, (CFIndex)length, localeString.get(), &amp;coveredLength));
</ins><span class="cx">     if (!substituteFont)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (188166 => 188167)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-08-07 21:49:42 UTC (rev 188167)
</span><span class="lines">@@ -484,9 +484,11 @@
</span><span class="cx">         fallbackDedupSet().remove(font);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline RetainPtr&lt;CTFontRef&gt; lookupCTFont(CTFontRef font, float fontSize, const UChar* characters, unsigned length)
</del><ins>+static inline RetainPtr&lt;CTFontRef&gt; lookupCTFont(CTFontRef font, float fontSize, const AtomicString&amp; locale, const UChar* characters, unsigned length)
</ins><span class="cx"> {
</span><ins>+    RetainPtr&lt;CFStringRef&gt; localeString;
</ins><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1090
</span><ins>+    UNUSED_PARAM(locale);
</ins><span class="cx">     if (!font) {
</span><span class="cx">         font = reinterpret_cast&lt;CTFontRef&gt;([NSFont userFontOfSize:fontSize]);
</span><span class="cx">         bool acceptable = true;
</span><span class="lines">@@ -501,18 +503,24 @@
</span><span class="cx">         if (acceptable)
</span><span class="cx">             return font;
</span><span class="cx">     }
</span><ins>+#elif __MAC_OS_X_VERSION_MIN_REQUIRED &gt; 101100
+    UNUSED_PARAM(fontSize);
+    if (!locale.isNull())
+        localeString = locale.string().createCFString();
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(fontSize);
</span><ins>+    UNUSED_PARAM(locale);
</ins><span class="cx"> #endif
</span><ins>+
</ins><span class="cx">     CFIndex coveredLength = 0;
</span><del>-    return adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, nullptr, &amp;coveredLength));
</del><ins>+    return adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString.get(), &amp;coveredLength));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;Font&gt; FontCache::systemFallbackForCharacters(const FontDescription&amp; description, const Font* originalFontData, bool isPlatformFont, const UChar* characters, unsigned length)
</span><span class="cx"> {
</span><span class="cx">     const FontPlatformData&amp; platformData = originalFontData-&gt;platformData();
</span><span class="cx">     NSFont *nsFont = platformData.nsFont();
</span><del>-    RetainPtr&lt;CTFontRef&gt; result = lookupCTFont(platformData.font(), platformData.size(), characters, length);
</del><ins>+    RetainPtr&lt;CTFontRef&gt; result = lookupCTFont(platformData.font(), platformData.size(), description.locale(), characters, length);
</ins><span class="cx">     if (result &amp;&amp; description.featureSettings() &amp;&amp; description.featureSettings()-&gt;size())
</span><span class="cx">         result = applyFontFeatureSettings(result.get(), *description.featureSettings());
</span><span class="cx">     if (!result)
</span></span></pre>
</div>
</div>

</body>
</html>