<!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>[181569] 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/181569">181569</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2015-03-16 11:30:34 -0700 (Mon, 16 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Mac] fast/forms/text-control-intrinsic-widths.html fails when MS Office is installed
https://bugs.webkit.org/show_bug.cgi?id=142720
Reviewed by Myles C. Maxfield.
Tools:
Activate system copies of Microsoft fonts for the current process, thus overriding
any other ones that could be preferred by the system otherwise.
* DumpRenderTree/mac/DumpRenderTree.mm:
(activateSystemCoreWebFonts):
(adjustFonts):
* WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
(WTR::activateSystemCoreWebFonts):
(WTR::activateFonts):
LayoutTests:
* platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt: Removed.
Mavericks result is no different from Yosemite.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreemacDumpRenderTreemm">trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundlecocoaActivateFontsCocoamm">trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformmacmavericksfastformstextcontrolintrinsicwidthsexpectedtxt">trunk/LayoutTests/platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (181568 => 181569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-16 18:23:54 UTC (rev 181568)
+++ trunk/LayoutTests/ChangeLog        2015-03-16 18:30:34 UTC (rev 181569)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-03-16 Alexey Proskuryakov <ap@apple.com>
+
+ [Mac] fast/forms/text-control-intrinsic-widths.html fails when MS Office is installed
+ https://bugs.webkit.org/show_bug.cgi?id=142720
+
+ Reviewed by Myles C. Maxfield.
+
+ * platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt: Removed.
+ Mavericks result is no different from Yosemite.
+
</ins><span class="cx"> 2015-03-16 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Document more debug assertions.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacmavericksfastformstextcontrolintrinsicwidthsexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt (181568 => 181569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt        2015-03-16 18:23:54 UTC (rev 181568)
+++ trunk/LayoutTests/platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt        2015-03-16 18:30:34 UTC (rev 181569)
</span><span class="lines">@@ -1,387 +0,0 @@
</span><del>-This test measures the width of textareas and text inputs for different fonts.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Lucida Grande
-input
-size=1 clientWidth=24
-size=2 clientWidth=29
-size=3 clientWidth=34
-size=4 clientWidth=39
-size=5 clientWidth=44
-size=10 clientWidth=69
-size=20 clientWidth=119
-size=50 clientWidth=269
-size=100 clientWidth=519
-size=500 clientWidth=2519
-size=1000 clientWidth=5019
-
-textarea
-cols=1 clientWidth=26
-cols=2 clientWidth=33
-cols=3 clientWidth=40
-cols=4 clientWidth=47
-cols=5 clientWidth=54
-cols=10 clientWidth=89
-cols=20 clientWidth=159
-cols=50 clientWidth=369
-cols=100 clientWidth=719
-cols=500 clientWidth=3519
-cols=1000 clientWidth=7019
-
-Courier
-input
-size=1 clientWidth=9
-size=2 clientWidth=15
-size=3 clientWidth=22
-size=4 clientWidth=28
-size=5 clientWidth=35
-size=10 clientWidth=68
-size=20 clientWidth=134
-size=50 clientWidth=332
-size=100 clientWidth=662
-size=500 clientWidth=3303
-size=1000 clientWidth=6603
-
-textarea
-cols=1 clientWidth=26
-cols=2 clientWidth=33
-cols=3 clientWidth=39
-cols=4 clientWidth=46
-cols=5 clientWidth=53
-cols=10 clientWidth=86
-cols=20 clientWidth=152
-cols=50 clientWidth=350
-cols=100 clientWidth=680
-cols=500 clientWidth=3320
-cols=1000 clientWidth=6621
-
-Helvetica
-input
-size=1 clientWidth=8
-size=2 clientWidth=14
-size=3 clientWidth=20
-size=4 clientWidth=26
-size=5 clientWidth=33
-size=10 clientWidth=63
-size=20 clientWidth=124
-size=50 clientWidth=308
-size=100 clientWidth=614
-size=500 clientWidth=3061
-size=1000 clientWidth=6120
-
-textarea
-cols=1 clientWidth=26
-cols=2 clientWidth=32
-cols=3 clientWidth=38
-cols=4 clientWidth=44
-cols=5 clientWidth=50
-cols=10 clientWidth=81
-cols=20 clientWidth=142
-cols=50 clientWidth=325
-cols=100 clientWidth=631
-cols=500 clientWidth=3078
-cols=1000 clientWidth=6137
-
-Monaco
-input
-size=1 clientWidth=9
-size=2 clientWidth=15
-size=3 clientWidth=22
-size=4 clientWidth=28
-size=5 clientWidth=35
-size=10 clientWidth=68
-size=20 clientWidth=134
-size=50 clientWidth=332
-size=100 clientWidth=662
-size=500 clientWidth=3303
-size=1000 clientWidth=6603
-
-textarea
-cols=1 clientWidth=26
-cols=2 clientWidth=33
-cols=3 clientWidth=39
-cols=4 clientWidth=46
-cols=5 clientWidth=53
-cols=10 clientWidth=86
-cols=20 clientWidth=152
-cols=50 clientWidth=350
-cols=100 clientWidth=680
-cols=500 clientWidth=3320
-cols=1000 clientWidth=6621
-
-Times
-input
-size=1 clientWidth=8
-size=2 clientWidth=13
-size=3 clientWidth=19
-size=4 clientWidth=24
-size=5 clientWidth=30
-size=10 clientWidth=57
-size=20 clientWidth=112
-size=50 clientWidth=277
-size=100 clientWidth=552
-size=500 clientWidth=2752
-size=1000 clientWidth=5502
-
-textarea
-cols=1 clientWidth=25
-cols=2 clientWidth=30
-cols=3 clientWidth=36
-cols=4 clientWidth=41
-cols=5 clientWidth=47
-cols=10 clientWidth=74
-cols=20 clientWidth=129
-cols=50 clientWidth=294
-cols=100 clientWidth=569
-cols=500 clientWidth=2769
-cols=1000 clientWidth=5519
-
-Andale Mono
-input
-size=1 clientWidth=9
-size=2 clientWidth=16
-size=3 clientWidth=23
-size=4 clientWidth=30
-size=5 clientWidth=37
-size=10 clientWidth=72
-size=20 clientWidth=142
-size=50 clientWidth=352
-size=100 clientWidth=702
-size=500 clientWidth=3502
-size=1000 clientWidth=7002
-
-textarea
-cols=1 clientWidth=26
-cols=2 clientWidth=33
-cols=3 clientWidth=40
-cols=4 clientWidth=47
-cols=5 clientWidth=54
-cols=10 clientWidth=89
-cols=20 clientWidth=159
-cols=50 clientWidth=369
-cols=100 clientWidth=719
-cols=500 clientWidth=3519
-cols=1000 clientWidth=7019
-
-Arial
-input
-size=1 clientWidth=31
-size=2 clientWidth=36
-size=3 clientWidth=41
-size=4 clientWidth=46
-size=5 clientWidth=51
-size=10 clientWidth=76
-size=20 clientWidth=126
-size=50 clientWidth=276
-size=100 clientWidth=526
-size=500 clientWidth=2526
-size=1000 clientWidth=5026
-
-textarea
-cols=1 clientWidth=24
-cols=2 clientWidth=29
-cols=3 clientWidth=34
-cols=4 clientWidth=39
-cols=5 clientWidth=44
-cols=10 clientWidth=69
-cols=20 clientWidth=119
-cols=50 clientWidth=269
-cols=100 clientWidth=519
-cols=500 clientWidth=2519
-cols=1000 clientWidth=5019
-
-Comic Sans MS
-input
-size=1 clientWidth=16
-size=2 clientWidth=21
-size=3 clientWidth=26
-size=4 clientWidth=31
-size=5 clientWidth=36
-size=10 clientWidth=61
-size=20 clientWidth=111
-size=50 clientWidth=261
-size=100 clientWidth=511
-size=500 clientWidth=2511
-size=1000 clientWidth=5011
-
-textarea
-cols=1 clientWidth=24
-cols=2 clientWidth=29
-cols=3 clientWidth=34
-cols=4 clientWidth=39
-cols=5 clientWidth=44
-cols=10 clientWidth=69
-cols=20 clientWidth=119
-cols=50 clientWidth=269
-cols=100 clientWidth=519
-cols=500 clientWidth=2519
-cols=1000 clientWidth=5019
-
-Courier New
-input
-size=1 clientWidth=10
-size=2 clientWidth=17
-size=3 clientWidth=24
-size=4 clientWidth=31
-size=5 clientWidth=38
-size=10 clientWidth=73
-size=20 clientWidth=143
-size=50 clientWidth=353
-size=100 clientWidth=703
-size=500 clientWidth=3503
-size=1000 clientWidth=7003
-
-textarea
-cols=1 clientWidth=26
-cols=2 clientWidth=33
-cols=3 clientWidth=40
-cols=4 clientWidth=47
-cols=5 clientWidth=54
-cols=10 clientWidth=89
-cols=20 clientWidth=159
-cols=50 clientWidth=369
-cols=100 clientWidth=719
-cols=500 clientWidth=3519
-cols=1000 clientWidth=7019
-
-Georgia
-input
-size=1 clientWidth=27
-size=2 clientWidth=32
-size=3 clientWidth=37
-size=4 clientWidth=42
-size=5 clientWidth=47
-size=10 clientWidth=72
-size=20 clientWidth=122
-size=50 clientWidth=272
-size=100 clientWidth=522
-size=500 clientWidth=2522
-size=1000 clientWidth=5022
-
-textarea
-cols=1 clientWidth=24
-cols=2 clientWidth=29
-cols=3 clientWidth=34
-cols=4 clientWidth=39
-cols=5 clientWidth=44
-cols=10 clientWidth=69
-cols=20 clientWidth=119
-cols=50 clientWidth=269
-cols=100 clientWidth=519
-cols=500 clientWidth=2519
-cols=1000 clientWidth=5019
-
-Times New Roman
-input
-size=1 clientWidth=30
-size=2 clientWidth=34
-size=3 clientWidth=38
-size=4 clientWidth=42
-size=5 clientWidth=46
-size=10 clientWidth=66
-size=20 clientWidth=106
-size=50 clientWidth=226
-size=100 clientWidth=426
-size=500 clientWidth=2026
-size=1000 clientWidth=4026
-
-textarea
-cols=1 clientWidth=23
-cols=2 clientWidth=27
-cols=3 clientWidth=31
-cols=4 clientWidth=35
-cols=5 clientWidth=39
-cols=10 clientWidth=59
-cols=20 clientWidth=99
-cols=50 clientWidth=219
-cols=100 clientWidth=419
-cols=500 clientWidth=2019
-cols=1000 clientWidth=4019
-
-Trebuchet MS
-input
-size=1 clientWidth=15
-size=2 clientWidth=20
-size=3 clientWidth=25
-size=4 clientWidth=30
-size=5 clientWidth=35
-size=10 clientWidth=60
-size=20 clientWidth=110
-size=50 clientWidth=260
-size=100 clientWidth=510
-size=500 clientWidth=2510
-size=1000 clientWidth=5010
-
-textarea
-cols=1 clientWidth=24
-cols=2 clientWidth=29
-cols=3 clientWidth=34
-cols=4 clientWidth=39
-cols=5 clientWidth=44
-cols=10 clientWidth=69
-cols=20 clientWidth=119
-cols=50 clientWidth=269
-cols=100 clientWidth=519
-cols=500 clientWidth=2519
-cols=1000 clientWidth=5019
-
-Verdana
-input
-size=1 clientWidth=23
-size=2 clientWidth=29
-size=3 clientWidth=35
-size=4 clientWidth=41
-size=5 clientWidth=47
-size=10 clientWidth=77
-size=20 clientWidth=137
-size=50 clientWidth=317
-size=100 clientWidth=617
-size=500 clientWidth=3017
-size=1000 clientWidth=6017
-
-textarea
-cols=1 clientWidth=25
-cols=2 clientWidth=31
-cols=3 clientWidth=37
-cols=4 clientWidth=43
-cols=5 clientWidth=49
-cols=10 clientWidth=79
-cols=20 clientWidth=139
-cols=50 clientWidth=319
-cols=100 clientWidth=619
-cols=500 clientWidth=3019
-cols=1000 clientWidth=6019
-
-Webdings
-input
-size=1 clientWidth=46
-size=2 clientWidth=57
-size=3 clientWidth=68
-size=4 clientWidth=79
-size=5 clientWidth=90
-size=10 clientWidth=145
-size=20 clientWidth=255
-size=50 clientWidth=585
-size=100 clientWidth=1135
-size=500 clientWidth=5535
-size=1000 clientWidth=11035
-
-textarea
-cols=1 clientWidth=30
-cols=2 clientWidth=41
-cols=3 clientWidth=52
-cols=4 clientWidth=63
-cols=5 clientWidth=74
-cols=10 clientWidth=129
-cols=20 clientWidth=239
-cols=50 clientWidth=569
-cols=100 clientWidth=1119
-cols=500 clientWidth=5519
-cols=1000 clientWidth=11019
-
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (181568 => 181569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-03-16 18:23:54 UTC (rev 181568)
+++ trunk/Tools/ChangeLog        2015-03-16 18:30:34 UTC (rev 181569)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-03-16 Alexey Proskuryakov <ap@apple.com>
+
+ [Mac] fast/forms/text-control-intrinsic-widths.html fails when MS Office is installed
+ https://bugs.webkit.org/show_bug.cgi?id=142720
+
+ Reviewed by Myles C. Maxfield.
+
+ Activate system copies of Microsoft fonts for the current process, thus overriding
+ any other ones that could be preferred by the system otherwise.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (activateSystemCoreWebFonts):
+ (adjustFonts):
+ * WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
+ (WTR::activateSystemCoreWebFonts):
+ (WTR::activateFonts):
+
</ins><span class="cx"> 2015-03-16 Xabier Rodriguez Calvar <calvaris@igalia.com>
</span><span class="cx">
</span><span class="cx"> Created Streams API watchlist
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacDumpRenderTreemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (181568 => 181569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2015-03-16 18:23:54 UTC (rev 181568)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2015-03-16 18:30:34 UTC (rev 181569)
</span><span class="lines">@@ -473,6 +473,48 @@
</span><span class="cx"> appKitAvailableFontsIMP = method_setImplementation(availableFontsMethod, (IMP)drt_NSFontManager_availableFonts);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// Activating system copies of these fonts overrides any others that could be preferred, such as ones
+// in /Library/Fonts/Microsoft, and which don't always have the same metrics.
+// FIXME: Switch to a solution from <rdar://problem/19553550> once it's available.
+static void activateSystemCoreWebFonts()
+{
+ NSArray *coreWebFontNames = @[
+ @"Andale Mono",
+ @"Arial",
+ @"Arial Black",
+ @"Comic Sans MS",
+ @"Courier New",
+ @"Georgia",
+ @"Impact",
+ @"Times New Roman",
+ @"Trebuchet MS",
+ @"Verdana",
+ @"Webdings"
+ ];
+
+ NSArray *fontFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:@"/Library/Fonts" isDirectory:YES]
+ includingPropertiesForKeys:@[NSURLFileResourceTypeKey, NSURLNameKey] options:0 error:0];
+
+ for (NSURL *fontURL in fontFiles) {
+ NSString *resourceType;
+ NSString *fileName;
+ if (![fontURL getResourceValue:&resourceType forKey:NSURLFileResourceTypeKey error:0]
+ || ![fontURL getResourceValue:&fileName forKey:NSURLNameKey error:0])
+ continue;
+ if (![resourceType isEqualToString:NSURLFileResourceTypeRegular])
+ continue;
+
+ // Activate all font variations, such as Arial Bold Italic.ttf. This algorithm is not 100% precise, as it
+ // also activates e.g. Arial Unicode, which is not a variation of Arial.
+ for (NSString *coreWebFontName in coreWebFontNames) {
+ if ([fileName hasPrefix:coreWebFontName]) {
+ CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, 0);
+ break;
+ }
+ }
+ }
+}
+
</ins><span class="cx"> static void activateTestingFonts()
</span><span class="cx"> {
</span><span class="cx"> static const char* fontFileNames[] = {
</span><span class="lines">@@ -508,6 +550,7 @@
</span><span class="cx"> static void adjustFonts()
</span><span class="cx"> {
</span><span class="cx"> swizzleNSFontManagerMethods();
</span><ins>+ activateSystemCoreWebFonts();
</ins><span class="cx"> activateTestingFonts();
</span><span class="cx"> }
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundlecocoaActivateFontsCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm (181568 => 181569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm        2015-03-16 18:23:54 UTC (rev 181568)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm        2015-03-16 18:30:34 UTC (rev 181569)
</span><span class="lines">@@ -241,6 +241,48 @@
</span><span class="cx"> appKitAvailableFontsIMP = method_setImplementation(availableFontsMethod, (IMP)wtr_NSFontManager_availableFonts);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// Activating system copies of these fonts overrides any others that could be preferred, such as ones
+// in /Library/Fonts/Microsoft, and which don't always have the same metrics.
+// FIXME: Switch to a solution from <rdar://problem/19553550> once it's available.
+static void activateSystemCoreWebFonts()
+{
+ NSArray *coreWebFontNames = @[
+ @"Andale Mono",
+ @"Arial",
+ @"Arial Black",
+ @"Comic Sans MS",
+ @"Courier New",
+ @"Georgia",
+ @"Impact",
+ @"Times New Roman",
+ @"Trebuchet MS",
+ @"Verdana",
+ @"Webdings"
+ ];
+
+ NSArray *fontFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:@"/Library/Fonts" isDirectory:YES]
+ includingPropertiesForKeys:@[NSURLFileResourceTypeKey, NSURLNameKey] options:0 error:0];
+
+ for (NSURL *fontURL in fontFiles) {
+ NSString *resourceType;
+ NSString *fileName;
+ if (![fontURL getResourceValue:&resourceType forKey:NSURLFileResourceTypeKey error:0]
+ || ![fontURL getResourceValue:&fileName forKey:NSURLNameKey error:0])
+ continue;
+ if (![resourceType isEqualToString:NSURLFileResourceTypeRegular])
+ continue;
+
+ // Activate all font variations, such as Arial Bold Italic.ttf. This algorithm is not 100% precise, as it
+ // also activates e.g. Arial Unicode, which is not a variation of Arial.
+ for (NSString *coreWebFontName in coreWebFontNames) {
+ if ([fileName hasPrefix:coreWebFontName]) {
+ CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, 0);
+ break;
+ }
+ }
+ }
+}
+
</ins><span class="cx"> #endif // USE(APPKIT)
</span><span class="cx">
</span><span class="cx"> void activateFonts()
</span><span class="lines">@@ -276,6 +318,7 @@
</span><span class="cx">
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> swizzleNSFontManagerMethods();
</span><ins>+ activateSystemCoreWebFonts();
</ins><span class="cx"> #endif // USE(APPKIT)
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>