<!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>[184599] 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/184599">184599</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-05-19 15:52:35 -0700 (Tue, 19 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] Font lookups are flakey due to caching
https://bugs.webkit.org/show_bug.cgi?id=145180
&lt;rdar://problem/21012406&gt;

Reviewed by Darin Adler.

Source/WebCore:

Font lookups were flakey on Mac due to the cache in fontWithFamily().
The reason is that the &quot;desired family&quot; to &quot;available family&quot; mapping
is sometimes dependent on the desired traits. However, our cache was
only using the &quot;desired family&quot; as key.

This patch now uses a std::pair as key containing both the &quot;desired
family&quot; and the &quot;desired traits&quot; for correctness. I also updated the
cache to use WTF types instead of NS types.

Test: platform/mac/fast/text/font-weights.html

* platform/graphics/mac/FontCacheMac.mm:
(WebCore::desiredFamilyToAvailableFamilyMap):
(WebCore::hasDesiredFamilyToAvailableFamilyMapping):
(WebCore::rememberDesiredFamilyToAvailableFamilyMapping):
(WebCore::fontWithFamily):
(WebCore::invalidateFontCache):
(WebCore::desiredFamilyToAvailableFamilyDictionary): Deleted.

LayoutTests:

* platform/mac/TestExpectations:
Unskip platform/mac/fast/text/font-weights.html as it is no longer
flakey after this change.

* platform/mac/fast/text/font-weights-expected.txt:
Rebaseline the test as the expected results were those based on the
bad caching behavior.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasttextfontweightsexpectedtxt">trunk/LayoutTests/platform/mac/fast/text/font-weights-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (184598 => 184599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-05-19 22:22:51 UTC (rev 184598)
+++ trunk/LayoutTests/ChangeLog        2015-05-19 22:52:35 UTC (rev 184599)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-05-19  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        [Mac] Font lookups are flakey due to caching
+        https://bugs.webkit.org/show_bug.cgi?id=145180
+        &lt;rdar://problem/21012406&gt;
+
+        Reviewed by Darin Adler.
+
+        * platform/mac/TestExpectations:
+        Unskip platform/mac/fast/text/font-weights.html as it is no longer
+        flakey after this change.
+
+        * platform/mac/fast/text/font-weights-expected.txt:
+        Rebaseline the test as the expected results were those based on the
+        bad caching behavior.
+
</ins><span class="cx"> 2015-05-19  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         X-Frame-Options headers not respected when loading from application cache.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (184598 => 184599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2015-05-19 22:22:51 UTC (rev 184598)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2015-05-19 22:52:35 UTC (rev 184599)
</span><span class="lines">@@ -1262,4 +1262,3 @@
</span><span class="cx"> webkit.org/b/142548 [ Yosemite+ ] editing/selection/extend-by-character-007.html [ Pass ]
</span><span class="cx"> webkit.org/b/141661 [ Yosemite+ ] fast/text/emoji.html [ Pass ]
</span><span class="cx"> 
</span><del>-webkit.org/b/145149 platform/mac/fast/text/font-weights.html [ Pass Failure ]
</del></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasttextfontweightsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/fast/text/font-weights-expected.txt (184598 => 184599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/text/font-weights-expected.txt        2015-05-19 22:22:51 UTC (rev 184598)
+++ trunk/LayoutTests/platform/mac/fast/text/font-weights-expected.txt        2015-05-19 22:52:35 UTC (rev 184599)
</span><span class="lines">@@ -451,17 +451,17 @@
</span><span class="cx">         RenderText {#text} at (0,0) size 372x18
</span><span class="cx">           text run at (0,0) width 372: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 100 Style: italic&quot;
</span><span class="cx">       RenderBlock {DIV} at (0,2834) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 407x18
-          text run at (0,0) width 407: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 200 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 372x18
+          text run at (0,0) width 372: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 200 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,2852) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 407x18
-          text run at (0,0) width 407: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 300 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 372x18
+          text run at (0,0) width 372: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 300 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,2870) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 424x18
-          text run at (0,0) width 424: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 400 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 372x18
+          text run at (0,0) width 372: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 400 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,2888) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 424x18
-          text run at (0,0) width 424: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 500 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 372x18
+          text run at (0,0) width 372: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 500 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,2906) size 769x19
</span><span class="cx">         RenderText {#text} at (0,0) size 455x19
</span><span class="cx">           text run at (0,0) width 455: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 600 Style: italic&quot;
</span><span class="lines">@@ -475,8 +475,8 @@
</span><span class="cx">         RenderText {#text} at (0,0) size 455x19
</span><span class="cx">           text run at (0,0) width 455: &quot;Font: HelveticaNeue-UltraLightItalic Weight: 900 Style: italic&quot;
</span><span class="cx">       RenderBlock {DIV} at (0,2982) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 343x18
-          text run at (0,0) width 343: &quot;Font: HelveticaNeue-LightItalic Weight: 100 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 375x18
+          text run at (0,0) width 375: &quot;Font: HelveticaNeue-LightItalic Weight: 100 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,3000) size 769x18
</span><span class="cx">         RenderText {#text} at (0,0) size 375x18
</span><span class="cx">           text run at (0,0) width 375: &quot;Font: HelveticaNeue-LightItalic Weight: 200 Style: italic&quot;
</span><span class="lines">@@ -484,11 +484,11 @@
</span><span class="cx">         RenderText {#text} at (0,0) size 375x18
</span><span class="cx">           text run at (0,0) width 375: &quot;Font: HelveticaNeue-LightItalic Weight: 300 Style: italic&quot;
</span><span class="cx">       RenderBlock {DIV} at (0,3036) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 390x18
-          text run at (0,0) width 390: &quot;Font: HelveticaNeue-LightItalic Weight: 400 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 375x18
+          text run at (0,0) width 375: &quot;Font: HelveticaNeue-LightItalic Weight: 400 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,3054) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 390x18
-          text run at (0,0) width 390: &quot;Font: HelveticaNeue-LightItalic Weight: 500 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 375x18
+          text run at (0,0) width 375: &quot;Font: HelveticaNeue-LightItalic Weight: 500 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,3072) size 769x19
</span><span class="cx">         RenderText {#text} at (0,0) size 418x19
</span><span class="cx">           text run at (0,0) width 418: &quot;Font: HelveticaNeue-LightItalic Weight: 600 Style: italic&quot;
</span><span class="lines">@@ -502,14 +502,14 @@
</span><span class="cx">         RenderText {#text} at (0,0) size 418x19
</span><span class="cx">           text run at (0,0) width 418: &quot;Font: HelveticaNeue-LightItalic Weight: 900 Style: italic&quot;
</span><span class="cx">       RenderBlock {DIV} at (0,3148) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 313x18
-          text run at (0,0) width 313: &quot;Font: HelveticaNeue-Italic Weight: 100 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 355x18
+          text run at (0,0) width 355: &quot;Font: HelveticaNeue-Italic Weight: 100 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,3166) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 341x18
-          text run at (0,0) width 341: &quot;Font: HelveticaNeue-Italic Weight: 200 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 355x18
+          text run at (0,0) width 355: &quot;Font: HelveticaNeue-Italic Weight: 200 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,3184) size 769x18
</span><del>-        RenderText {#text} at (0,0) size 341x18
-          text run at (0,0) width 341: &quot;Font: HelveticaNeue-Italic Weight: 300 Style: italic&quot;
</del><ins>+        RenderText {#text} at (0,0) size 355x18
+          text run at (0,0) width 355: &quot;Font: HelveticaNeue-Italic Weight: 300 Style: italic&quot;
</ins><span class="cx">       RenderBlock {DIV} at (0,3202) size 769x18
</span><span class="cx">         RenderText {#text} at (0,0) size 355x18
</span><span class="cx">           text run at (0,0) width 355: &quot;Font: HelveticaNeue-Italic Weight: 400 Style: italic&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184598 => 184599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-19 22:22:51 UTC (rev 184598)
+++ trunk/Source/WebCore/ChangeLog        2015-05-19 22:52:35 UTC (rev 184599)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2015-05-19  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        [Mac] Font lookups are flakey due to caching
+        https://bugs.webkit.org/show_bug.cgi?id=145180
+        &lt;rdar://problem/21012406&gt;
+
+        Reviewed by Darin Adler.
+
+        Font lookups were flakey on Mac due to the cache in fontWithFamily().
+        The reason is that the &quot;desired family&quot; to &quot;available family&quot; mapping
+        is sometimes dependent on the desired traits. However, our cache was
+        only using the &quot;desired family&quot; as key.
+
+        This patch now uses a std::pair as key containing both the &quot;desired
+        family&quot; and the &quot;desired traits&quot; for correctness. I also updated the
+        cache to use WTF types instead of NS types.
+
+        Test: platform/mac/fast/text/font-weights.html
+
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::desiredFamilyToAvailableFamilyMap):
+        (WebCore::hasDesiredFamilyToAvailableFamilyMapping):
+        (WebCore::rememberDesiredFamilyToAvailableFamilyMapping):
+        (WebCore::fontWithFamily):
+        (WebCore::invalidateFontCache):
+        (WebCore::desiredFamilyToAvailableFamilyDictionary): Deleted.
+
</ins><span class="cx"> 2015-05-19  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         X-Frame-Options headers not respected when loading from application cache.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (184598 => 184599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-05-19 22:22:51 UTC (rev 184598)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-05-19 22:52:35 UTC (rev 184599)
</span><span class="lines">@@ -129,31 +129,36 @@
</span><span class="cx">                 FontWeight900Mask));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Keep a cache for mapping desired font families to font families actually
-// available on the system for performance.
-static NSMutableDictionary* desiredFamilyToAvailableFamilyDictionary()
</del><ins>+#if !ENABLE(PLATFORM_FONT_LOOKUP)
+// Keep a cache for mapping desired font families to font families actually available on the system for performance.
+using AvailableFamilyMap = HashMap&lt;std::pair&lt;AtomicString, NSFontTraitMask&gt;, AtomicString&gt;;
+static AvailableFamilyMap&amp; desiredFamilyToAvailableFamilyMap()
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><del>-    static NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
-    return dictionary;
</del><ins>+    static NeverDestroyed&lt;AvailableFamilyMap&gt; map;
+    return map;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-static inline void rememberDesiredFamilyToAvailableFamilyMapping(NSString* desiredFamily, NSString* availableFamily)
</del><ins>+static bool hasDesiredFamilyToAvailableFamilyMapping(const AtomicString&amp; desiredFamily, NSFontTraitMask desiredTraits, NSString*&amp; availableFamily)
</ins><span class="cx"> {
</span><del>-    static const NSUInteger maxCacheSize = 128;
-    NSMutableDictionary *familyMapping = desiredFamilyToAvailableFamilyDictionary();
-    ASSERT([familyMapping count] &lt;= maxCacheSize);
-    if ([familyMapping count] == maxCacheSize) {
-        for (NSString *key in familyMapping) {
-            [familyMapping removeObjectForKey:key];
-            break;
-        }
-    }
-    id value = availableFamily ? availableFamily : [NSNull null];
-    [familyMapping setObject:value forKey:desiredFamily];
</del><ins>+    AtomicString value = desiredFamilyToAvailableFamilyMap().get(std::make_pair(desiredFamily, desiredTraits));
+    availableFamily = value.isEmpty() ? nil : static_cast&lt;NSString*&gt;(value);
+    return !value.isNull();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline void rememberDesiredFamilyToAvailableFamilyMapping(const AtomicString&amp; desiredFamily, NSFontTraitMask desiredTraits, NSString* availableFamily)
+{
+    static const unsigned maxCacheSize = 128;
+    auto&amp; familyMapping = desiredFamilyToAvailableFamilyMap();
+    ASSERT(familyMapping.size() &lt;= maxCacheSize);
+    if (familyMapping.size() &gt;= maxCacheSize)
+        familyMapping.remove(familyMapping.begin());
+
+    // Store nil as an emptyAtom to distinguish from missing values (nullAtom).
+    AtomicString value = availableFamily ? AtomicString(availableFamily) : emptyAtom;
+    familyMapping.add(std::make_pair(desiredFamily, desiredTraits), value);
+}
+
</ins><span class="cx"> #else
</span><span class="cx"> 
</span><span class="cx"> static uint16_t toCoreTextFontWeight(FontWeight fontWeight)
</span><span class="lines">@@ -262,7 +267,6 @@
</span><span class="cx">         return specialCase.value();
</span><span class="cx"> 
</span><span class="cx">     NSFontManager *fontManager = [NSFontManager sharedFontManager];
</span><del>-    NSString *desiredFamily = family;
</del><span class="cx">     NSString *availableFamily;
</span><span class="cx">     int chosenWeight;
</span><span class="cx">     NSFont *font;
</span><span class="lines">@@ -277,20 +281,25 @@
</span><span class="cx">         requestedTraits |= kCTFontItalicTrait;
</span><span class="cx">     if (weight &gt;= FontWeight600)
</span><span class="cx">         requestedTraits |= kCTFontBoldTrait;
</span><ins>+
+    NSString *desiredFamily = family;
</ins><span class="cx">     font = CFBridgingRelease(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size));
</span><span class="cx">     availableFamily = [font familyName];
</span><span class="cx">     chosenWeight = [fontManager weightOfFont:font];
</span><span class="cx"> 
</span><span class="cx"> #else
</span><span class="cx"> 
</span><del>-    id cachedAvailableFamily = [desiredFamilyToAvailableFamilyDictionary() objectForKey:desiredFamily];
-    if (cachedAvailableFamily == [NSNull null]) {
-        // We already know this font is not available.
-        return nil;
</del><ins>+    NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight &gt;= FontWeight600 ? NSBoldFontMask : 0);
+    if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) {
+        if (!availableFamily) {
+            // We already know the desired font family does not map to any available font family.
+            return nil;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    availableFamily = cachedAvailableFamily;
</del><span class="cx">     if (!availableFamily) {
</span><ins>+        NSString *desiredFamily = family;
+
</ins><span class="cx">         // Do a simple case insensitive search for a matching font family.
</span><span class="cx">         // NSFontManager requires exact name matches.
</span><span class="cx">         // This addresses the problem of matching arial to Arial, etc., but perhaps not all the issues.
</span><span class="lines">@@ -302,7 +311,6 @@
</span><span class="cx">         if (!availableFamily) {
</span><span class="cx">             // Match by PostScript name.
</span><span class="cx">             NSFont *nameMatchedFont = nil;
</span><del>-            NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight &gt;= FontWeight600 ? NSBoldFontMask : 0);
</del><span class="cx">             for (NSString *availableFont in [fontManager availableFonts]) {
</span><span class="cx">                 if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
</span><span class="cx">                     nameMatchedFont = [NSFont fontWithName:availableFont size:size];
</span><span class="lines">@@ -322,7 +330,7 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        rememberDesiredFamilyToAvailableFamilyMapping(desiredFamily, availableFamily);
</del><ins>+        rememberDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily);
</ins><span class="cx">         if (!availableFamily)
</span><span class="cx">             return nil;
</span><span class="cx">     }
</span><span class="lines">@@ -406,7 +414,10 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     FontCache::singleton().invalidate();
</span><del>-    [desiredFamilyToAvailableFamilyDictionary() removeAllObjects];
</del><ins>+
+#if !ENABLE(PLATFORM_FONT_LOOKUP)
+    desiredFamilyToAvailableFamilyMap().clear();
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef)
</span></span></pre>
</div>
</div>

</body>
</html>