<!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>[179445] 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/179445">179445</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2015-01-31 12:42:57 -0800 (Sat, 31 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge SimpleFontDataIOS.mm and SimpleFontDataMac.mm into FontCocoa.mm
https://bugs.webkit.org/show_bug.cgi?id=141101
Rubber-stamped by Dan Bernstein.
* WebCore.xcodeproj/project.pbxproj:
Remove SimpleFontDataIOS.mm and SimpleFontDataMac.mm. Add FontCocoa.mm.
* platform/graphics/Font.h:
Remove a few CG only functions from the header that can be implemented as static functions
in the implementation file.
* platform/graphics/cocoa/FontCocoa.mm: Copied from Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm.
(WebCore::fontFamilyShouldNotBeUsedForArabic):
(WebCore::Font::platformInit):
(WebCore::Font::platformCharWidthInit):
(WebCore::Font::platformCreateScaledFont):
(WebCore::Font::determinePitch):
(WebCore::renderingStyle):
(WebCore::advanceForColorBitmapFont):
(WebCore::hasCustomTracking):
(WebCore::canUseFastGlyphAdvanceGetter):
(WebCore::Font::platformWidthForGlyph):
(WebCore::Font::compositeFontReferenceFont):
(WebCore::copyFontTableForTag): Deleted.
(WebCore::Font::renderingStyle): Deleted.
Merge in the iOS specific parts.
* platform/graphics/ios/SimpleFontDataIOS.mm: Removed.
* platform/graphics/mac/SimpleFontDataMac.mm: Removed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFonth">trunk/Source/WebCore/platform/graphics/Font.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsiosSimpleFontDataIOSmm">trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacSimpleFontDataMacmm">trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179444 => 179445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-31 20:30:50 UTC (rev 179444)
+++ trunk/Source/WebCore/ChangeLog        2015-01-31 20:42:57 UTC (rev 179445)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-01-30 Sam Weinig <sam@webkit.org>
+
+ Merge SimpleFontDataIOS.mm and SimpleFontDataMac.mm into FontCocoa.mm
+ https://bugs.webkit.org/show_bug.cgi?id=141101
+
+ Rubber-stamped by Dan Bernstein.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ Remove SimpleFontDataIOS.mm and SimpleFontDataMac.mm. Add FontCocoa.mm.
+
+ * platform/graphics/Font.h:
+ Remove a few CG only functions from the header that can be implemented as static functions
+ in the implementation file.
+
+ * platform/graphics/cocoa/FontCocoa.mm: Copied from Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm.
+ (WebCore::fontFamilyShouldNotBeUsedForArabic):
+ (WebCore::Font::platformInit):
+ (WebCore::Font::platformCharWidthInit):
+ (WebCore::Font::platformCreateScaledFont):
+ (WebCore::Font::determinePitch):
+ (WebCore::renderingStyle):
+ (WebCore::advanceForColorBitmapFont):
+ (WebCore::hasCustomTracking):
+ (WebCore::canUseFastGlyphAdvanceGetter):
+ (WebCore::Font::platformWidthForGlyph):
+ (WebCore::Font::compositeFontReferenceFont):
+ (WebCore::copyFontTableForTag): Deleted.
+ (WebCore::Font::renderingStyle): Deleted.
+ Merge in the iOS specific parts.
+
+ * platform/graphics/ios/SimpleFontDataIOS.mm: Removed.
+ * platform/graphics/mac/SimpleFontDataMac.mm: Removed.
+
</ins><span class="cx"> 2015-01-31 Zalan Bujtas <zalan@apple.com>
</span><span class="cx">
</span><span class="cx"> Regression(r179438) Simple line layout: ASSERTION at SimpleLineLayout::FlowContentsIterator::runWidth().
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (179444 => 179445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-01-31 20:30:50 UTC (rev 179444)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-01-31 20:42:57 UTC (rev 179445)
</span><span class="lines">@@ -1395,7 +1395,6 @@
</span><span class="cx">                 37DDCDA71384501C0008B793 /* MHTMLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 37DDCDA31384501C0008B793 /* MHTMLParser.h */; };
</span><span class="cx">                 37E3524B12450C5200BAF5D9 /* InputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37E3524A12450C5200BAF5D9 /* InputType.cpp */; };
</span><span class="cx">                 37E3524D12450C6600BAF5D9 /* InputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 37E3524C12450C6600BAF5D9 /* InputType.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                37E65950163B10C200EB4574 /* SimpleFontDataIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37E6594F163B10C200EB4574 /* SimpleFontDataIOS.mm */; };
</del><span class="cx">                 37F567CE165358F400DDE92B /* PopupOpeningObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 3772B09516535856000A49CA /* PopupOpeningObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 37F57AB91A50726900876F98 /* AccessibilityARIAGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2981CA9D131822EC00D12F2A /* AccessibilityARIAGrid.cpp */; };
</span><span class="cx">                 37F57ABA1A50726F00876F98 /* AccessibilityARIAGridCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2981CA9E131822EC00D12F2A /* AccessibilityARIAGridCell.cpp */; };
</span><span class="lines">@@ -2474,6 +2473,7 @@
</span><span class="cx">                 7C48A6D0191C9D6500026674 /* WebKitNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C48A6CE191C9D6500026674 /* WebKitNamespace.cpp */; };
</span><span class="cx">                 7C48A6D1191C9D6500026674 /* WebKitNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C48A6CF191C9D6500026674 /* WebKitNamespace.h */; };
</span><span class="cx">                 7C4902A218B825F8007D9298 /* DOMWheelEventInternal.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85989DCA0ACC8BBD00A0BC51 /* DOMWheelEventInternal.h */; };
</span><ins>+                7C4EDD741A7B607800198C4D /* FontCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C4EDD731A7B607800198C4D /* FontCocoa.mm */; };
</ins><span class="cx">                 7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */; };
</span><span class="cx">                 7C5343FC17B74B63004232F0 /* JSMediaQueryListListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */; };
</span><span class="cx">                 7C5343FD17B74B63004232F0 /* JSMediaQueryListListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */; };
</span><span class="lines">@@ -4686,7 +4686,6 @@
</span><span class="cx">                 B2AFFC7C0D00A5C10030074D /* FontCacheMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC740D00A5C10030074D /* FontCacheMac.mm */; };
</span><span class="cx">                 B2AFFC7D0D00A5C10030074D /* FontCustomPlatformData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */; };
</span><span class="cx">                 B2AFFC7E0D00A5C10030074D /* FontCustomPlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */; };
</span><del>-                B2AFFC7F0D00A5C10030074D /* SimpleFontDataMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC770D00A5C10030074D /* SimpleFontDataMac.mm */; };
</del><span class="cx">                 B2AFFC800D00A5C10030074D /* FontCascadeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */; };
</span><span class="cx">                 B2AFFC830D00A5C10030074D /* GlyphPageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */; };
</span><span class="cx">                 B2AFFC970D00A5DF0030074D /* TextBoundaries.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2AFFC8C0D00A5DF0030074D /* TextBoundaries.mm */; };
</span><span class="lines">@@ -8463,7 +8462,6 @@
</span><span class="cx">                 37DDCDA31384501C0008B793 /* MHTMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MHTMLParser.h; sourceTree = "<group>"; };
</span><span class="cx">                 37E3524A12450C5200BAF5D9 /* InputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InputType.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 37E3524C12450C6600BAF5D9 /* InputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputType.h; sourceTree = "<group>"; };
</span><del>-                37E6594F163B10C200EB4574 /* SimpleFontDataIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleFontDataIOS.mm; sourceTree = "<group>"; };
</del><span class="cx">                 37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreURLResponse.h; sourceTree = "<group>"; };
</span><span class="cx">                 37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponse.mm; sourceTree = "<group>"; };
</span><span class="cx">                 37FC96DA1104ED71003E1FAD /* TrailingFloatsRootInlineBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrailingFloatsRootInlineBox.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -9657,6 +9655,7 @@
</span><span class="cx">                 7C48A6CE191C9D6500026674 /* WebKitNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitNamespace.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C48A6CF191C9D6500026674 /* WebKitNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNamespace.h; sourceTree = "<group>"; };
</span><span class="cx">                 7C48A6D2191C9D8E00026674 /* WebKitNamespace.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebKitNamespace.idl; sourceTree = "<group>"; };
</span><ins>+                7C4EDD731A7B607800198C4D /* FontCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCocoa.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorOverlay.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C522D4A15B478B2009B7C95 /* InspectorOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorOverlay.h; sourceTree = "<group>"; };
</span><span class="cx">                 7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaQueryListListener.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -12088,7 +12087,6 @@
</span><span class="cx">                 B2AFFC740D00A5C10030074D /* FontCacheMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCacheMac.mm; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FontCustomPlatformData.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontCustomPlatformData.h; sourceTree = "<group>"; };
</span><del>-                B2AFFC770D00A5C10030074D /* SimpleFontDataMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleFontDataMac.mm; sourceTree = "<group>"; };
</del><span class="cx">                 B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCascadeCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 B2AFFC850D00A5DF0030074D /* character-sets.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "character-sets.txt"; sourceTree = "<group>"; };
</span><span class="lines">@@ -15732,7 +15730,6 @@
</span><span class="cx">                                 C58361A81744523F00173511 /* FontServicesIOS.mm */,
</span><span class="cx">                                 31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */,
</span><span class="cx">                                 FED13D3F0CEA939400D89466 /* IconIOS.mm */,
</span><del>-                                37E6594F163B10C200EB4574 /* SimpleFontDataIOS.mm */,
</del><span class="cx">                                 CEEC6034187DD962003E43BB /* TextTrackRepresentationIOS.h */,
</span><span class="cx">                                 CDCA82941679100F00875714 /* TextTrackRepresentationIOS.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -20463,7 +20460,6 @@
</span><span class="cx">                                 CD60C0C4193E87C7003C656B /* MediaTimeQTKit.mm */,
</span><span class="cx">                                 2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */,
</span><span class="cx">                                 163E88F5118A39D200ED9231 /* SimpleFontDataCoreText.cpp */,
</span><del>-                                B2AFFC770D00A5C10030074D /* SimpleFontDataMac.mm */,
</del><span class="cx">                                 49FFBF3D11C93EE3006A7118 /* WebGLLayer.h */,
</span><span class="cx">                                 49FFBF3E11C93EE3006A7118 /* WebGLLayer.mm */,
</span><span class="cx">                                 0FCF332B0F2B9A25004B6795 /* WebLayer.h */,
</span><span class="lines">@@ -20796,6 +20792,7 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
</span><ins>+                                7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
</ins><span class="cx">                                 B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
</span><span class="cx">                                 2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
</span><span class="cx">                                 2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
</span><span class="lines">@@ -29541,8 +29538,6 @@
</span><span class="cx">                                 93309EA2099EB78C0056E581 /* SharedTimerMac.mm in Sources */,
</span><span class="cx">                                 B2C3DA640D006CD600EF6F26 /* Font.cpp in Sources */,
</span><span class="cx">                                 163E88F7118A39D200ED9231 /* SimpleFontDataCoreText.cpp in Sources */,
</span><del>-                                37E65950163B10C200EB4574 /* SimpleFontDataIOS.mm in Sources */,
-                                B2AFFC7F0D00A5C10030074D /* SimpleFontDataMac.mm in Sources */,
</del><span class="cx">                                 E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */,
</span><span class="cx">                                 E4E9B11B18145692003ACCDF /* SimpleLineLayoutFunctions.cpp in Sources */,
</span><span class="cx">                                 C5A1EA7C152BCF04004D00B6 /* SimplifyMarkupCommand.cpp in Sources */,
</span><span class="lines">@@ -29626,6 +29621,7 @@
</span><span class="cx">                                 E47127CA163438A100ED6F5A /* StyleInvalidationAnalysis.cpp in Sources */,
</span><span class="cx">                                 BC5EB7290E81DE8100B25965 /* StyleMarqueeData.cpp in Sources */,
</span><span class="cx">                                 0FF50271102BA96A0066F39A /* StyleMedia.cpp in Sources */,
</span><ins>+                                7C4EDD741A7B607800198C4D /* FontCocoa.mm in Sources */,
</ins><span class="cx">                                 BC5EB74D0E81E06700B25965 /* StyleMultiColData.cpp in Sources */,
</span><span class="cx">                                 A80E6DFB0A199067007FB8C5 /* StyleProperties.cpp in Sources */,
</span><span class="cx">                                 E1B25106152A0BAF0069B779 /* StylePropertyShorthand.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.h (179444 => 179445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.h        2015-01-31 20:30:50 UTC (rev 179444)
+++ trunk/Source/WebCore/platform/graphics/Font.h        2015-01-31 20:42:57 UTC (rev 179445)
</span><span class="lines">@@ -236,12 +236,6 @@
</span><span class="cx"> float widthForGDIGlyph(Glyph) const;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if USE(CG)
- bool canUseFastGlyphAdvanceGetter(Glyph, CGSize& advance, bool& populatedAdvance) const;
- CGFontRenderingStyle renderingStyle() const;
- bool advanceForColorBitmapFont(Glyph, CGSize& result) const; // Returns true if the font is a color bitmap font
-#endif
-
</del><span class="cx"> FontMetrics m_fontMetrics;
</span><span class="cx"> float m_maxCharWidth;
</span><span class="cx"> float m_avgCharWidth;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCocoammfromrev179385trunkSourceWebCoreplatformgraphicsmacSimpleFontDataMacmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (from rev 179385, trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm) (0 => 179445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm        2015-01-31 20:42:57 UTC (rev 179445)
</span><span class="lines">@@ -0,0 +1,580 @@
</span><ins>+/*
+ * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Alexey Proskuryakov
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "Font.h"
+
+#import "BlockExceptions.h"
+#import "Color.h"
+#import "CoreGraphicsSPI.h"
+#import "CoreTextSPI.h"
+#import "FloatRect.h"
+#import "FontCache.h"
+#import "FontCascade.h"
+#import "FontDescription.h"
+#import "SharedBuffer.h"
+#import "WebCoreSystemInterface.h"
+#import <float.h>
+#import <unicode/uchar.h>
+#import <wtf/Assertions.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/StdLibExtras.h>
+
+#if USE(APPKIT)
+#import <AppKit/AppKit.h>
+#import <ApplicationServices/ApplicationServices.h>
+#else
+#import "FontServicesIOS.h"
+#import <CoreText/CoreText.h>
+#endif
+
+#if USE(APPKIT)
+@interface NSFont (WebAppKitSecretAPI)
+- (BOOL)_isFakeFixedPitch;
+@end
+#endif
+
+namespace WebCore {
+
+static bool fontHasVerticalGlyphs(CTFontRef ctFont)
+{
+ // The check doesn't look neat but this is what AppKit does for vertical writing...
+ RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));
+ CFIndex numTables = CFArrayGetCount(tableTags.get());
+ for (CFIndex index = 0; index < numTables; ++index) {
+ CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
+ if (tag == kCTFontTableVhea || tag == kCTFontTableVORG)
+ return true;
+ }
+ return false;
+}
+
+#if USE(APPKIT)
+static NSString *webFallbackFontFamily(void)
+{
+ static NSString *webFallbackFontFamily = [[[NSFont systemFontOfSize:16.0f] familyName] retain];
+ return webFallbackFontFamily;
+}
+#else
+static bool fontFamilyShouldNotBeUsedForArabic(CFStringRef fontFamilyName)
+{
+ if (!fontFamilyName)
+ return false;
+
+ // Times New Roman contains Arabic glyphs, but Core Text doesn't know how to shape them. <rdar://problem/9823975>
+ // FIXME <rdar://problem/12096835> remove this function once the above bug is fixed.
+ // Arial and Tahoma are have performance issues so don't use them as well.
+ return (CFStringCompare(CFSTR("Times New Roman"), fontFamilyName, 0) == kCFCompareEqualTo)
+ || (CFStringCompare(CFSTR("Arial"), fontFamilyName, 0) == kCFCompareEqualTo)
+ || (CFStringCompare(CFSTR("Tahoma"), fontFamilyName, 0) == kCFCompareEqualTo);
+}
+#endif
+
+void Font::platformInit()
+{
+#if USE(APPKIT)
+ m_syntheticBoldOffset = m_platformData.m_syntheticBold ? 1.0f : 0.f;
+
+ bool failedSetup = false;
+ if (!platformData().cgFont()) {
+ // Ack! Something very bad happened, like a corrupt font.
+ // Try looking for an alternate 'base' font for this renderer.
+
+ // Special case hack to use "Times New Roman" in place of "Times".
+ // "Times RO" is a common font whose family name is "Times".
+ // It overrides the normal "Times" family font.
+ // It also appears to have a corrupt regular variant.
+ NSString *fallbackFontFamily;
+ if ([[m_platformData.nsFont() familyName] isEqual:@"Times"])
+ fallbackFontFamily = @"Times New Roman";
+ else
+ fallbackFontFamily = webFallbackFontFamily();
+
+ // Try setting up the alternate font.
+ // This is a last ditch effort to use a substitute font when something has gone wrong.
+#if !ERROR_DISABLED
+ RetainPtr<NSFont> initialFont = m_platformData.nsFont();
+#endif
+ if (m_platformData.font())
+ m_platformData.setNSFont([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toFamily:fallbackFontFamily]);
+ else
+ m_platformData.setNSFont([NSFont fontWithName:fallbackFontFamily size:m_platformData.size()]);
+ if (!platformData().cgFont()) {
+ if ([fallbackFontFamily isEqual:@"Times New Roman"]) {
+ // OK, couldn't setup Times New Roman as an alternate to Times, fallback
+ // on the system font. If this fails we have no alternative left.
+ m_platformData.setNSFont([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toFamily:webFallbackFontFamily()]);
+ if (!platformData().cgFont()) {
+ // We tried, Times, Times New Roman, and the system font. No joy. We have to give up.
+ LOG_ERROR("unable to initialize with font %@", initialFont.get());
+ failedSetup = true;
+ }
+ } else {
+ // We tried the requested font and the system font. No joy. We have to give up.
+ LOG_ERROR("unable to initialize with font %@", initialFont.get());
+ failedSetup = true;
+ }
+ }
+
+ // Report the problem.
+ LOG_ERROR("Corrupt font detected, using %@ in place of %@.",
+ [m_platformData.nsFont() familyName], [initialFont.get() familyName]);
+ }
+
+ // If all else fails, try to set up using the system font.
+ // This is probably because Times and Times New Roman are both unavailable.
+ if (failedSetup) {
+ m_platformData.setNSFont([NSFont systemFontOfSize:[m_platformData.nsFont() pointSize]]);
+ LOG_ERROR("failed to set up font, using system font %s", m_platformData.font());
+ }
+
+ // Work around <rdar://problem/19433490>
+ CGGlyph dummyGlyphs[] = {0, 0};
+ CGSize dummySize[] = { CGSizeMake(0, 0), CGSizeMake(0, 0) };
+ CTFontTransformGlyphs(m_platformData.ctFont(), dummyGlyphs, dummySize, 2, kCTFontTransformApplyPositioning | kCTFontTransformApplyShaping);
+
+ int iAscent;
+ int iDescent;
+ int iCapHeight;
+ int iLineGap;
+ unsigned unitsPerEm;
+ iAscent = CGFontGetAscent(m_platformData.cgFont());
+ // Some fonts erroneously specify a positive descender value. We follow Core Text in assuming that
+ // such fonts meant the same distance, but in the reverse direction.
+ iDescent = -abs(CGFontGetDescent(m_platformData.cgFont()));
+ iCapHeight = CGFontGetCapHeight(m_platformData.cgFont());
+ iLineGap = CGFontGetLeading(m_platformData.cgFont());
+ unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont());
+
+ float pointSize = m_platformData.m_size;
+ float ascent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
+ float descent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
+ float capHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize;
+
+ float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
+
+ // We need to adjust Times, Helvetica, and Courier to closely match the
+ // vertical metrics of their Microsoft counterparts that are the de facto
+ // web standard. The AppKit adjustment of 20% is too big and is
+ // incorrectly added to line spacing, so we use a 15% adjustment instead
+ // and add it to the ascent.
+ NSString *familyName = [m_platformData.nsFont() familyName];
+ if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"Helvetica"] || [familyName isEqualToString:@"Courier"])
+ ascent += floorf(((ascent + descent) * 0.15f) + 0.5f);
+
+ // Compute and store line spacing, before the line metrics hacks are applied.
+ m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
+
+ // Hack Hiragino line metrics to allow room for marked text underlines.
+ // <rdar://problem/5386183>
+ if (descent < 3 && lineGap >= 3 && [familyName hasPrefix:@"Hiragino"]) {
+ lineGap -= 3 - descent;
+ descent = 3;
+ }
+
+ if (platformData().orientation() == Vertical && !isTextOrientationFallback())
+ m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
+
+ float xHeight;
+
+ if (platformData().orientation() == Horizontal) {
+ // Measure the actual character "x", since it's possible for it to extend below the baseline, and we need the
+ // reported x-height to only include the portion of the glyph that is above the baseline.
+ NSGlyph xGlyph = glyphForCharacter('x');
+ if (xGlyph)
+ xHeight = -CGRectGetMinY(platformBoundsForGlyph(xGlyph));
+ else
+ xHeight = scaleEmToUnits(CGFontGetXHeight(m_platformData.cgFont()), unitsPerEm) * pointSize;
+ } else
+ xHeight = verticalRightOrientationFont()->fontMetrics().xHeight();
+
+ m_fontMetrics.setUnitsPerEm(unitsPerEm);
+ m_fontMetrics.setAscent(ascent);
+ m_fontMetrics.setDescent(descent);
+ m_fontMetrics.setCapHeight(capHeight);
+ m_fontMetrics.setLineGap(lineGap);
+ m_fontMetrics.setXHeight(xHeight);
+#else
+ m_syntheticBoldOffset = m_platformData.m_syntheticBold ? ceilf(m_platformData.size() / 24.0f) : 0.f;
+ m_spaceGlyph = 0;
+ m_spaceWidth = 0;
+ unsigned unitsPerEm;
+ float ascent;
+ float descent;
+ float capHeight;
+ float lineGap;
+ float lineSpacing;
+ float xHeight;
+ RetainPtr<CFStringRef> familyName;
+ if (CTFontRef ctFont = m_platformData.font()) {
+ FontServicesIOS fontService(ctFont);
+ ascent = ceilf(fontService.ascent());
+ descent = ceilf(fontService.descent());
+ lineSpacing = fontService.lineSpacing();
+ lineGap = fontService.lineGap();
+ xHeight = fontService.xHeight();
+ capHeight = fontService.capHeight();
+ unitsPerEm = fontService.unitsPerEm();
+ familyName = adoptCF(CTFontCopyFamilyName(ctFont));
+ } else {
+ CGFontRef cgFont = m_platformData.cgFont();
+
+ unitsPerEm = CGFontGetUnitsPerEm(cgFont);
+
+ float pointSize = m_platformData.size();
+ ascent = lroundf(scaleEmToUnits(CGFontGetAscent(cgFont), unitsPerEm) * pointSize);
+ descent = lroundf(-scaleEmToUnits(-abs(CGFontGetDescent(cgFont)), unitsPerEm) * pointSize);
+ lineGap = lroundf(scaleEmToUnits(CGFontGetLeading(cgFont), unitsPerEm) * pointSize);
+ xHeight = scaleEmToUnits(CGFontGetXHeight(cgFont), unitsPerEm) * pointSize;
+ capHeight = scaleEmToUnits(CGFontGetCapHeight(cgFont), unitsPerEm) * pointSize;
+
+ lineSpacing = ascent + descent + lineGap;
+ familyName = adoptCF(CGFontCopyFamilyName(cgFont));
+ }
+
+ m_fontMetrics.setUnitsPerEm(unitsPerEm);
+ m_fontMetrics.setAscent(ascent);
+ m_fontMetrics.setDescent(descent);
+ m_fontMetrics.setLineGap(lineGap);
+ m_fontMetrics.setLineSpacing(lineSpacing);
+ m_fontMetrics.setXHeight(xHeight);
+ m_fontMetrics.setCapHeight(capHeight);
+ m_shouldNotBeUsedForArabic = fontFamilyShouldNotBeUsedForArabic(familyName.get());
+
+ if (platformData().orientation() == Vertical && !isTextOrientationFallback())
+ m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
+
+ if (!m_platformData.m_isEmoji)
+ return;
+
+ int thirdOfSize = m_platformData.size() / 3;
+ m_fontMetrics.setAscent(thirdOfSize);
+ m_fontMetrics.setDescent(thirdOfSize);
+ m_fontMetrics.setLineGap(thirdOfSize);
+ m_fontMetrics.setLineSpacing(0);
+#endif
+}
+
+void Font::platformCharWidthInit()
+{
+ m_avgCharWidth = 0;
+ m_maxCharWidth = 0;
+
+#if PLATFORM(MAC)
+ RetainPtr<CFDataRef> os2Table = adoptCF(CGFontCopyTableForTag(m_platformData.cgFont(), 'OS/2'));
+ if (os2Table && CFDataGetLength(os2Table.get()) >= 4) {
+ const UInt8* os2 = CFDataGetBytePtr(os2Table.get());
+ SInt16 os2AvgCharWidth = os2[2] * 256 + os2[3];
+ m_avgCharWidth = scaleEmToUnits(os2AvgCharWidth, m_fontMetrics.unitsPerEm()) * m_platformData.m_size;
+ }
+
+ RetainPtr<CFDataRef> headTable = adoptCF(CGFontCopyTableForTag(m_platformData.cgFont(), 'head'));
+ if (headTable && CFDataGetLength(headTable.get()) >= 42) {
+ const UInt8* head = CFDataGetBytePtr(headTable.get());
+ ushort uxMin = head[36] * 256 + head[37];
+ ushort uxMax = head[40] * 256 + head[41];
+ SInt16 xMin = static_cast<SInt16>(uxMin);
+ SInt16 xMax = static_cast<SInt16>(uxMax);
+ float diff = static_cast<float>(xMax - xMin);
+ m_maxCharWidth = scaleEmToUnits(diff, m_fontMetrics.unitsPerEm()) * m_platformData.m_size;
+ }
+#endif
+
+ // Fallback to a cross-platform estimate, which will populate these values if they are non-positive.
+ initCharWidths();
+}
+
+void Font::platformDestroy()
+{
+}
+
+PassRefPtr<Font> Font::platformCreateScaledFont(const FontDescription&, float scaleFactor) const
+{
+ if (isCustomFont()) {
+ FontPlatformData scaledFontData(m_platformData);
+ scaledFontData.m_size = scaledFontData.m_size * scaleFactor;
+ return Font::create(scaledFontData, true, false);
+ }
+
+ float size = m_platformData.size() * scaleFactor;
+
+#if USE(APPKIT)
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+ FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toSize:size], size, false, false, m_platformData.orientation());
+
+ if (scaledFontData.font()) {
+ NSFontManager *fontManager = [NSFontManager sharedFontManager];
+ NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_platformData.nsFont()];
+
+ if (m_platformData.m_syntheticBold)
+ fontTraits |= NSBoldFontMask;
+ if (m_platformData.m_syntheticOblique)
+ fontTraits |= NSItalicFontMask;
+
+ NSFontTraitMask scaledFontTraits = [fontManager traitsOfFont:scaledFontData.nsFont()];
+ scaledFontData.m_syntheticBold = (fontTraits & NSBoldFontMask) && !(scaledFontTraits & NSBoldFontMask);
+ scaledFontData.m_syntheticOblique = (fontTraits & NSItalicFontMask) && !(scaledFontTraits & NSItalicFontMask);
+
+ return fontCache().fontForPlatformData(scaledFontData);
+ }
+ END_BLOCK_OBJC_EXCEPTIONS;
+
+ return 0;
+#else
+ CTFontSymbolicTraits fontTraits = CTFontGetSymbolicTraits(m_platformData.font());
+ RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontCopyFontDescriptor(m_platformData.font()));
+ RetainPtr<CTFontRef> scaledFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), size, nullptr));
+ FontPlatformData scaledFontData(scaledFont.get(), size, false, false, m_platformData.orientation());
+
+ if (scaledFontData.font()) {
+ if (m_platformData.m_syntheticBold)
+ fontTraits |= kCTFontBoldTrait;
+ if (m_platformData.m_syntheticOblique)
+ fontTraits |= kCTFontItalicTrait;
+
+ CTFontSymbolicTraits scaledFontTraits = CTFontGetSymbolicTraits(scaledFontData.font());
+ scaledFontData.m_syntheticBold = (fontTraits & kCTFontBoldTrait) && !(scaledFontTraits & kCTFontTraitBold);
+ scaledFontData.m_syntheticOblique = (fontTraits & kCTFontItalicTrait) && !(scaledFontTraits & kCTFontTraitItalic);
+
+ return fontCache().fontForPlatformData(scaledFontData);
+ }
+
+ return nullptr;
+#endif
+}
+
+void Font::determinePitch()
+{
+#if USE(APPKIT)
+ NSFont* f = m_platformData.nsFont();
+ // Special case Osaka-Mono.
+ // According to <rdar://problem/3999467>, we should treat Osaka-Mono as fixed pitch.
+ // Note that the AppKit does not report Osaka-Mono as fixed pitch.
+
+ // Special case MS-PGothic.
+ // According to <rdar://problem/4032938>, we should not treat MS-PGothic as fixed pitch.
+ // Note that AppKit does report MS-PGothic as fixed pitch.
+
+ // Special case MonotypeCorsiva
+ // According to <rdar://problem/5454704>, we should not treat MonotypeCorsiva as fixed pitch.
+ // Note that AppKit does report MonotypeCorsiva as fixed pitch.
+
+ NSString *name = [f fontName];
+ m_treatAsFixedPitch = ([f isFixedPitch] || [f _isFakeFixedPitch] || [name caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame) && [name caseInsensitiveCompare:@"MS-PGothic"] != NSOrderedSame && [name caseInsensitiveCompare:@"MonotypeCorsiva"] != NSOrderedSame;
+#else
+ CTFontRef ctFont = m_platformData.font();
+ m_treatAsFixedPitch = false;
+ if (!ctFont)
+ return; // CTFont is null in the case of SVG fonts for example.
+
+ RetainPtr<CFStringRef> fullName = adoptCF(CTFontCopyFullName(ctFont));
+ RetainPtr<CFStringRef> familyName = adoptCF(CTFontCopyFamilyName(ctFont));
+
+ m_treatAsFixedPitch = CGFontIsFixedPitch(m_platformData.cgFont()) || (fullName && (CFStringCompare(fullName.get(), CFSTR("Osaka-Mono"), kCFCompareCaseInsensitive) == kCFCompareEqualTo || CFStringCompare(fullName.get(), CFSTR("MS-PGothic"), kCFCompareCaseInsensitive) == kCFCompareEqualTo));
+ if (familyName && CFStringCompare(familyName.get(), CFSTR("Courier New"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ // Special case Courier New to not be treated as fixed pitch, as this will make use of a hacked space width which is undesireable for iPhone (see rdar://6269783).
+ m_treatAsFixedPitch = false;
+ }
+#endif
+}
+
+FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
+{
+ FloatRect boundingBox;
+ boundingBox = CTFontGetBoundingRectsForGlyphs(m_platformData.ctFont(), platformData().orientation() == Vertical ? kCTFontVerticalOrientation : kCTFontHorizontalOrientation, &glyph, 0, 1);
+ boundingBox.setY(-boundingBox.maxY());
+ if (m_syntheticBoldOffset)
+ boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset);
+
+ return boundingBox;
+}
+
+static inline CGFontRenderingStyle renderingStyle(const FontPlatformData& platformData)
+{
+#if USE(APPKIT)
+ CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization;
+ NSFont *font = platformData.nsFont();
+ if (font) {
+ switch ([font renderingMode]) {
+ case NSFontIntegerAdvancementsRenderingMode:
+ style = 0;
+ break;
+ case NSFontAntialiasedIntegerAdvancementsRenderingMode:
+ style = kCGFontRenderingStyleAntialiasing;
+ break;
+ default:
+ break;
+ }
+ }
+ return style;
+
+#else
+ UNUSED_PARAM(platformData);
+ return kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
+#endif
+}
+
+static inline bool advanceForColorBitmapFont(const FontPlatformData& platformData, Glyph glyph, CGSize& advance)
+{
+#if PLATFORM(MAC)
+ NSFont *font = platformData.nsFont();
+ if (!font || !platformData.isColorBitmapFont())
+ return false;
+ advance = NSSizeToCGSize([font advancementForGlyph:glyph]);
+ return true;
+#else
+ UNUSED_PARAM(platformData);
+ UNUSED_PARAM(glyph);
+ UNUSED_PARAM(advance);
+ return false;
+#endif
+}
+
+static bool hasCustomTracking(CTFontRef font)
+{
+ return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());
+}
+
+static inline bool isEmoji(const FontPlatformData& platformData)
+{
+#if PLATFORM(IOS)
+ return platformData.m_isEmoji;
+#else
+ UNUSED_PARAM(platformData);
+ return false;
+#endif
+}
+
+static inline bool canUseFastGlyphAdvanceGetter(const FontPlatformData& platformData, Glyph glyph, CGSize& advance, bool& populatedAdvance)
+{
+ // Fast getter doesn't take custom tracking into account
+ if (hasCustomTracking(platformData.ctFont()))
+ return false;
+ // Fast getter doesn't work for emoji
+ if (isEmoji(platformData))
+ return false;
+ // ... or for any bitmap fonts in general
+ if (advanceForColorBitmapFont(platformData, glyph, advance)) {
+ populatedAdvance = true;
+ return false;
+ }
+ return true;
+}
+
+float Font::platformWidthForGlyph(Glyph glyph) const
+{
+ CGSize advance = CGSizeZero;
+ bool horizontal = platformData().orientation() == Horizontal;
+ bool populatedAdvance = false;
+ if ((horizontal || m_isBrokenIdeographFallback) && canUseFastGlyphAdvanceGetter(platformData(), glyph, advance, populatedAdvance)) {
+ float pointSize = platformData().m_size;
+ CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
+ if (!CGFontGetGlyphAdvancesForStyle(platformData().cgFont(), &m, renderingStyle(platformData()), &glyph, 1, &advance)) {
+ RetainPtr<CFStringRef> fullName = adoptCF(CGFontCopyFullName(platformData().cgFont()));
+ LOG_ERROR("Unable to cache glyph widths for %@ %f", fullName.get(), pointSize);
+ advance.width = 0;
+ }
+ } else if (!populatedAdvance)
+ CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), horizontal ? kCTFontHorizontalOrientation : kCTFontVerticalOrientation, &glyph, &advance, 1);
+
+ return advance.width + m_syntheticBoldOffset;
+}
+
+struct ProviderInfo {
+ const UChar* characters;
+ size_t length;
+ CFDictionaryRef attributes;
+};
+
+static const UniChar* provideStringAndAttributes(CFIndex stringIndex, CFIndex* count, CFDictionaryRef* attributes, void* context)
+{
+ ProviderInfo* info = static_cast<struct ProviderInfo*>(context);
+ if (stringIndex < 0 || static_cast<size_t>(stringIndex) >= info->length)
+ return 0;
+
+ *count = info->length - stringIndex;
+ *attributes = info->attributes;
+ return info->characters + stringIndex;
+}
+
+bool Font::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
+{
+ ASSERT(isMainThread());
+
+ if (!m_combiningCharacterSequenceSupport)
+ m_combiningCharacterSequenceSupport = std::make_unique<HashMap<String, bool>>();
+
+ WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequenceSupport->add(String(characters, length), false);
+ if (!addResult.isNewEntry)
+ return addResult.iterator->value;
+
+ RetainPtr<CFTypeRef> fontEqualityObject = platformData().objectForEqualityCheck();
+
+ ProviderInfo info = { characters, length, getCFStringAttributes(0, platformData().orientation()) };
+ RetainPtr<CTLineRef> line = adoptCF(CTLineCreateWithUniCharProvider(&provideStringAndAttributes, 0, &info));
+
+ CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
+ CFIndex runCount = CFArrayGetCount(runArray);
+
+ for (CFIndex r = 0; r < runCount; r++) {
+ CTRunRef ctRun = static_cast<CTRunRef>(CFArrayGetValueAtIndex(runArray, r));
+ ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
+ CFDictionaryRef runAttributes = CTRunGetAttributes(ctRun);
+ CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttributes, kCTFontAttributeName));
+ if (!CFEqual(fontEqualityObject.get(), FontPlatformData::objectForEqualityCheck(runFont).get()))
+ return false;
+ }
+
+ addResult.iterator->value = true;
+ return true;
+}
+
+#if USE(APPKIT)
+const Font* Font::compositeFontReferenceFont(NSFont *key) const
+{
+ if (!key || CFEqual(adoptCF(CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort")))
+ return nullptr;
+
+ if (!m_derivedFontData)
+ m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
+
+ auto addResult = m_derivedFontData->compositeFontReferences.add(key, nullptr);
+ if (addResult.isNewEntry) {
+ NSFont *substituteFont = [key printerFont];
+
+ CTFontSymbolicTraits traits = CTFontGetSymbolicTraits((CTFontRef)substituteFont);
+ bool syntheticBold = platformData().syntheticBold() && !(traits & kCTFontBoldTrait);
+ bool syntheticOblique = platformData().syntheticOblique() && !(traits & kCTFontItalicTrait);
+
+ FontPlatformData substitutePlatform(substituteFont, platformData().size(), syntheticBold, syntheticOblique, platformData().orientation(), platformData().widthVariant());
+ addResult.iterator->value = Font::create(substitutePlatform, isCustomFont());
+ }
+ return addResult.iterator->value.get();
+}
+#endif
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosSimpleFontDataIOSmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm (179444 => 179445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm        2015-01-31 20:30:50 UTC (rev 179444)
+++ trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm        2015-01-31 20:42:57 UTC (rev 179445)
</span><span class="lines">@@ -1,197 +0,0 @@
</span><del>-/*
- * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Font.h"
-
-#import "BlockExceptions.h"
-#import "CoreGraphicsSPI.h"
-#import "FontCache.h"
-#import "FontCascade.h"
-#import "FontDescription.h"
-#import "FontServicesIOS.h"
-#import <CoreText/CoreText.h>
-#import <float.h>
-#import <unicode/uchar.h>
-#import <wtf/Assertions.h>
-#import <wtf/StdLibExtras.h>
-
-namespace WebCore {
-
-static bool fontFamilyShouldNotBeUsedForArabic(CFStringRef fontFamilyName)
-{
- if (!fontFamilyName)
- return false;
-
- // Times New Roman contains Arabic glyphs, but Core Text doesn't know how to shape them. <rdar://problem/9823975>
- // FIXME <rdar://problem/12096835> remove this function once the above bug is fixed.
- // Arial and Tahoma are have performance issues so don't use them as well.
- return (CFStringCompare(CFSTR("Times New Roman"), fontFamilyName, 0) == kCFCompareEqualTo)
- || (CFStringCompare(CFSTR("Arial"), fontFamilyName, 0) == kCFCompareEqualTo)
- || (CFStringCompare(CFSTR("Tahoma"), fontFamilyName, 0) == kCFCompareEqualTo);
-}
-
-static bool fontHasVerticalGlyphs(CTFontRef ctFont)
-{
- // The check doesn't look neat but this is what AppKit does for vertical writing...
- RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));
- CFIndex numTables = CFArrayGetCount(tableTags.get());
- for (CFIndex index = 0; index < numTables; ++index) {
- CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
- if (tag == kCTFontTableVhea || tag == kCTFontTableVORG)
- return true;
- }
- return false;
-}
-
-void Font::platformInit()
-{
- m_syntheticBoldOffset = m_platformData.m_syntheticBold ? ceilf(m_platformData.size() / 24.0f) : 0.f;
- m_spaceGlyph = 0;
- m_spaceWidth = 0;
- unsigned unitsPerEm;
- float ascent;
- float descent;
- float capHeight;
- float lineGap;
- float lineSpacing;
- float xHeight;
- RetainPtr<CFStringRef> familyName;
- if (CTFontRef ctFont = m_platformData.font()) {
- FontServicesIOS fontService(ctFont);
- ascent = ceilf(fontService.ascent());
- descent = ceilf(fontService.descent());
- lineSpacing = fontService.lineSpacing();
- lineGap = fontService.lineGap();
- xHeight = fontService.xHeight();
- capHeight = fontService.capHeight();
- unitsPerEm = fontService.unitsPerEm();
- familyName = adoptCF(CTFontCopyFamilyName(ctFont));
- } else {
- CGFontRef cgFont = m_platformData.cgFont();
-
- unitsPerEm = CGFontGetUnitsPerEm(cgFont);
-
- float pointSize = m_platformData.size();
- ascent = lroundf(scaleEmToUnits(CGFontGetAscent(cgFont), unitsPerEm) * pointSize);
- descent = lroundf(-scaleEmToUnits(-abs(CGFontGetDescent(cgFont)), unitsPerEm) * pointSize);
- lineGap = lroundf(scaleEmToUnits(CGFontGetLeading(cgFont), unitsPerEm) * pointSize);
- xHeight = scaleEmToUnits(CGFontGetXHeight(cgFont), unitsPerEm) * pointSize;
- capHeight = scaleEmToUnits(CGFontGetCapHeight(cgFont), unitsPerEm) * pointSize;
-
- lineSpacing = ascent + descent + lineGap;
- familyName = adoptCF(CGFontCopyFamilyName(cgFont));
- }
-
- m_fontMetrics.setUnitsPerEm(unitsPerEm);
- m_fontMetrics.setAscent(ascent);
- m_fontMetrics.setDescent(descent);
- m_fontMetrics.setLineGap(lineGap);
- m_fontMetrics.setLineSpacing(lineSpacing);
- m_fontMetrics.setXHeight(xHeight);
- m_fontMetrics.setCapHeight(capHeight);
- m_shouldNotBeUsedForArabic = fontFamilyShouldNotBeUsedForArabic(familyName.get());
-
- if (platformData().orientation() == Vertical && !isTextOrientationFallback())
- m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
-
- if (!m_platformData.m_isEmoji)
- return;
-
- int thirdOfSize = m_platformData.size() / 3;
- m_fontMetrics.setAscent(thirdOfSize);
- m_fontMetrics.setDescent(thirdOfSize);
- m_fontMetrics.setLineGap(thirdOfSize);
- m_fontMetrics.setLineSpacing(0);
-}
-
-void Font::platformCharWidthInit()
-{
- m_avgCharWidth = 0;
- m_maxCharWidth = 0;
-
- // Fallback to a cross-platform estimate, which will populate these values if they are non-positive.
- initCharWidths();
-}
-
-PassRefPtr<Font> Font::platformCreateScaledFont(const FontDescription&, float scaleFactor) const
-{
- if (isCustomFont()) {
- FontPlatformData scaledFontData(m_platformData);
- scaledFontData.m_size = scaledFontData.m_size * scaleFactor;
- return Font::create(scaledFontData, true, false);
- }
-
- float size = m_platformData.size() * scaleFactor;
- CTFontSymbolicTraits fontTraits = CTFontGetSymbolicTraits(m_platformData.font());
- RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontCopyFontDescriptor(m_platformData.font()));
- RetainPtr<CTFontRef> scaledFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), size, nullptr));
- FontPlatformData scaledFontData(scaledFont.get(), size, false, false, m_platformData.orientation());
-
- if (scaledFontData.font()) {
- if (m_platformData.m_syntheticBold)
- fontTraits |= kCTFontBoldTrait;
- if (m_platformData.m_syntheticOblique)
- fontTraits |= kCTFontItalicTrait;
-
- CTFontSymbolicTraits scaledFontTraits = CTFontGetSymbolicTraits(scaledFontData.font());
- scaledFontData.m_syntheticBold = (fontTraits & kCTFontBoldTrait) && !(scaledFontTraits & kCTFontTraitBold);
- scaledFontData.m_syntheticOblique = (fontTraits & kCTFontItalicTrait) && !(scaledFontTraits & kCTFontTraitItalic);
-
- return fontCache().fontForPlatformData(scaledFontData);
- }
-
- return nullptr;
-}
-
-void Font::determinePitch()
-{
- CTFontRef ctFont = m_platformData.font();
- m_treatAsFixedPitch = false;
- if (!ctFont)
- return; // CTFont is null in the case of SVG fonts for example.
-
- RetainPtr<CFStringRef> fullName = adoptCF(CTFontCopyFullName(ctFont));
- RetainPtr<CFStringRef> familyName = adoptCF(CTFontCopyFamilyName(ctFont));
-
- m_treatAsFixedPitch = CGFontIsFixedPitch(m_platformData.cgFont()) || (fullName && (CFStringCompare(fullName.get(), CFSTR("Osaka-Mono"), kCFCompareCaseInsensitive) == kCFCompareEqualTo || CFStringCompare(fullName.get(), CFSTR("MS-PGothic"), kCFCompareCaseInsensitive) == kCFCompareEqualTo));
- if (familyName && CFStringCompare(familyName.get(), CFSTR("Courier New"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- // Special case Courier New to not be treated as fixed pitch, as this will make use of a hacked space width which is undesireable for iPhone (see rdar://6269783).
- m_treatAsFixedPitch = false;
- }
-}
-
-CGFontRenderingStyle Font::renderingStyle() const
-{
- return kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
-}
-
-bool Font::advanceForColorBitmapFont(Glyph, CGSize&) const
-{
- return false;
-}
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacSimpleFontDataMacmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm (179444 => 179445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm        2015-01-31 20:30:50 UTC (rev 179444)
+++ trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm        2015-01-31 20:42:57 UTC (rev 179445)
</span><span class="lines">@@ -1,480 +0,0 @@
</span><del>-/*
- * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Font.h"
-
-#import "BlockExceptions.h"
-#import "Color.h"
-#import "CoreGraphicsSPI.h"
-#import "CoreTextSPI.h"
-#import "FloatRect.h"
-#import "FontCache.h"
-#import "FontCascade.h"
-#import "FontDescription.h"
-#import "SharedBuffer.h"
-#import "WebCoreSystemInterface.h"
-#if USE(APPKIT)
-#import <AppKit/AppKit.h>
-#import <ApplicationServices/ApplicationServices.h>
-#else
-#import <CoreText/CoreText.h>
-#endif
-#import <float.h>
-#import <unicode/uchar.h>
-#import <wtf/Assertions.h>
-#import <wtf/StdLibExtras.h>
-#import <wtf/RetainPtr.h>
-
-#if !PLATFORM(IOS)
-@interface NSFont (WebAppKitSecretAPI)
-- (BOOL)_isFakeFixedPitch;
-@end
-#endif
-
-namespace WebCore {
-
-#if USE(APPKIT)
-static bool fontHasVerticalGlyphs(CTFontRef ctFont)
-{
- // The check doesn't look neat but this is what AppKit does for vertical writing...
- RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));
- CFIndex numTables = CFArrayGetCount(tableTags.get());
- for (CFIndex index = 0; index < numTables; ++index) {
- CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
- if (tag == kCTFontTableVhea || tag == kCTFontTableVORG)
- return true;
- }
- return false;
-}
-
-static bool initFontData(Font* fontData)
-{
- if (!fontData->platformData().cgFont())
- return false;
-
- return true;
-}
-
-static NSString *webFallbackFontFamily(void)
-{
- static NSString *webFallbackFontFamily = [[[NSFont systemFontOfSize:16.0f] familyName] retain];
- return webFallbackFontFamily;
-}
-
-const Font* Font::compositeFontReferenceFont(NSFont *key) const
-{
- if (!key || CFEqual(adoptCF(CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort")))
- return nullptr;
-
- if (!m_derivedFontData)
- m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
-
- auto addResult = m_derivedFontData->compositeFontReferences.add(key, nullptr);
- if (addResult.isNewEntry) {
- NSFont *substituteFont = [key printerFont];
-
- CTFontSymbolicTraits traits = CTFontGetSymbolicTraits((CTFontRef)substituteFont);
- bool syntheticBold = platformData().syntheticBold() && !(traits & kCTFontBoldTrait);
- bool syntheticOblique = platformData().syntheticOblique() && !(traits & kCTFontItalicTrait);
-
- FontPlatformData substitutePlatform(substituteFont, platformData().size(), syntheticBold, syntheticOblique, platformData().orientation(), platformData().widthVariant());
- addResult.iterator->value = Font::create(substitutePlatform, isCustomFont());
- }
- return addResult.iterator->value.get();
-}
-
-void Font::platformInit()
-{
- m_syntheticBoldOffset = m_platformData.m_syntheticBold ? 1.0f : 0.f;
-
- bool failedSetup = false;
- if (!initFontData(this)) {
- // Ack! Something very bad happened, like a corrupt font.
- // Try looking for an alternate 'base' font for this renderer.
-
- // Special case hack to use "Times New Roman" in place of "Times".
- // "Times RO" is a common font whose family name is "Times".
- // It overrides the normal "Times" family font.
- // It also appears to have a corrupt regular variant.
- NSString *fallbackFontFamily;
- if ([[m_platformData.nsFont() familyName] isEqual:@"Times"])
- fallbackFontFamily = @"Times New Roman";
- else
- fallbackFontFamily = webFallbackFontFamily();
-
- // Try setting up the alternate font.
- // This is a last ditch effort to use a substitute font when something has gone wrong.
-#if !ERROR_DISABLED
- RetainPtr<NSFont> initialFont = m_platformData.nsFont();
-#endif
- if (m_platformData.font())
- m_platformData.setNSFont([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toFamily:fallbackFontFamily]);
- else
- m_platformData.setNSFont([NSFont fontWithName:fallbackFontFamily size:m_platformData.size()]);
- if (!initFontData(this)) {
- if ([fallbackFontFamily isEqual:@"Times New Roman"]) {
- // OK, couldn't setup Times New Roman as an alternate to Times, fallback
- // on the system font. If this fails we have no alternative left.
- m_platformData.setNSFont([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toFamily:webFallbackFontFamily()]);
- if (!initFontData(this)) {
- // We tried, Times, Times New Roman, and the system font. No joy. We have to give up.
- LOG_ERROR("unable to initialize with font %@", initialFont.get());
- failedSetup = true;
- }
- } else {
- // We tried the requested font and the system font. No joy. We have to give up.
- LOG_ERROR("unable to initialize with font %@", initialFont.get());
- failedSetup = true;
- }
- }
-
- // Report the problem.
- LOG_ERROR("Corrupt font detected, using %@ in place of %@.",
- [m_platformData.nsFont() familyName], [initialFont.get() familyName]);
- }
-
- // If all else fails, try to set up using the system font.
- // This is probably because Times and Times New Roman are both unavailable.
- if (failedSetup) {
- m_platformData.setNSFont([NSFont systemFontOfSize:[m_platformData.nsFont() pointSize]]);
- LOG_ERROR("failed to set up font, using system font %s", m_platformData.font());
- initFontData(this);
- }
-
-#if PLATFORM(MAC)
- // Work around <rdar://problem/19433490>
- CGGlyph dummyGlyphs[] = {0, 0};
- CGSize dummySize[] = {CGSizeMake(0, 0), CGSizeMake(0, 0)};
- CTFontTransformGlyphs(m_platformData.ctFont(), dummyGlyphs, dummySize, 2, kCTFontTransformApplyPositioning | kCTFontTransformApplyShaping);
-#endif
-
- int iAscent;
- int iDescent;
- int iCapHeight;
- int iLineGap;
- unsigned unitsPerEm;
- iAscent = CGFontGetAscent(m_platformData.cgFont());
- // Some fonts erroneously specify a positive descender value. We follow Core Text in assuming that
- // such fonts meant the same distance, but in the reverse direction.
- iDescent = -abs(CGFontGetDescent(m_platformData.cgFont()));
- iCapHeight = CGFontGetCapHeight(m_platformData.cgFont());
- iLineGap = CGFontGetLeading(m_platformData.cgFont());
- unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont());
-
- float pointSize = m_platformData.m_size;
- float ascent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
- float descent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
- float capHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize;
-
- float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
-
- // We need to adjust Times, Helvetica, and Courier to closely match the
- // vertical metrics of their Microsoft counterparts that are the de facto
- // web standard. The AppKit adjustment of 20% is too big and is
- // incorrectly added to line spacing, so we use a 15% adjustment instead
- // and add it to the ascent.
- NSString *familyName = [m_platformData.nsFont() familyName];
- if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"Helvetica"] || [familyName isEqualToString:@"Courier"])
- ascent += floorf(((ascent + descent) * 0.15f) + 0.5f);
-
- // Compute and store line spacing, before the line metrics hacks are applied.
- m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
-
- // Hack Hiragino line metrics to allow room for marked text underlines.
- // <rdar://problem/5386183>
- if (descent < 3 && lineGap >= 3 && [familyName hasPrefix:@"Hiragino"]) {
- lineGap -= 3 - descent;
- descent = 3;
- }
-
- if (platformData().orientation() == Vertical && !isTextOrientationFallback())
- m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
-
- float xHeight;
-
- if (platformData().orientation() == Horizontal) {
- // Measure the actual character "x", since it's possible for it to extend below the baseline, and we need the
- // reported x-height to only include the portion of the glyph that is above the baseline.
- NSGlyph xGlyph = glyphForCharacter('x');
- if (xGlyph)
- xHeight = -CGRectGetMinY(platformBoundsForGlyph(xGlyph));
- else
- xHeight = scaleEmToUnits(CGFontGetXHeight(m_platformData.cgFont()), unitsPerEm) * pointSize;
- } else
- xHeight = verticalRightOrientationFont()->fontMetrics().xHeight();
-
- m_fontMetrics.setUnitsPerEm(unitsPerEm);
- m_fontMetrics.setAscent(ascent);
- m_fontMetrics.setDescent(descent);
- m_fontMetrics.setCapHeight(capHeight);
- m_fontMetrics.setLineGap(lineGap);
- m_fontMetrics.setXHeight(xHeight);
-}
-
-static CFDataRef copyFontTableForTag(FontPlatformData& platformData, FourCharCode tableName)
-{
- return CGFontCopyTableForTag(platformData.cgFont(), tableName);
-}
-
-void Font::platformCharWidthInit()
-{
- m_avgCharWidth = 0;
- m_maxCharWidth = 0;
-
- RetainPtr<CFDataRef> os2Table = adoptCF(copyFontTableForTag(m_platformData, 'OS/2'));
- if (os2Table && CFDataGetLength(os2Table.get()) >= 4) {
- const UInt8* os2 = CFDataGetBytePtr(os2Table.get());
- SInt16 os2AvgCharWidth = os2[2] * 256 + os2[3];
- m_avgCharWidth = scaleEmToUnits(os2AvgCharWidth, m_fontMetrics.unitsPerEm()) * m_platformData.m_size;
- }
-
- RetainPtr<CFDataRef> headTable = adoptCF(copyFontTableForTag(m_platformData, 'head'));
- if (headTable && CFDataGetLength(headTable.get()) >= 42) {
- const UInt8* head = CFDataGetBytePtr(headTable.get());
- ushort uxMin = head[36] * 256 + head[37];
- ushort uxMax = head[40] * 256 + head[41];
- SInt16 xMin = static_cast<SInt16>(uxMin);
- SInt16 xMax = static_cast<SInt16>(uxMax);
- float diff = static_cast<float>(xMax - xMin);
- m_maxCharWidth = scaleEmToUnits(diff, m_fontMetrics.unitsPerEm()) * m_platformData.m_size;
- }
-
- // Fallback to a cross-platform estimate, which will populate these values if they are non-positive.
- initCharWidths();
-}
-#endif // USE(APPKIT)
-
-void Font::platformDestroy()
-{
-}
-
-#if !PLATFORM(IOS)
-PassRefPtr<Font> Font::platformCreateScaledFont(const FontDescription&, float scaleFactor) const
-{
- if (isCustomFont()) {
- FontPlatformData scaledFontData(m_platformData);
- scaledFontData.m_size = scaledFontData.m_size * scaleFactor;
- return Font::create(scaledFontData, true, false);
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- float size = m_platformData.size() * scaleFactor;
- FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toSize:size], size, false, false, m_platformData.orientation());
-
- // AppKit resets the type information (screen/printer) when you convert a font to a different size.
- // We have to fix up the font that we're handed back.
- scaledFontData.setNSFont([scaledFontData.nsFont() printerFont]);
-
- if (scaledFontData.font()) {
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
- NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_platformData.nsFont()];
-
- if (m_platformData.m_syntheticBold)
- fontTraits |= NSBoldFontMask;
- if (m_platformData.m_syntheticOblique)
- fontTraits |= NSItalicFontMask;
-
- NSFontTraitMask scaledFontTraits = [fontManager traitsOfFont:scaledFontData.nsFont()];
- scaledFontData.m_syntheticBold = (fontTraits & NSBoldFontMask) && !(scaledFontTraits & NSBoldFontMask);
- scaledFontData.m_syntheticOblique = (fontTraits & NSItalicFontMask) && !(scaledFontTraits & NSItalicFontMask);
-
- return fontCache().fontForPlatformData(scaledFontData);
- }
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return 0;
-}
-
-void Font::determinePitch()
-{
- NSFont* f = m_platformData.nsFont();
- // Special case Osaka-Mono.
- // According to <rdar://problem/3999467>, we should treat Osaka-Mono as fixed pitch.
- // Note that the AppKit does not report Osaka-Mono as fixed pitch.
-
- // Special case MS-PGothic.
- // According to <rdar://problem/4032938>, we should not treat MS-PGothic as fixed pitch.
- // Note that AppKit does report MS-PGothic as fixed pitch.
-
- // Special case MonotypeCorsiva
- // According to <rdar://problem/5454704>, we should not treat MonotypeCorsiva as fixed pitch.
- // Note that AppKit does report MonotypeCorsiva as fixed pitch.
-
- NSString *name = [f fontName];
- m_treatAsFixedPitch = ([f isFixedPitch] || [f _isFakeFixedPitch] ||
- [name caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame) &&
- [name caseInsensitiveCompare:@"MS-PGothic"] != NSOrderedSame &&
- [name caseInsensitiveCompare:@"MonotypeCorsiva"] != NSOrderedSame;
-}
-#endif // !PLATFORM(IOS)
-
-FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
-{
- FloatRect boundingBox;
- boundingBox = CTFontGetBoundingRectsForGlyphs(m_platformData.ctFont(), platformData().orientation() == Vertical ? kCTFontVerticalOrientation : kCTFontHorizontalOrientation, &glyph, 0, 1);
- boundingBox.setY(-boundingBox.maxY());
- if (m_syntheticBoldOffset)
- boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset);
-
- return boundingBox;
-}
-
-#if PLATFORM(MAC)
-inline CGFontRenderingStyle Font::renderingStyle() const
-{
- CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization;
- NSFont *font = platformData().nsFont();
- if (font) {
- switch ([font renderingMode]) {
- case NSFontIntegerAdvancementsRenderingMode:
- style = 0;
- break;
- case NSFontAntialiasedIntegerAdvancementsRenderingMode:
- style = kCGFontRenderingStyleAntialiasing;
- break;
- default:
- break;
- }
- }
- return style;
-}
-
-inline bool Font::advanceForColorBitmapFont(Glyph glyph, CGSize& advance) const
-{
- NSFont *font = platformData().nsFont();
- if (!font || !platformData().isColorBitmapFont())
- return false;
- advance = NSSizeToCGSize([font advancementForGlyph:glyph]);
- return true;
-}
-#endif
-
-static bool hasCustomTracking(CTFontRef font)
-{
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
- UNUSED_PARAM(font);
- return false;
-#else
- return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());
-#endif
-}
-
-static inline bool isEmoji(const FontPlatformData& platformData)
-{
-#if PLATFORM(IOS)
- return platformData.m_isEmoji;
-#else
- UNUSED_PARAM(platformData);
- return false;
-#endif
-}
-
-inline bool Font::canUseFastGlyphAdvanceGetter(Glyph glyph, CGSize& advance, bool& populatedAdvance) const
-{
- // Fast getter doesn't take custom tracking into account
- if (hasCustomTracking(platformData().ctFont()))
- return false;
- // Fast getter doesn't work for emoji
- if (isEmoji(platformData()))
- return false;
- // ... or for any bitmap fonts in general
- if (advanceForColorBitmapFont(glyph, advance)) {
- populatedAdvance = true;
- return false;
- }
- return true;
-}
-
-float Font::platformWidthForGlyph(Glyph glyph) const
-{
- CGSize advance = CGSizeZero;
- bool horizontal = platformData().orientation() == Horizontal;
- bool populatedAdvance = false;
- if ((horizontal || m_isBrokenIdeographFallback) && canUseFastGlyphAdvanceGetter(glyph, advance, populatedAdvance)) {
- float pointSize = platformData().m_size;
- CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
- if (!CGFontGetGlyphAdvancesForStyle(platformData().cgFont(), &m, renderingStyle(), &glyph, 1, &advance)) {
- RetainPtr<CFStringRef> fullName = adoptCF(CGFontCopyFullName(platformData().cgFont()));
- LOG_ERROR("Unable to cache glyph widths for %@ %f", fullName.get(), pointSize);
- advance.width = 0;
- }
- } else if (!populatedAdvance)
- CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), horizontal ? kCTFontHorizontalOrientation : kCTFontVerticalOrientation, &glyph, &advance, 1);
-
- return advance.width + m_syntheticBoldOffset;
-}
-
-struct ProviderInfo {
- const UChar* characters;
- size_t length;
- CFDictionaryRef attributes;
-};
-
-static const UniChar* provideStringAndAttributes(CFIndex stringIndex, CFIndex* count, CFDictionaryRef* attributes, void* context)
-{
- ProviderInfo* info = static_cast<struct ProviderInfo*>(context);
- if (stringIndex < 0 || static_cast<size_t>(stringIndex) >= info->length)
- return 0;
-
- *count = info->length - stringIndex;
- *attributes = info->attributes;
- return info->characters + stringIndex;
-}
-
-bool Font::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
-{
- ASSERT(isMainThread());
-
- if (!m_combiningCharacterSequenceSupport)
- m_combiningCharacterSequenceSupport = std::make_unique<HashMap<String, bool>>();
-
- WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequenceSupport->add(String(characters, length), false);
- if (!addResult.isNewEntry)
- return addResult.iterator->value;
-
- RetainPtr<CFTypeRef> fontEqualityObject = platformData().objectForEqualityCheck();
-
- ProviderInfo info = { characters, length, getCFStringAttributes(0, platformData().orientation()) };
- RetainPtr<CTLineRef> line = adoptCF(CTLineCreateWithUniCharProvider(&provideStringAndAttributes, 0, &info));
-
- CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
- CFIndex runCount = CFArrayGetCount(runArray);
-
- for (CFIndex r = 0; r < runCount; r++) {
- CTRunRef ctRun = static_cast<CTRunRef>(CFArrayGetValueAtIndex(runArray, r));
- ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
- CFDictionaryRef runAttributes = CTRunGetAttributes(ctRun);
- CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttributes, kCTFontAttributeName));
- if (!CFEqual(fontEqualityObject.get(), FontPlatformData::objectForEqualityCheck(runFont).get()))
- return false;
- }
-
- addResult.iterator->value = true;
- return true;
-}
-
-} // namespace WebCore
</del></span></pre>
</div>
</div>
</body>
</html>