<!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>[210776] trunk/Source/WebCore</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/210776">210776</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2017-01-15 00:23:31 -0800 (Sun, 15 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] Unify font fallback between macOS and iOS for when the font-family list is exhausted
https://bugs.webkit.org/show_bug.cgi?id=167056

Reviewed by Darin Adler.

When performing font fallback, each item in the font-family list is examined.
If no appropriate fonts are found, WebKit asks the system for an appropriate
font. As of a few years ago, both macOS and iOS used platform calls to
produce a font; however, each platform used a different platform call. This
patch migrates both platforms to use a shared function which uses only
one of the platform calls (which means the other platform call is never used).

There are still some behavior differences between macOS and iOS (which are now
hidden behind a PLATFORM() guard), but I'd like to minimize and eliminate these
in the future. Using a shared function is a step toward this goal.

No new tests because there is no behavior change.

* platform/graphics/FontCache.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::lookupFallbackFont):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::getSystemFontFallbackForCharacters): Deleted.
(WebCore::platformLookupFallbackFont): Deleted.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformLookupFallbackFont): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCacheh">trunk/Source/WebCore/platform/graphics/FontCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCacheCoreTextcpp">trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp</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>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210775 => 210776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-15 07:22:19 UTC (rev 210775)
+++ trunk/Source/WebCore/ChangeLog        2017-01-15 08:23:31 UTC (rev 210776)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-01-15  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Unify font fallback between macOS and iOS for when the font-family list is exhausted
+        https://bugs.webkit.org/show_bug.cgi?id=167056
+
+        Reviewed by Darin Adler.
+
+        When performing font fallback, each item in the font-family list is examined.
+        If no appropriate fonts are found, WebKit asks the system for an appropriate
+        font. As of a few years ago, both macOS and iOS used platform calls to
+        produce a font; however, each platform used a different platform call. This
+        patch migrates both platforms to use a shared function which uses only
+        one of the platform calls (which means the other platform call is never used). 
+
+        There are still some behavior differences between macOS and iOS (which are now
+        hidden behind a PLATFORM() guard), but I'd like to minimize and eliminate these
+        in the future. Using a shared function is a step toward this goal. 
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/FontCache.h:
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::lookupFallbackFont):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::getSystemFontFallbackForCharacters): Deleted.
+        (WebCore::platformLookupFallbackFont): Deleted.
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::platformLookupFallbackFont): Deleted.
+
</ins><span class="cx"> 2017-01-14  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Report CPU usage of tabs after they become non-visible using diagnostic logging
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (210775 => 210776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.h        2017-01-15 07:22:19 UTC (rev 210775)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h        2017-01-15 08:23:31 UTC (rev 210776)
</span><span class="lines">@@ -276,7 +276,6 @@
</span><span class="cx"> SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&amp;, bool isPlatformFont = false);
</span><span class="cx"> RetainPtr&lt;CTFontRef&gt; platformFontWithFamilySpecialCase(const AtomicString&amp; family, FontWeight, CTFontSymbolicTraits, float size);
</span><span class="cx"> RetainPtr&lt;CTFontRef&gt; platformFontWithFamily(const AtomicString&amp; family, CTFontSymbolicTraits, FontWeight, TextRenderingMode, float size);
</span><del>-RetainPtr&lt;CTFontRef&gt; platformLookupFallbackFont(CTFontRef, FontWeight, const AtomicString&amp; locale, const UChar* characters, unsigned length);
</del><span class="cx"> bool requiresCustomFallbackFont(UChar32 character);
</span><span class="cx"> 
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCacheCoreTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (210775 => 210776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp        2017-01-15 07:22:19 UTC (rev 210775)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp        2017-01-15 08:23:31 UTC (rev 210776)
</span><span class="lines">@@ -39,11 +39,11 @@
</span><span class="cx"> 
</span><span class="cx"> static inline void appendRawTrueTypeFeature(CFMutableArrayRef features, int type, int selector)
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;CFNumberRef&gt; typeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &amp;type));
-    RetainPtr&lt;CFNumberRef&gt; selectorNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &amp;selector));
</del><ins>+    auto typeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &amp;type));
+    auto selectorNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &amp;selector));
</ins><span class="cx">     CFTypeRef featureKeys[] = { kCTFontFeatureTypeIdentifierKey, kCTFontFeatureSelectorIdentifierKey };
</span><span class="cx">     CFTypeRef featureValues[] = { typeNumber.get(), selectorNumber.get() };
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; feature = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, featureKeys, featureValues, WTF_ARRAY_LENGTH(featureKeys), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</del><ins>+    auto feature = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, featureKeys, featureValues, WTF_ARRAY_LENGTH(featureKeys), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</ins><span class="cx">     CFArrayAppendValue(features, feature.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -133,12 +133,12 @@
</span><span class="cx"> 
</span><span class="cx"> static inline void appendOpenTypeFeature(CFMutableArrayRef features, const FontFeature&amp; feature)
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;CFStringRef&gt; featureKey = adoptCF(CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast&lt;const UInt8*&gt;(feature.tag().data()), feature.tag().size() * sizeof(FontTag::value_type), kCFStringEncodingASCII, false));
</del><ins>+    auto featureKey = adoptCF(CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast&lt;const UInt8*&gt;(feature.tag().data()), feature.tag().size() * sizeof(FontTag::value_type), kCFStringEncodingASCII, false));
</ins><span class="cx">     int rawFeatureValue = feature.value();
</span><del>-    RetainPtr&lt;CFNumberRef&gt; featureValue = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &amp;rawFeatureValue));
</del><ins>+    auto featureValue = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &amp;rawFeatureValue));
</ins><span class="cx">     CFTypeRef featureDictionaryKeys[] = { kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue };
</span><span class="cx">     CFTypeRef featureDictionaryValues[] = { featureKey.get(), featureValue.get() };
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; featureDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, featureDictionaryKeys, featureDictionaryValues, WTF_ARRAY_LENGTH(featureDictionaryValues), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</del><ins>+    auto featureDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, featureDictionaryKeys, featureDictionaryValues, WTF_ARRAY_LENGTH(featureDictionaryValues), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</ins><span class="cx">     CFArrayAppendValue(features, featureDictionary.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -479,9 +479,9 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;CFMutableDictionaryRef&gt; attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</del><ins>+    auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</ins><span class="cx">     if (!featuresToBeApplied.isEmpty()) {
</span><del>-        RetainPtr&lt;CFMutableArrayRef&gt; featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &amp;kCFTypeArrayCallBacks));
</del><ins>+        auto featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &amp;kCFTypeArrayCallBacks));
</ins><span class="cx">         for (auto&amp; p : featuresToBeApplied) {
</span><span class="cx">             auto feature = FontFeature(p.key, p.value);
</span><span class="cx">             appendTrueTypeFeature(featureArray.get(), feature);
</span><span class="lines">@@ -505,10 +505,10 @@
</span><span class="cx"> 
</span><span class="cx">     if (textRenderingMode == OptimizeLegibility) {
</span><span class="cx">         CGFloat size = CTFontGetSize(originalFont);
</span><del>-        RetainPtr&lt;CFNumberRef&gt; sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &amp;size));
</del><ins>+        auto sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &amp;size));
</ins><span class="cx">         CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, sizeNumber.get());
</span><span class="cx">     }
</span><del>-    RetainPtr&lt;CTFontDescriptorRef&gt; descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
</del><ins>+    auto descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
</ins><span class="cx">     auto result = adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get()));
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="lines">@@ -626,12 +626,12 @@
</span><span class="cx"> 
</span><span class="cx"> Vector&lt;FontTraitsMask&gt; FontCache::getTraitsInFamily(const AtomicString&amp; familyName)
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;CFStringRef&gt; familyNameStr = familyName.string().createCFString();
</del><ins>+    auto familyNameStr = familyName.string().createCFString();
</ins><span class="cx">     CFTypeRef keys[] = { kCTFontFamilyNameAttribute };
</span><span class="cx">     CFTypeRef values[] = { familyNameStr.get() };
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
-    RetainPtr&lt;CTFontDescriptorRef&gt; fontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
-    RetainPtr&lt;CFArrayRef&gt; matchedDescriptors = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(fontDescriptor.get(), nullptr));
</del><ins>+    auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
+    auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
+    auto matchedDescriptors = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(fontDescriptor.get(), nullptr));
</ins><span class="cx">     if (!matchedDescriptors)
</span><span class="cx">         return { };
</span><span class="cx"> 
</span><span class="lines">@@ -642,7 +642,7 @@
</span><span class="cx">     Vector&lt;FontTraitsMask&gt; traitsMasks;
</span><span class="cx">     traitsMasks.reserveInitialCapacity(numMatches);
</span><span class="cx">     for (CFIndex i = 0; i &lt; numMatches; ++i) {
</span><del>-        RetainPtr&lt;CFDictionaryRef&gt; traits = adoptCF((CFDictionaryRef)CTFontDescriptorCopyAttribute((CTFontDescriptorRef)CFArrayGetValueAtIndex(matchedDescriptors.get(), i), kCTFontTraitsAttribute));
</del><ins>+        auto traits = adoptCF((CFDictionaryRef)CTFontDescriptorCopyAttribute((CTFontDescriptorRef)CFArrayGetValueAtIndex(matchedDescriptors.get(), i), kCTFontTraitsAttribute));
</ins><span class="cx">         CFNumberRef resultRef = (CFNumberRef)CFDictionaryGetValue(traits.get(), kCTFontSymbolicTrait);
</span><span class="cx">         CFNumberRef weightRef = (CFNumberRef)CFDictionaryGetValue(traits.get(), kCTFontWeightTrait);
</span><span class="cx">         if (resultRef &amp;&amp; weightRef) {
</span><span class="lines">@@ -686,7 +686,7 @@
</span><span class="cx"> Vector&lt;String&gt; FontCache::systemFontFamilies()
</span><span class="cx"> {
</span><span class="cx">     // FIXME: &lt;rdar://problem/21890188&gt;
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, nullptr, nullptr, 0, &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</del><ins>+    auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, nullptr, nullptr, 0, &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
</ins><span class="cx">     auto emptyFontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
</span><span class="cx">     auto matchedDescriptors = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(emptyFontDescriptor.get(), nullptr));
</span><span class="cx">     if (!matchedDescriptors)
</span><span class="lines">@@ -776,7 +776,7 @@
</span><span class="cx">     if (family.isEmpty())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;CTFontRef&gt; foundFont = platformFontWithFamilySpecialCase(family, weight, desiredTraits, size);
</del><ins>+    auto foundFont = platformFontWithFamilySpecialCase(family, weight, desiredTraits, size);
</ins><span class="cx">     if (!foundFont) {
</span><span class="cx"> #if ENABLE(PLATFORM_FONT_LOOKUP)
</span><span class="cx">         foundFont = platformFontLookupWithFamily(family, desiredTraits, weight, size);
</span><span class="lines">@@ -824,7 +824,7 @@
</span><span class="cx">     CTFontSymbolicTraits traits = computeTraits(fontDescription);
</span><span class="cx">     float size = fontDescription.computedPixelSize();
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;CTFontRef&gt; font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
</del><ins>+    auto font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     if (!font) {
</span><span class="lines">@@ -866,6 +866,50 @@
</span><span class="cx">         fallbackDedupSet().remove(font);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+static inline bool isArabicCharacter(UChar character)
+{
+    return character &gt;= 0x0600 &amp;&amp; character &lt;= 0x06FF;
+}
+#endif
+
+static RetainPtr&lt;CTFontRef&gt; lookupFallbackFont(CTFontRef font, FontWeight fontWeight, const AtomicString&amp; locale, const UChar* characters, unsigned length)
+{
+    ASSERT(length &gt; 0);
+
+    RetainPtr&lt;CFStringRef&gt; localeString;
+#if (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 100000) || (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200)
+    if (!locale.isNull())
+        localeString = locale.string().createCFString();
+#else
+    UNUSED_PARAM(locale);
+#endif
+
+    CFIndex coveredLength = 0;
+    auto result = adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString.get(), &amp;coveredLength));
+
+#if PLATFORM(IOS)
+    // Callers of this function won't include multiple code points. &quot;Length&quot; is to know how many code units
+    // are in the code point.
+    UChar firstCharacter = characters[0];
+    if (isArabicCharacter(firstCharacter)) {
+        auto familyName = adoptCF(static_cast&lt;CFStringRef&gt;(CTFontCopyAttribute(result.get(), kCTFontFamilyNameAttribute)));
+        if (fontFamilyShouldNotBeUsedForArabic(familyName.get())) {
+            CFStringRef newFamilyName = isFontWeightBold(fontWeight) ? CFSTR(&quot;GeezaPro-Bold&quot;) : CFSTR(&quot;GeezaPro&quot;);
+            CFTypeRef keys[] = { kCTFontNameAttribute };
+            CFTypeRef values[] = { newFamilyName };
+            auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
+            auto modification = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
+            result = adoptCF(CTFontCreateCopyWithAttributes(result.get(), CTFontGetSize(result.get()), nullptr, modification.get()));
+        }
+    }
+#else
+    UNUSED_PARAM(fontWeight);
+#endif
+
+    return result;
+}
+
</ins><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"> #if PLATFORM(IOS)
</span><span class="lines">@@ -878,7 +922,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     const FontPlatformData&amp; platformData = originalFontData-&gt;platformData();
</span><del>-    RetainPtr&lt;CTFontRef&gt; result = platformLookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
</del><ins>+    auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
</ins><span class="cx">     result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, description.featureSettings(), description.variantSettings(), description.variationSettings());
</span><span class="cx">     if (!result)
</span><span class="cx">         return lastResortFallbackFont(description);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosFontCacheIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (210775 => 210776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2017-01-15 07:22:19 UTC (rev 210775)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2017-01-15 08:23:31 UTC (rev 210776)
</span><span class="lines">@@ -78,46 +78,6 @@
</span><span class="cx">     return getCachedFontPlatformData(description, *family);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RetainPtr&lt;CTFontRef&gt; getSystemFontFallbackForCharacters(CTFontRef font, const AtomicString&amp; locale, const UChar* characters, unsigned length)
-{
-    // FIXME: Unify this with platformLookupFallbackFont()
-    RetainPtr&lt;CFStringRef&gt; localeString;
-    if (!locale.isNull())
-        localeString = locale.string().createCFString();
-
-    CFIndex coveredLength = 0;
-    return adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(font, (const UTF16Char*)characters, (CFIndex)length, localeString.get(), &amp;coveredLength));
-}
-
-RetainPtr&lt;CTFontRef&gt; platformLookupFallbackFont(CTFontRef font, FontWeight fontWeight, const AtomicString&amp; locale, const UChar* characters, unsigned length)
-{
-    // For system fonts we use CoreText fallback mechanism.
-    if (length &amp;&amp; CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get()))
-        return getSystemFontFallbackForCharacters(font, locale, characters, length);
-
-    RetainPtr&lt;CFStringRef&gt; localeString;
-#if __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 100000
-    if (!locale.isNull())
-        localeString = locale.string().createCFString();
-#endif
-    RetainPtr&lt;CTFontDescriptorRef&gt; fallbackFontDescriptor = adoptCF(CTFontCreatePhysicalFontDescriptorForCharactersWithLanguage(font, characters, length, localeString.get(), nullptr));
-    UChar32 c = *characters;
-    if (length &gt; 1 &amp;&amp; U16_IS_LEAD(c) &amp;&amp; U16_IS_TRAIL(characters[1]))
-        c = U16_GET_SUPPLEMENTARY(c, characters[1]);
-    // Arabic
-    if (c &gt;= 0x0600 &amp;&amp; c &lt;= 0x06ff) {
-        auto familyName = adoptCF(static_cast&lt;CFStringRef&gt;(CTFontDescriptorCopyAttribute(fallbackFontDescriptor.get(), kCTFontFamilyNameAttribute)));
-        if (fontFamilyShouldNotBeUsedForArabic(familyName.get())) {
-            CFStringRef newFamilyName = isFontWeightBold(fontWeight) ? CFSTR(&quot;GeezaPro-Bold&quot;) : CFSTR(&quot;GeezaPro&quot;);
-            CFTypeRef keys[] = { kCTFontNameAttribute };
-            CFTypeRef values[] = { newFamilyName };
-            RetainPtr&lt;CFDictionaryRef&gt; attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks));
-            fallbackFontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithAttributes(fallbackFontDescriptor.get(), attributes.get()));
-        }
-    }
-    return adoptCF(CTFontCreateWithFontDescriptor(fallbackFontDescriptor.get(), CTFontGetSize(font), nullptr));
-}
-
</del><span class="cx"> Ref&lt;Font&gt; FontCache::lastResortFallbackFont(const FontDescription&amp; fontDescription)
</span><span class="cx"> {
</span><span class="cx">     return *fontForFamily(fontDescription, AtomicString(&quot;.PhoneFallback&quot;, AtomicString::ConstructFromLiteral));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (210775 => 210776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2017-01-15 07:22:19 UTC (rev 210775)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2017-01-15 08:23:31 UTC (rev 210776)
</span><span class="lines">@@ -376,20 +376,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RetainPtr&lt;CTFontRef&gt; platformLookupFallbackFont(CTFontRef font, FontWeight, const AtomicString&amp; locale, const UChar* characters, unsigned length)
-{
-    RetainPtr&lt;CFStringRef&gt; localeString;
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt; 101100
-    if (!locale.isNull())
-        localeString = locale.string().createCFString();
-#else
-    UNUSED_PARAM(locale);
-#endif
-
-    CFIndex coveredLength = 0;
-    return adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString.get(), &amp;coveredLength));
-}
-
</del><span class="cx"> Ref&lt;Font&gt; FontCache::lastResortFallbackFont(const FontDescription&amp; fontDescription)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: Would be even better to somehow get the user's default font here.  For now we'll pick
</span></span></pre>
</div>
</div>

</body>
</html>