<!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>[204858] 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/204858">204858</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-08-23 14:11:20 -0700 (Tue, 23 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] Reduce uses of CGFonts
https://bugs.webkit.org/show_bug.cgi?id=160896

Reviewed by Darin Adler.

There are a few places where we unnecessarily use CGFonts instead of
CTFonts. We have had an ongoing effort throughout the past few years
of elliminating all of our uses of CGFonts, and this patch moves us
in that direction.

Most of the changes in this patch are straightforward (e.g.
CGFontGetUnitsPerEm() -&gt; CTFontGetUnitsPerEm()). However, there is
one notable change: from CGContextShowGlyphsWithAdvances() to
CTFontDrawGlyphs(). This migration does not cause a performance
regression.

No new tests because there is no behavior change.

* WebCore.xcodeproj/project.pbxproj: Delete unnecessary
FontServicesIOS files.
* platform/graphics/FontMetrics.h:
(WebCore::FontMetrics::xHeight): Migrate to Optional&lt;float&gt;
(WebCore::FontMetrics::setXHeight):
(WebCore::FontMetrics::hasXHeight):
(WebCore::FontMetrics::hasCapHeight): Ditto.
(WebCore::FontMetrics::floatCapHeight):
(WebCore::FontMetrics::setCapHeight):
(WebCore::FontMetrics::capHeight):
(WebCore::FontMetrics::setZeroWidth): No one ever used the
m_hasZeroWidth variable, so this patch removes it.
(WebCore::FontMetrics::reset):
(WebCore::FontMetrics::FontMetrics): Deleted.
(WebCore::FontMetrics::setHasXHeight): Deleted. No one ever calls
this, so this patch removes it.
(WebCore::FontMetrics::hasZeroWidth): Deleted.
(WebCore::FontMetrics::setHasZeroWidth): Deleted.
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::TextMatrixRestorer::TextMatrixRestorer): Rather than leaving
the text matrix stale after using it, this class cleans it up after us.
This means that the text matrix doesn't have to be reset in other places
which draw text.
(WebCore::TextMatrixRestorer::~TextMatrixRestorer):
(WebCore::TextMatrixRestorer::savedMatrix):
(WebCore::showGlyphsWithAdvances): Migrate from
CGContextShowGlyphsWithAdvances() to CTFontDrawGlyphs()
(WebCore::FontCascade::drawGlyphs): See above comment about the text
matrix.
(WebCore::RenderingStyleSaver::RenderingStyleSaver): Deleted.
(WebCore::RenderingStyleSaver::~RenderingStyleSaver): Deleted.
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::shouldUseAdjustment): Taken from FontServicesIOS.
(WebCore::Font::platformInit): Migrate from CG to CT for some direct
replacement API calls.
(WebCore::Font::platformCharWidthInit): Ditto.
(WebCore::Font::determinePitch): Ditto.
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::openTypeTable): Ditto.
(WebCore::FontPlatformData::description): Ditto.
* platform/graphics/ios/FontServicesIOS.h: Removed. No longer needed
after migrating from CGContextShowGlyphsWithAdvances() to
CTFontDrawGlyphs().
(WebCore::FontServicesIOS::ascent): Deleted.
(WebCore::FontServicesIOS::descent): Deleted.
(WebCore::FontServicesIOS::lineGap): Deleted.
(WebCore::FontServicesIOS::lineSpacing): Deleted.
(WebCore::FontServicesIOS::xHeight): Deleted.
(WebCore::FontServicesIOS::capHeight): Deleted.
(WebCore::FontServicesIOS::unitsPerEm): Deleted.
* platform/graphics/ios/FontServicesIOS.mm: Removed. Moved into
Font::platformInit().
(WebCore::shouldUseAdjustment): Deleted.
(WebCore::isCourier): Deleted.
(WebCore::FontServicesIOS::FontServicesIOS): Deleted.
* platform/graphics/opentype/OpenTypeCG.cpp:
(WebCore::OpenType::tryGetTypoMetrics): Migrate from CG to CT for some
direct replacement API calls.
* platform/graphics/opentype/OpenTypeCG.h: Ditto.
* platform/graphics/win/FontCGWin.cpp:
(WebCore::FontCascade::drawGlyphs): Restore the text matrix.
* platform/graphics/win/SimpleFontDataCGWin.cpp:
(WebCore::Font::platformWidthForGlyph): Deleted.
* platform/spi/cg/CoreGraphicsSPI.h:
* platform/spi/cocoa/CoreTextSPI.h:
* rendering/RenderThemeIOS.mm:
(WebCore::paintAttachmentText): Deleted.
* rendering/RenderThemeMac.mm:
(WebCore::paintAttachmentTitle): Deleted.
(WebCore::paintAttachmentSubtitle): Deleted.</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="#trunkSourceWebCoreplatformgraphicsFontMetricsh">trunk/Source/WebCore/platform/graphics/FontMetrics.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontPlatformDatah">trunk/Source/WebCore/platform/graphics/FontPlatformData.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontPlatformDataCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopentypeOpenTypeCGcpp">trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopentypeOpenTypeCGh">trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCGWincpp">trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinSimpleFontDataCGWincpp">trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformspicgCoreGraphicsSPIh">trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h</a></li>
<li><a href="#trunkSourceWebCoreplatformspicocoaCoreTextSPIh">trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h</a></li>
<li><a href="#trunkSourceWebCoreplatformspiwinCoreTextSPIWinh">trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderThemeIOSmm">trunk/Source/WebCore/rendering/RenderThemeIOS.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderThemeMacmm">trunk/Source/WebCore/rendering/RenderThemeMac.mm</a></li>
<li><a href="#trunkSourceWebCoresvgSVGFontFaceElementcpp">trunk/Source/WebCore/svg/SVGFontFaceElement.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsiosFontServicesIOSh">trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsiosFontServicesIOSmm">trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/ChangeLog        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -1,3 +1,94 @@
</span><ins>+2016-08-23  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Reduce uses of CGFonts
+        https://bugs.webkit.org/show_bug.cgi?id=160896
+
+        Reviewed by Darin Adler.
+
+        There are a few places where we unnecessarily use CGFonts instead of
+        CTFonts. We have had an ongoing effort throughout the past few years
+        of elliminating all of our uses of CGFonts, and this patch moves us
+        in that direction.
+
+        Most of the changes in this patch are straightforward (e.g.
+        CGFontGetUnitsPerEm() -&gt; CTFontGetUnitsPerEm()). However, there is
+        one notable change: from CGContextShowGlyphsWithAdvances() to
+        CTFontDrawGlyphs(). This migration does not cause a performance
+        regression.
+
+        No new tests because there is no behavior change.
+
+        * WebCore.xcodeproj/project.pbxproj: Delete unnecessary
+        FontServicesIOS files.
+        * platform/graphics/FontMetrics.h:
+        (WebCore::FontMetrics::xHeight): Migrate to Optional&lt;float&gt;
+        (WebCore::FontMetrics::setXHeight):
+        (WebCore::FontMetrics::hasXHeight):
+        (WebCore::FontMetrics::hasCapHeight): Ditto.
+        (WebCore::FontMetrics::floatCapHeight):
+        (WebCore::FontMetrics::setCapHeight):
+        (WebCore::FontMetrics::capHeight):
+        (WebCore::FontMetrics::setZeroWidth): No one ever used the
+        m_hasZeroWidth variable, so this patch removes it.
+        (WebCore::FontMetrics::reset):
+        (WebCore::FontMetrics::FontMetrics): Deleted.
+        (WebCore::FontMetrics::setHasXHeight): Deleted. No one ever calls
+        this, so this patch removes it.
+        (WebCore::FontMetrics::hasZeroWidth): Deleted.
+        (WebCore::FontMetrics::setHasZeroWidth): Deleted.
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::TextMatrixRestorer::TextMatrixRestorer): Rather than leaving
+        the text matrix stale after using it, this class cleans it up after us.
+        This means that the text matrix doesn't have to be reset in other places
+        which draw text.
+        (WebCore::TextMatrixRestorer::~TextMatrixRestorer):
+        (WebCore::TextMatrixRestorer::savedMatrix):
+        (WebCore::showGlyphsWithAdvances): Migrate from
+        CGContextShowGlyphsWithAdvances() to CTFontDrawGlyphs()
+        (WebCore::FontCascade::drawGlyphs): See above comment about the text
+        matrix.
+        (WebCore::RenderingStyleSaver::RenderingStyleSaver): Deleted.
+        (WebCore::RenderingStyleSaver::~RenderingStyleSaver): Deleted.
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::shouldUseAdjustment): Taken from FontServicesIOS.
+        (WebCore::Font::platformInit): Migrate from CG to CT for some direct
+        replacement API calls.
+        (WebCore::Font::platformCharWidthInit): Ditto.
+        (WebCore::Font::determinePitch): Ditto.
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::openTypeTable): Ditto.
+        (WebCore::FontPlatformData::description): Ditto.
+        * platform/graphics/ios/FontServicesIOS.h: Removed. No longer needed
+        after migrating from CGContextShowGlyphsWithAdvances() to
+        CTFontDrawGlyphs().
+        (WebCore::FontServicesIOS::ascent): Deleted.
+        (WebCore::FontServicesIOS::descent): Deleted.
+        (WebCore::FontServicesIOS::lineGap): Deleted.
+        (WebCore::FontServicesIOS::lineSpacing): Deleted.
+        (WebCore::FontServicesIOS::xHeight): Deleted.
+        (WebCore::FontServicesIOS::capHeight): Deleted.
+        (WebCore::FontServicesIOS::unitsPerEm): Deleted.
+        * platform/graphics/ios/FontServicesIOS.mm: Removed. Moved into
+        Font::platformInit().
+        (WebCore::shouldUseAdjustment): Deleted.
+        (WebCore::isCourier): Deleted.
+        (WebCore::FontServicesIOS::FontServicesIOS): Deleted.
+        * platform/graphics/opentype/OpenTypeCG.cpp:
+        (WebCore::OpenType::tryGetTypoMetrics): Migrate from CG to CT for some
+        direct replacement API calls.
+        * platform/graphics/opentype/OpenTypeCG.h: Ditto.
+        * platform/graphics/win/FontCGWin.cpp:
+        (WebCore::FontCascade::drawGlyphs): Restore the text matrix.
+        * platform/graphics/win/SimpleFontDataCGWin.cpp:
+        (WebCore::Font::platformWidthForGlyph): Deleted.
+        * platform/spi/cg/CoreGraphicsSPI.h:
+        * platform/spi/cocoa/CoreTextSPI.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::paintAttachmentText): Deleted.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::paintAttachmentTitle): Deleted.
+        (WebCore::paintAttachmentSubtitle): Deleted.
+
</ins><span class="cx"> 2016-08-23  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix CMake build after r204852.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -5440,8 +5440,6 @@
</span><span class="cx">                 C55C7BA11718AFBA001327E4 /* RenderThemeIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = C55C7BA01718AFBA001327E4 /* RenderThemeIOS.mm */; };
</span><span class="cx">                 C572EE1F1201C9BC007D8F82 /* JSIDBIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = C572EE1D1201C9BC007D8F82 /* JSIDBIndex.h */; };
</span><span class="cx">                 C57FEDE11212EE9C0097BE65 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C57FEDE01212EE9C0097BE65 /* FileSystem.cpp */; };
</span><del>-                C58361A91744523F00173511 /* FontServicesIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = C58361A71744523F00173511 /* FontServicesIOS.h */; };
-                C58361AA1744523F00173511 /* FontServicesIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = C58361A81744523F00173511 /* FontServicesIOS.mm */; };
</del><span class="cx">                 C585A66211D4FAC5004C3E4B /* IDBBindingUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C585A66011D4FAC5004C3E4B /* IDBBindingUtilities.cpp */; };
</span><span class="cx">                 C585A66311D4FAC5004C3E4B /* IDBBindingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = C585A66111D4FAC5004C3E4B /* IDBBindingUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 C585A68311D4FB08004C3E4B /* JSIDBDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = C585A66B11D4FB07004C3E4B /* JSIDBDatabase.h */; };
</span><span class="lines">@@ -12885,8 +12883,6 @@
</span><span class="cx">                 C55C7BA01718AFBA001327E4 /* RenderThemeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderThemeIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C572EE1D1201C9BC007D8F82 /* JSIDBIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIDBIndex.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C57FEDE01212EE9C0097BE65 /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                C58361A71744523F00173511 /* FontServicesIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontServicesIOS.h; sourceTree = &quot;&lt;group&gt;&quot;; };
-                C58361A81744523F00173511 /* FontServicesIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FontServicesIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 C585A66011D4FAC5004C3E4B /* IDBBindingUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBBindingUtilities.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C585A66111D4FAC5004C3E4B /* IDBBindingUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBBindingUtilities.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C585A66B11D4FB07004C3E4B /* JSIDBDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIDBDatabase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16019,8 +16015,6 @@
</span><span class="cx">                                 0F97A657155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm */,
</span><span class="cx">                                 1AC2D89C1B1E291F00D52E87 /* FontAntialiasingStateSaver.h */,
</span><span class="cx">                                 3727DFD4142AAE4500D449CB /* FontCacheIOS.mm */,
</span><del>-                                C58361A71744523F00173511 /* FontServicesIOS.h */,
-                                C58361A81744523F00173511 /* FontServicesIOS.mm */,
</del><span class="cx">                                 31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */,
</span><span class="cx">                                 FED13D3F0CEA939400D89466 /* IconIOS.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -24332,7 +24326,6 @@
</span><span class="cx">                                 371F4FFC0D25E7F300ECE0D5 /* FontRanges.h in Headers */,
</span><span class="cx">                                 B2C3DA6B0D006CD600EF6F26 /* FontSelector.h in Headers */,
</span><span class="cx">                                 E419041F1CC6486B00C35F5D /* FontSelectorClient.h in Headers */,
</span><del>-                                C58361A91744523F00173511 /* FontServicesIOS.h in Headers */,
</del><span class="cx">                                 C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */,
</span><span class="cx">                                 4A0DA2FF129B241900AB61E1 /* FormAssociatedElement.h in Headers */,
</span><span class="cx">                                 D05CED2A0A40BB2C00C5AF38 /* FormatBlockCommand.h in Headers */,
</span><span class="lines">@@ -27949,7 +27942,6 @@
</span><span class="cx">                                 84B62685133138F90095A489 /* FontPlatformData.cpp in Sources */,
</span><span class="cx">                                 B5320D6C122A24E9002D1440 /* FontPlatformDataCocoa.mm in Sources */,
</span><span class="cx">                                 371F4FFD0D25E7F300ECE0D5 /* FontRanges.cpp in Sources */,
</span><del>-                                C58361AA1744523F00173511 /* FontServicesIOS.mm in Sources */,
</del><span class="cx">                                 1C3249111C6D6A3B007EDB32 /* FontVariantBuilder.cpp in Sources */,
</span><span class="cx">                                 4A0DA2FE129B241900AB61E1 /* FormAssociatedElement.cpp in Sources */,
</span><span class="cx">                                 D05CED290A40BB2C00C5AF38 /* FormatBlockCommand.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontMetricsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontMetrics.h (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontMetrics.h        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/FontMetrics.h        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -22,25 +22,13 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;FontBaseline.h&quot;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-const unsigned gDefaultUnitsPerEm = 1000;
-
</del><span class="cx"> class FontMetrics {
</span><span class="cx"> public:
</span><del>-    FontMetrics()
-        : m_unitsPerEm(gDefaultUnitsPerEm)
-        , m_ascent(0)
-        , m_descent(0)
-        , m_lineGap(0)
-        , m_lineSpacing(0)
-        , m_xHeight(0)
-        , m_zeroWidth(0)
-        , m_hasXHeight(false)
-        , m_hasZeroWidth(false)
-    {
-    }
</del><ins>+    static const unsigned defaultUnitsPerEm = 1000;
</ins><span class="cx"> 
</span><span class="cx">     unsigned unitsPerEm() const { return m_unitsPerEm; }
</span><span class="cx">     void setUnitsPerEm(unsigned unitsPerEm) { m_unitsPerEm = unitsPerEm; }
</span><span class="lines">@@ -75,22 +63,12 @@
</span><span class="cx">     void setLineSpacing(float lineSpacing) { m_lineSpacing = lineSpacing; }
</span><span class="cx"> 
</span><span class="cx">     float xHeight() const { return m_xHeight; }
</span><del>-    void setXHeight(float xHeight) 
-    { 
-        m_xHeight = xHeight;
-        m_hasXHeight = true;
-    }
-
-    bool hasXHeight() const { return m_hasXHeight &amp;&amp; m_xHeight &gt; 0; }
-    void setHasXHeight(bool hasXHeight) { m_hasXHeight = hasXHeight; }
</del><ins>+    void setXHeight(float xHeight) { m_xHeight = xHeight; }
+    bool hasXHeight() const { return m_xHeight &gt; 0; }
</ins><span class="cx">     
</span><del>-    bool hasCapHeight() const { return m_hasCapHeight &amp;&amp; m_capHeight &gt; 0; }
</del><ins>+    bool hasCapHeight() const { return m_capHeight &gt; 0; }
</ins><span class="cx">     float floatCapHeight() const { return m_capHeight; }
</span><del>-    void setCapHeight(float capHeight)
-    { 
-        m_capHeight = capHeight;
-        m_hasCapHeight = true;
-    }
</del><ins>+    void setCapHeight(float capHeight) { m_capHeight = capHeight; }
</ins><span class="cx">     
</span><span class="cx">     // Integer variants of certain metrics, used for HTML rendering.
</span><span class="cx">     int ascent(FontBaseline baselineType = AlphabeticBaseline) const
</span><span class="lines">@@ -123,40 +101,31 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     float zeroWidth() const { return m_zeroWidth; }
</span><del>-    void setZeroWidth(float zeroWidth)
-    {
-        m_zeroWidth = zeroWidth;
-        m_hasZeroWidth = true;
-    }
</del><ins>+    void setZeroWidth(float zeroWidth) { m_zeroWidth = zeroWidth; }
</ins><span class="cx"> 
</span><del>-    bool hasZeroWidth() const { return m_hasZeroWidth; }
-    void setHasZeroWidth(bool hasZeroWidth) { m_hasZeroWidth = hasZeroWidth; }
-
</del><span class="cx"> private:
</span><span class="cx">     friend class Font;
</span><span class="cx"> 
</span><span class="cx">     void reset()
</span><span class="cx">     {
</span><del>-        m_unitsPerEm = gDefaultUnitsPerEm;
</del><ins>+        m_unitsPerEm = defaultUnitsPerEm;
</ins><span class="cx">         m_ascent = 0;
</span><span class="cx">         m_descent = 0;
</span><span class="cx">         m_lineGap = 0;
</span><span class="cx">         m_lineSpacing = 0;
</span><span class="cx">         m_xHeight = 0;
</span><del>-        m_hasXHeight = false;
</del><ins>+        m_capHeight = 0;
+        m_zeroWidth = 0;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned m_unitsPerEm;
-    float m_ascent;
-    float m_descent;
-    float m_lineGap;
-    float m_lineSpacing;
-    float m_xHeight;
-    float m_capHeight;
-    float m_zeroWidth;
-    bool m_hasXHeight;
-    bool m_hasCapHeight;
-    bool m_hasZeroWidth;
</del><ins>+    unsigned m_unitsPerEm { defaultUnitsPerEm };
+    float m_ascent { 0 };
+    float m_descent { 0 };
+    float m_lineGap { 0 };
+    float m_lineSpacing { 0 };
+    float m_zeroWidth { 0 };
+    float m_xHeight { 0 };
+    float m_capHeight { 0 };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> static inline float scaleEmToUnits(float x, unsigned unitsPerEm)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontPlatformDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -44,9 +44,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-#if PLATFORM(IOS)
-#import &lt;CoreGraphics/CoreGraphics.h&gt;
-#endif
</del><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> OBJC_CLASS NSFont;
</span><span class="cx"> #endif
</span><span class="lines">@@ -56,7 +53,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><del>-typedef struct CGFont* CGFontRef;
</del><ins>+#include &lt;CoreGraphics/CoreGraphics.h&gt;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="lines">@@ -292,6 +289,32 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(CG)
+class ScopedTextMatrix {
+public:
+    ScopedTextMatrix(CGAffineTransform newMatrix, CGContextRef context)
+        : m_context(context)
+        , m_textMatrix(CGContextGetTextMatrix(context))
+    {
+        CGContextSetTextMatrix(m_context, newMatrix);
+    }
+
+    ~ScopedTextMatrix()
+    {
+        CGContextSetTextMatrix(m_context, m_textMatrix);
+    }
+
+    CGAffineTransform savedMatrix() const
+    {
+        return m_textMatrix;
+    }
+
+private:
+    CGContextRef m_context;
+    CGAffineTransform m_textMatrix;
+};
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // FontPlatformData_h
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -131,33 +131,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-class RenderingStyleSaver {
-public:
-#if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED &lt;= 101000
-    RenderingStyleSaver(CTFontRef, CGContextRef) { }
-#else
-    RenderingStyleSaver(CTFontRef font, CGContextRef context)
-        : m_context(context)
-    {
-        m_changed = CTFontSetRenderingStyle(font, context, &amp;m_originalStyle, &amp;m_originalDilation);
-    }
-
-    ~RenderingStyleSaver()
-    {
-        if (!m_changed)
-            return;
-        CGContextSetFontRenderingStyle(m_context, m_originalStyle);
-        CGContextSetFontDilation(m_context, m_originalDilation);
-    }
-
-private:
-    bool m_changed;
-    CGContextRef m_context;
-    CGFontRenderingStyle m_originalStyle;
-    CGSize m_originalDilation;
-#endif
-};
-
</del><span class="cx"> static void showGlyphsWithAdvances(const FloatPoint&amp; point, const Font&amp; font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, unsigned count)
</span><span class="cx"> {
</span><span class="cx">     if (!count)
</span><span class="lines">@@ -167,13 +140,10 @@
</span><span class="cx"> 
</span><span class="cx">     const FontPlatformData&amp; platformData = font.platformData();
</span><span class="cx">     Vector&lt;CGPoint, 256&gt; positions(count);
</span><del>-    if (platformData.isColorBitmapFont())
-        fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);
</del><span class="cx">     if (platformData.orientation() == Vertical) {
</span><del>-        CGAffineTransform savedMatrix;
</del><span class="cx">         CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
</span><del>-        savedMatrix = CGContextGetTextMatrix(context);
-        CGAffineTransform runMatrix = CGAffineTransformConcat(savedMatrix, rotateLeftTransform);
</del><ins>+        CGAffineTransform textMatrix = CGContextGetTextMatrix(context);
+        CGAffineTransform runMatrix = CGAffineTransformConcat(textMatrix, rotateLeftTransform);
</ins><span class="cx">         CGContextSetTextMatrix(context, runMatrix);
</span><span class="cx"> 
</span><span class="cx">         Vector&lt;CGSize, 256&gt; translations(count);
</span><span class="lines">@@ -188,21 +158,10 @@
</span><span class="cx">             position.x += advances[i].width;
</span><span class="cx">             position.y += advances[i].height;
</span><span class="cx">         }
</span><del>-        if (!platformData.isColorBitmapFont()) {
-            RenderingStyleSaver saver(platformData.ctFont(), context);
-            CGContextShowGlyphsAtPositions(context, glyphs, positions.data(), count);
-        } else
-            CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
-        CGContextSetTextMatrix(context, savedMatrix);
</del><ins>+        CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
</ins><span class="cx">     } else {
</span><del>-        if (!platformData.isColorBitmapFont()) {
-            RenderingStyleSaver saver(platformData.ctFont(), context);
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
-            CGContextShowGlyphsWithAdvances(context, glyphs, advances, count);
-#pragma clang diagnostic pop
-        } else
-            CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
</del><ins>+        fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);
+        CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -270,8 +229,6 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    CGContextSetFont(cgContext, platformData.cgFont());
-
</del><span class="cx">     bool useLetterpressEffect = shouldUseLetterpressEffect(context);
</span><span class="cx">     FloatPoint point = anchorPoint;
</span><span class="cx"> 
</span><span class="lines">@@ -287,7 +244,7 @@
</span><span class="cx">         else
</span><span class="cx">             matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -obliqueSkew, 1, 0, 0));
</span><span class="cx">     }
</span><del>-    CGContextSetTextMatrix(cgContext, matrix);
</del><ins>+    ScopedTextMatrix restorer(matrix, cgContext);
</ins><span class="cx"> 
</span><span class="cx">     setCGFontRenderingMode(context);
</span><span class="cx">     CGContextSetFontSize(cgContext, platformData.size());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #import &quot;FontCache.h&quot;
</span><span class="cx"> #import &quot;FontCascade.h&quot;
</span><span class="cx"> #import &quot;FontDescription.h&quot;
</span><ins>+#import &quot;OpenTypeCG.h&quot;
</ins><span class="cx"> #import &quot;SharedBuffer.h&quot;
</span><span class="cx"> #import &quot;WebCoreSystemInterface.h&quot;
</span><span class="cx"> #import &lt;float.h&gt;
</span><span class="lines">@@ -46,7 +47,6 @@
</span><span class="cx"> #import &lt;AppKit/AppKit.h&gt;
</span><span class="cx"> #import &lt;ApplicationServices/ApplicationServices.h&gt;
</span><span class="cx"> #else
</span><del>-#import &quot;FontServicesIOS.h&quot;
</del><span class="cx"> #import &lt;CoreText/CoreText.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -56,12 +56,13 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(APPKIT)
-#import &quot;OpenTypeCG.h&quot;
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static inline bool caseInsensitiveCompare(CFStringRef a, CFStringRef b)
+{
+    return a &amp;&amp; CFStringCompare(a, b, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
+}
+
</ins><span class="cx"> static bool fontHasVerticalGlyphs(CTFontRef ctFont)
</span><span class="cx"> {
</span><span class="cx">     // The check doesn't look neat but this is what AppKit does for vertical writing...
</span><span class="lines">@@ -77,7 +78,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !USE(APPKIT)
</del><ins>+#if PLATFORM(IOS)
</ins><span class="cx"> bool fontFamilyShouldNotBeUsedForArabic(CFStringRef fontFamilyName)
</span><span class="cx"> {
</span><span class="cx">     if (!fontFamilyName)
</span><span class="lines">@@ -88,13 +89,39 @@
</span><span class="cx">     return (CFStringCompare(CFSTR(&quot;Times New Roman&quot;), fontFamilyName, 0) == kCFCompareEqualTo)
</span><span class="cx">         || (CFStringCompare(CFSTR(&quot;Arial&quot;), fontFamilyName, 0) == kCFCompareEqualTo);
</span><span class="cx"> }
</span><ins>+
+static const float kLineHeightAdjustment = 0.15f;
+
+static bool shouldUseAdjustment(CTFontRef font)
+{
+    RetainPtr&lt;CFStringRef&gt; familyName = adoptCF(CTFontCopyFamilyName(font));
+
+    if (!familyName || !CFStringGetLength(familyName.get()))
+        return false;
+
+    return caseInsensitiveCompare(familyName.get(), CFSTR(&quot;Times&quot;))
+        || caseInsensitiveCompare(familyName.get(), CFSTR(&quot;Helvetica&quot;))
+        || caseInsensitiveCompare(familyName.get(), CFSTR(&quot;.Helvetica NeueUI&quot;));
+}
+
+#else
+
+static bool needsAscentAdjustment(CFStringRef familyName)
+{
+    return familyName &amp;&amp; (caseInsensitiveCompare(familyName, CFSTR(&quot;Times&quot;))
+        || caseInsensitiveCompare(familyName, CFSTR(&quot;Helvetica&quot;))
+        || caseInsensitiveCompare(familyName, CFSTR(&quot;Courier&quot;)));
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void Font::platformInit()
</span><span class="cx"> {
</span><del>-    // FIXME: Unify these two codepaths
-#if USE(APPKIT)
</del><ins>+#if PLATFORM(IOS)
+    m_syntheticBoldOffset = m_platformData.syntheticBold() ? ceilf(m_platformData.size() / 24.0f) : 0.f;
+#else
</ins><span class="cx">     m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101100
</span><span class="cx">     // Work around &lt;rdar://problem/19433490&gt;
</span><span class="lines">@@ -103,16 +130,17 @@
</span><span class="cx">     CTFontTransformGlyphs(m_platformData.ctFont(), dummyGlyphs, dummySize, 2, kCTFontTransformApplyPositioning | kCTFontTransformApplyShaping);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    unsigned unitsPerEm = CGFontGetUnitsPerEm(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.
</del><ins>+    unsigned unitsPerEm = CTFontGetUnitsPerEm(m_platformData.font());
</ins><span class="cx">     float pointSize = m_platformData.size();
</span><ins>+    float capHeight = CTFontGetCapHeight(m_platformData.font());
+    float lineGap = CTFontGetLeading(m_platformData.font());
+#if PLATFORM(IOS)
+    CGFloat ascent = CTFontGetAscent(m_platformData.font());
+    CGFloat descent = CTFontGetDescent(m_platformData.font());
+#else
</ins><span class="cx">     float ascent = scaleEmToUnits(CGFontGetAscent(m_platformData.cgFont()), unitsPerEm) * pointSize;
</span><span class="cx">     float descent = -scaleEmToUnits(-abs(CGFontGetDescent(m_platformData.cgFont())), unitsPerEm) * pointSize;
</span><del>-    float capHeight = scaleEmToUnits(CGFontGetCapHeight(m_platformData.cgFont()), unitsPerEm) * pointSize;
-    
-    float lineGap = scaleEmToUnits(CGFontGetLeading(m_platformData.cgFont()), unitsPerEm) * pointSize;
</del><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
</span><span class="cx">     // &quot;If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font.&quot;
</span><span class="lines">@@ -119,7 +147,7 @@
</span><span class="cx">     // On OS X, we only apply this rule in the important case of fonts with a MATH table.
</span><span class="cx">     if (OpenType::fontHasMathTable(m_platformData.ctFont())) {
</span><span class="cx">         short typoAscent, typoDescent, typoLineGap;
</span><del>-        if (OpenType::tryGetTypoMetrics(m_platformData.cgFont(), typoAscent, typoDescent, typoLineGap)) {
</del><ins>+        if (OpenType::tryGetTypoMetrics(m_platformData.font(), typoAscent, typoDescent, typoLineGap)) {
</ins><span class="cx">             ascent = scaleEmToUnits(typoAscent, unitsPerEm) * pointSize;
</span><span class="cx">             descent = -scaleEmToUnits(typoDescent, unitsPerEm) * pointSize;
</span><span class="cx">             lineGap = scaleEmToUnits(typoLineGap, unitsPerEm) * pointSize;
</span><span class="lines">@@ -126,20 +154,21 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    auto familyName = adoptCF(CTFontCopyFamilyName(m_platformData.font()));
+#if PLATFORM(MAC)
</ins><span class="cx">     // We need to adjust Times, Helvetica, and Courier to closely match the
</span><span class="cx">     // vertical metrics of their Microsoft counterparts that are the de facto
</span><span class="cx">     // web standard. The AppKit adjustment of 20% is too big and is
</span><span class="cx">     // incorrectly added to line spacing, so we use a 15% adjustment instead
</span><span class="cx">     // and add it to the ascent.
</span><del>-    RetainPtr&lt;CFStringRef&gt; familyName = adoptCF(CTFontCopyFamilyName(m_platformData.font()));
-    if (!m_isCustomFont &amp;&amp; familyName &amp;&amp; (CFStringCompare(familyName.get(), CFSTR(&quot;Times&quot;), kCFCompareCaseInsensitive) == kCFCompareEqualTo
-        || CFStringCompare(familyName.get(), CFSTR(&quot;Helvetica&quot;), kCFCompareCaseInsensitive) == kCFCompareEqualTo
-        || CFStringCompare(familyName.get(), CFSTR(&quot;Courier&quot;), kCFCompareCaseInsensitive) == kCFCompareEqualTo))
-        ascent += floorf(((ascent + descent) * 0.15f) + 0.5f);
</del><ins>+    if (!m_isCustomFont &amp;&amp; needsAscentAdjustment(familyName.get()))
+        ascent += std::round((ascent + descent) * 0.15f);
+#endif
</ins><span class="cx"> 
</span><del>-    // Compute and store line spacing, before the line metrics hacks are applied.
-    m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
</del><ins>+    // Compute line spacing before the line metrics hacks are applied.
+    float lineSpacing = lroundf(ascent) + lroundf(descent) + lroundf(lineGap);
</ins><span class="cx"> 
</span><ins>+#if !PLATFORM(IOS)
</ins><span class="cx">     // Hack Hiragino line metrics to allow room for marked text underlines.
</span><span class="cx">     // &lt;rdar://problem/5386183&gt;
</span><span class="cx">     if (descent &lt; 3 &amp;&amp; lineGap &gt;= 3 &amp;&amp; familyName &amp;&amp; CFStringHasPrefix(familyName.get(), CFSTR(&quot;Hiragino&quot;))) {
</span><span class="lines">@@ -146,12 +175,24 @@
</span><span class="cx">         lineGap -= 3 - descent;
</span><span class="cx">         descent = 3;
</span><span class="cx">     }
</span><ins>+#endif
</ins><span class="cx">     
</span><span class="cx">     if (platformData().orientation() == Vertical &amp;&amp; !isTextOrientationFallback())
</span><span class="cx">         m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+    CGFloat adjustment = shouldUseAdjustment(m_platformData.font()) ? ceil((ascent + descent) * kLineHeightAdjustment) : 0;
+
+    CGFontDescriptor descriptor;
+    float xHeight = CGFontGetDescriptor(m_platformData.cgFont(), &amp;descriptor) ? (descriptor.xHeight / 1000) * CTFontGetSize(m_platformData.font()) : 0;
+    lineGap = ceilf(lineGap);
+    lineSpacing = ceil(ascent) + adjustment + ceil(descent) + lineGap;
+    ascent = ceilf(ascent + adjustment);
+    descent = ceilf(descent);
+
+    m_shouldNotBeUsedForArabic = fontFamilyShouldNotBeUsedForArabic(adoptCF(CTFontCopyFamilyName(m_platformData.font())).get());
+#else
</ins><span class="cx">     float xHeight;
</span><del>-
</del><span class="cx">     if (platformData().orientation() == Horizontal) {
</span><span class="cx">         // Measure the actual character &quot;x&quot;, since it's possible for it to extend below the baseline, and we need the
</span><span class="cx">         // reported x-height to only include the portion of the glyph that is above the baseline.
</span><span class="lines">@@ -159,9 +200,10 @@
</span><span class="cx">         if (xGlyph)
</span><span class="cx">             xHeight = -CGRectGetMinY(platformBoundsForGlyph(xGlyph));
</span><span class="cx">         else
</span><del>-            xHeight = scaleEmToUnits(CGFontGetXHeight(m_platformData.cgFont()), unitsPerEm) * pointSize;
</del><ins>+            xHeight = CTFontGetXHeight(m_platformData.font());
</ins><span class="cx">     } else
</span><span class="cx">         xHeight = verticalRightOrientationFont().fontMetrics().xHeight();
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     m_fontMetrics.setUnitsPerEm(unitsPerEm);
</span><span class="cx">     m_fontMetrics.setAscent(ascent);
</span><span class="lines">@@ -169,25 +211,7 @@
</span><span class="cx">     m_fontMetrics.setCapHeight(capHeight);
</span><span class="cx">     m_fontMetrics.setLineGap(lineGap);
</span><span class="cx">     m_fontMetrics.setXHeight(xHeight);
</span><del>-
-#else
-
-    m_syntheticBoldOffset = m_platformData.syntheticBold() ? ceilf(m_platformData.size()  / 24.0f) : 0.f;
-
-    CTFontRef ctFont = m_platformData.font();
-    FontServicesIOS fontService(ctFont);
-    m_fontMetrics.setUnitsPerEm(fontService.unitsPerEm());
-    m_fontMetrics.setAscent(ceilf(fontService.ascent()));
-    m_fontMetrics.setDescent(ceilf(fontService.descent()));
-    m_fontMetrics.setLineGap(fontService.lineGap());
-    m_fontMetrics.setLineSpacing(fontService.lineSpacing());
-    m_fontMetrics.setXHeight(fontService.xHeight());
-    m_fontMetrics.setCapHeight(fontService.capHeight());
-    m_shouldNotBeUsedForArabic = fontFamilyShouldNotBeUsedForArabic(adoptCF(CTFontCopyFamilyName(ctFont)).get());
-
-    if (platformData().orientation() == Vertical &amp;&amp; !isTextOrientationFallback())
-        m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
-#endif
</del><ins>+    m_fontMetrics.setLineSpacing(lineSpacing);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Font::platformCharWidthInit()
</span><span class="lines">@@ -196,7 +220,7 @@
</span><span class="cx">     m_maxCharWidth = 0;
</span><span class="cx">     
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    RetainPtr&lt;CFDataRef&gt; os2Table = adoptCF(CGFontCopyTableForTag(m_platformData.cgFont(), 'OS/2'));
</del><ins>+    auto os2Table = adoptCF(CTFontCopyTable(m_platformData.font(), kCTFontTableOS2, kCTFontTableOptionNoOptions));
</ins><span class="cx">     if (os2Table &amp;&amp; CFDataGetLength(os2Table.get()) &gt;= 4) {
</span><span class="cx">         const UInt8* os2 = CFDataGetBytePtr(os2Table.get());
</span><span class="cx">         SInt16 os2AvgCharWidth = os2[2] * 256 + os2[3];
</span><span class="lines">@@ -203,7 +227,7 @@
</span><span class="cx">         m_avgCharWidth = scaleEmToUnits(os2AvgCharWidth, m_fontMetrics.unitsPerEm()) * m_platformData.size();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;CFDataRef&gt; headTable = adoptCF(CGFontCopyTableForTag(m_platformData.cgFont(), 'head'));
</del><ins>+    auto headTable = adoptCF(CTFontCopyTable(m_platformData.font(), kCTFontTableHead, kCTFontTableOptionNoOptions));
</ins><span class="cx">     if (headTable &amp;&amp; CFDataGetLength(headTable.get()) &gt;= 42) {
</span><span class="cx">         const UInt8* head = CFDataGetBytePtr(headTable.get());
</span><span class="cx">         ushort uxMin = head[36] * 256 + head[37];
</span><span class="lines">@@ -523,9 +547,12 @@
</span><span class="cx">     return createDerivativeFont(scaledFont.get(), size, m_platformData.orientation(), fontTraits, m_platformData.syntheticBold(), m_platformData.syntheticOblique());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline bool caseInsensitiveCompare(CFStringRef a, CFStringRef b)
</del><ins>+static int extractNumber(CFNumberRef number)
</ins><span class="cx"> {
</span><del>-    return a &amp;&amp; CFStringCompare(a, b, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
</del><ins>+    int result = 0;
+    if (number)
+        CFNumberGetValue(number, kCFNumberIntType, &amp;result);
+    return result;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Font::determinePitch()
</span><span class="lines">@@ -545,12 +572,13 @@
</span><span class="cx">     // According to &lt;rdar://problem/5454704&gt;, we should not treat MonotypeCorsiva as fixed pitch.
</span><span class="cx">     // Note that AppKit does report MonotypeCorsiva as fixed pitch.
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;CFStringRef&gt; fullName = adoptCF(CTFontCopyFullName(ctFont));
-    RetainPtr&lt;CFStringRef&gt; familyName = adoptCF(CTFontCopyFamilyName(ctFont));
</del><ins>+    auto fullName = adoptCF(CTFontCopyFullName(ctFont));
+    auto familyName = adoptCF(CTFontCopyFamilyName(ctFont));
</ins><span class="cx"> 
</span><del>-    m_treatAsFixedPitch = (CTFontGetSymbolicTraits(ctFont) &amp; kCTFontMonoSpaceTrait) || CGFontIsFixedPitch(m_platformData.cgFont()) || (caseInsensitiveCompare(fullName.get(), CFSTR(&quot;Osaka-Mono&quot;)) || caseInsensitiveCompare(fullName.get(), CFSTR(&quot;MS-PGothic&quot;)) || caseInsensitiveCompare(fullName.get(), CFSTR(&quot;MonotypeCorsiva&quot;)));
</del><ins>+    int fixedPitch = extractNumber(adoptCF(static_cast&lt;CFNumberRef&gt;(CTFontCopyAttribute(m_platformData.font(), kCTFontFixedAdvanceAttribute))).get());
+    m_treatAsFixedPitch = (CTFontGetSymbolicTraits(ctFont) &amp; kCTFontMonoSpaceTrait) || fixedPitch || (caseInsensitiveCompare(fullName.get(), CFSTR(&quot;Osaka-Mono&quot;)) || caseInsensitiveCompare(fullName.get(), CFSTR(&quot;MS-PGothic&quot;)) || caseInsensitiveCompare(fullName.get(), CFSTR(&quot;MonotypeCorsiva&quot;)));
</ins><span class="cx"> #if PLATFORM(IOS)
</span><del>-    if (familyName &amp;&amp; CFStringCompare(familyName.get(), CFSTR(&quot;Courier New&quot;), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
</del><ins>+    if (familyName &amp;&amp; caseInsensitiveCompare(familyName.get(), CFSTR(&quot;Courier New&quot;))) {
</ins><span class="cx">         // 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).
</span><span class="cx">         m_treatAsFixedPitch = false;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontPlatformDataCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -157,7 +157,7 @@
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;SharedBuffer&gt; FontPlatformData::openTypeTable(uint32_t table) const
</span><span class="cx"> {
</span><del>-    if (RetainPtr&lt;CFDataRef&gt; data = adoptCF(CGFontCopyTableForTag(cgFont(), table)))
</del><ins>+    if (RetainPtr&lt;CFDataRef&gt; data = adoptCF(CTFontCopyTable(font(), table, kCTFontTableOptionNoOptions)))
</ins><span class="cx">         return SharedBuffer::wrapCFData(data.get());
</span><span class="cx">     
</span><span class="cx">     return nullptr;
</span><span class="lines">@@ -166,8 +166,8 @@
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx"> String FontPlatformData::description() const
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;CFStringRef&gt; cgFontDescription = adoptCF(CFCopyDescription(cgFont()));
-    return String(cgFontDescription.get()) + &quot; &quot; + String::number(m_size)
</del><ins>+    auto fontDescription = adoptCF(CFCopyDescription(font()));
+    return String(fontDescription.get()) + &quot; &quot; + String::number(m_size)
</ins><span class="cx">             + (m_syntheticBold ? &quot; synthetic bold&quot; : &quot;&quot;) + (m_syntheticOblique ? &quot; synthetic oblique&quot; : &quot;&quot;) + (m_orientation ? &quot; vertical orientation&quot; : &quot;&quot;);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosFontServicesIOSh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.h (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.h        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.h        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -1,53 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * 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.
- */
-#ifndef FontServicesIOS_h
-#define FontServicesIOS_h
-
-#import &lt;CoreText/CoreText.h&gt;
-
-namespace WebCore {
-
-class FontServicesIOS {
-public:
-    FontServicesIOS(CTFontRef);
-    CGFloat ascent() { return m_ascent; }
-    CGFloat descent() { return m_descent; }
-    CGFloat lineGap() { return m_lineGap; }
-    CGFloat lineSpacing() { return m_lineSpacing; }
-    CGFloat xHeight() { return m_xHeight; }
-    CGFloat capHeight() { return m_capHeight; }
-    unsigned unitsPerEm() { return m_unitsPerEm; }
-
-private:
-    CGFloat m_ascent;
-    CGFloat m_descent;
-    CGFloat m_lineGap;
-    CGFloat m_lineSpacing;
-    CGFloat m_xHeight;
-    CGFloat m_capHeight;
-    unsigned m_unitsPerEm;
-};
-
-}
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosFontServicesIOSmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -1,122 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * 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 &quot;config.h&quot;
-#import &quot;FontServicesIOS.h&quot;
-
-#import &quot;CoreGraphicsSPI.h&quot;
-#import &quot;FontMetrics.h&quot;
-#import &quot;OpenTypeCG.h&quot;
-#import &lt;wtf/RetainPtr.h&gt;
-#import &lt;wtf/spi/darwin/dyldSPI.h&gt;
-
-namespace WebCore {
-
-static const float kLineHeightAdjustment = 0.15f;
-
-static bool shouldUseAdjustment(CTFontRef font, bool isiOS7OrLater)
-{
-    RetainPtr&lt;NSString&gt; familyName = adoptNS((NSString *)CTFontCopyFamilyName(font));
-    if (![familyName length])
-        return false;
-
-    if ([familyName.get() compare:@&quot;Times&quot; options:NSCaseInsensitiveSearch] == NSOrderedSame
-        || [familyName.get() compare:@&quot;Helvetica&quot; options:NSCaseInsensitiveSearch] == NSOrderedSame
-        || [familyName.get() compare:@&quot;.Helvetica NeueUI&quot; options:NSCaseInsensitiveSearch] == NSOrderedSame)
-        return true;
-    if (!isiOS7OrLater &amp;&amp; [familyName.get() compare:@&quot;.Helvetica NeueUILegacy&quot; options:NSCaseInsensitiveSearch] == NSOrderedSame)
-        return true;
-
-    return false;
-}
-
-static bool isCourier(CTFontRef font)
-{
-    RetainPtr&lt;NSString&gt; familyName = adoptNS((NSString *)CTFontCopyFamilyName(font));
-    if (![familyName length])
-        return false;
-    return [familyName.get() compare:@&quot;Courier&quot; options:NSCaseInsensitiveSearch] == NSOrderedSame;
-}
-
-FontServicesIOS::FontServicesIOS(CTFontRef font)
-{
-    CGFontDescriptor descriptor;
-    RetainPtr&lt;CGFontRef&gt; cgFont = adoptCF(CTFontCopyGraphicsFont(font, NULL));
-    m_xHeight = CGFontGetDescriptor(cgFont.get(), &amp;descriptor) ? (descriptor.xHeight / 1000) * CTFontGetSize(font) : 0;
-    m_unitsPerEm = CTFontGetUnitsPerEm(font);
-    CGFloat lineGap;
-    CGFloat ascent;
-    CGFloat descent;
-    CGFloat capHeight;
-    static bool isiOS7OrLater = dyld_get_program_sdk_version() &gt;= DYLD_IOS_VERSION_7_0;
-    if (isiOS7OrLater) {
-        // Use CoreText API in iOS 7.
-        ascent = CTFontGetAscent(font);
-        descent = CTFontGetDescent(font);
-        lineGap = CTFontGetLeading(font);
-        capHeight = CTFontGetCapHeight(font);
-    } else {
-        float pointSize = CTFontGetSize(font);
-        const CGFontHMetrics *metrics = CGFontGetHMetrics(cgFont.get());
-        unsigned unitsPerEm = CGFontGetUnitsPerEm(cgFont.get());
-        unsigned capHeightInGlyphSpace = CGFontGetCapHeight(cgFont.get());
-
-        lineGap = (dyld_get_program_sdk_version() &gt;= DYLD_IOS_VERSION_3_0) ? scaleEmToUnits(metrics-&gt;lineGap, unitsPerEm) * pointSize : 0.0;
-        capHeight = scaleEmToUnits(capHeightInGlyphSpace, unitsPerEm) * pointSize;
-
-        bool isiOS6OrLater = dyld_get_program_sdk_version() &gt;= DYLD_IOS_VERSION_6_0;
-        if (!isiOS6OrLater || !isCourier(font)) {
-            ascent = (scaleEmToUnits(metrics-&gt;ascent, unitsPerEm) * pointSize);
-            descent = (-scaleEmToUnits(metrics-&gt;descent, unitsPerEm) * pointSize);
-        } else {
-            // For Courier, we use Courier New's exact values, because in iOS 5.1 and earlier,
-            // Courier New was substituted for Courier by WebKit.
-            ascent = (scaleEmToUnits(1705, 2048) * pointSize);
-            descent = (scaleEmToUnits(615, 2048) * pointSize);
-        }
-    }
-    // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
-    // &quot;If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font.&quot;
-    // On iOS, we only apply this rule in the important case of fonts with a MATH table.
-    if (OpenType::fontHasMathTable(font)) {
-        short typoAscent, typoDescent, typoLineGap;
-        if (OpenType::tryGetTypoMetrics(cgFont.get(), typoAscent, typoDescent, typoLineGap)) {
-            unsigned unitsPerEm = CGFontGetUnitsPerEm(cgFont.get());
-            float pointSize = CTFontGetSize(font);
-            ascent = scaleEmToUnits(typoAscent, unitsPerEm) * pointSize;
-            descent = -scaleEmToUnits(typoDescent, unitsPerEm) * pointSize;
-            lineGap = scaleEmToUnits(typoLineGap, unitsPerEm) * pointSize;
-        }
-    }
-    CGFloat adjustment = (shouldUseAdjustment(font, isiOS7OrLater)) ? ceil((ascent + descent) * kLineHeightAdjustment) : 0;
-
-    m_ascent = ascent + adjustment;
-    m_descent = descent;
-    m_lineGap = ceilf(lineGap);
-    m_lineSpacing = ceil(ascent) + adjustment + ceil(descent) + m_lineGap;
-    m_capHeight = capHeight;
-}
-
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopentypeOpenTypeCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.cpp (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.cpp        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.cpp        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> static const unsigned long kCTFontTableOS2 = 'OS/2';
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(COCOA)
</del><span class="cx"> bool fontHasMathTable(CTFontRef ctFont)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;CFArrayRef&gt; tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));
</span><span class="lines">@@ -49,7 +48,6 @@
</span><span class="cx">     }
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> static inline short readShortFromTable(const UInt8* os2Data, CFIndex offset)
</span><span class="cx"> {
</span><span class="lines">@@ -56,10 +54,10 @@
</span><span class="cx">     return *(reinterpret_cast&lt;const OpenType::Int16*&gt;(os2Data + offset));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool tryGetTypoMetrics(CGFontRef cgFont, short&amp; ascent, short&amp; descent, short&amp; lineGap)
</del><ins>+bool tryGetTypoMetrics(CTFontRef font, short&amp; ascent, short&amp; descent, short&amp; lineGap)
</ins><span class="cx"> {
</span><span class="cx">     bool result = false;
</span><del>-    if (CFDataRef os2Table = CGFontCopyTableForTag(cgFont, kCTFontTableOS2)) {
</del><ins>+    if (auto os2Table = adoptCF(CTFontCopyTable(font, kCTFontTableOS2, kCTFontTableOptionNoOptions))) {
</ins><span class="cx">         // For the structure of the OS/2 table, see
</span><span class="cx">         // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html
</span><span class="cx">         const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1;
</span><span class="lines">@@ -66,8 +64,8 @@
</span><span class="cx">         const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2;
</span><span class="cx">         const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2;
</span><span class="cx">         const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2;
</span><del>-        if (CFDataGetLength(os2Table) &gt;= sTypoLineGapOffset + 2) {
-            const UInt8* os2Data = CFDataGetBytePtr(os2Table);
</del><ins>+        if (CFDataGetLength(os2Table.get()) &gt;= sTypoLineGapOffset + 2) {
+            const UInt8* os2Data = CFDataGetBytePtr(os2Table.get());
</ins><span class="cx">             // We test the use typo bit on the least significant byte of fsSelection.
</span><span class="cx">             const UInt8 useTypoMetricsMask = 1 &lt;&lt; 7;
</span><span class="cx">             if (*(os2Data + fsSelectionOffset + 1) &amp; useTypoMetricsMask) {
</span><span class="lines">@@ -77,7 +75,6 @@
</span><span class="cx">                 result = true;
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        CFRelease(os2Table);
</del><span class="cx">     }
</span><span class="cx">     return result;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopentypeOpenTypeCGh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.h (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.h        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/opentype/OpenTypeCG.h        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -27,17 +27,17 @@
</span><span class="cx"> #define OpenTypeCG_h
</span><span class="cx"> 
</span><span class="cx"> #include &lt;CoreGraphics/CoreGraphics.h&gt;
</span><del>-#if PLATFORM(COCOA)
</del><span class="cx"> #include &lt;CoreText/CoreText.h&gt;
</span><ins>+
+#if PLATFORM(WIN)
+#include &quot;CoreTextSPIWin.h&quot;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace OpenType {
</span><span class="cx"> 
</span><del>-#if PLATFORM(COCOA)
</del><span class="cx"> bool fontHasMathTable(CTFontRef);
</span><del>-#endif
-bool tryGetTypoMetrics(CGFontRef, short&amp; ascent, short&amp; descent, short&amp; lineGap);
</del><ins>+bool tryGetTypoMetrics(CTFontRef, short&amp; ascent, short&amp; descent, short&amp; lineGap);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace OpenType
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -172,6 +172,7 @@
</span><span class="cx">         matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, skew, 1, 0, 0));
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    CGAffineTransform savedMatrix = CGContextGetTextMatrix(cgContext);
</ins><span class="cx">     CGContextSetTextMatrix(cgContext, matrix);
</span><span class="cx"> 
</span><span class="cx">     // Uniscribe gives us offsets to help refine the positioning of combining glyphs.
</span><span class="lines">@@ -215,6 +216,7 @@
</span><span class="cx">         graphicsContext.setShadow(shadowOffset, shadowBlur, shadowColor);
</span><span class="cx"> 
</span><span class="cx">     wkRestoreFontSmoothingStyle(cgContext, oldFontSmoothingStyle);
</span><ins>+    CGContextSetTextMatrix(cgContext, savedMatrix);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinSimpleFontDataCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;Font.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CoreTextSPIWin.h&quot;
</ins><span class="cx"> #include &quot;FloatRect.h&quot;
</span><span class="cx"> #include &quot;FontCache.h&quot;
</span><span class="cx"> #include &quot;FontDescription.h&quot;
</span><span class="lines">@@ -67,7 +68,7 @@
</span><span class="cx">     // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
</span><span class="cx">     // &quot;If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font.&quot;
</span><span class="cx">     short typoAscent, typoDescent, typoLineGap;
</span><del>-    if (OpenType::tryGetTypoMetrics(m_platformData.cgFont(), typoAscent, typoDescent, typoLineGap)) {
</del><ins>+    if (OpenType::tryGetTypoMetrics(adoptCF(CTFontCreateWithGraphicsFont(m_platformData.cgFont(), m_platformData.size(), nullptr, nullptr)).get(), typoAscent, typoDescent, typoLineGap)) {
</ins><span class="cx">         iAscent = typoAscent;
</span><span class="cx">         iDescent = typoDescent;
</span><span class="cx">         iLineGap = typoLineGap;
</span><span class="lines">@@ -144,7 +145,6 @@
</span><span class="cx">     CGSize advance;
</span><span class="cx">     CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
</span><span class="cx">  
</span><del>-    // FIXME: Need to add real support for printer fonts.
</del><span class="cx">     bool isPrinterFont = false;
</span><span class="cx">     wkGetGlyphAdvances(font, m, m_platformData.isSystemFont(), isPrinterFont, glyph, advance);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicgCoreGraphicsSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -170,10 +170,6 @@
</span><span class="cx"> void CGContextSetShouldAntialiasFonts(CGContextRef, bool shouldAntialiasFonts);
</span><span class="cx"> void CGContextResetClip(CGContextRef);
</span><span class="cx"> CGContextType CGContextGetType(CGContextRef);
</span><del>-#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101100
-void CGContextSetFontDilation(CGContextRef, CGSize);
-void CGContextSetFontRenderingStyle(CGContextRef, CGFontRenderingStyle);
-#endif
</del><span class="cx"> 
</span><span class="cx"> CFStringRef CGFontCopyFamilyName(CGFontRef);
</span><span class="cx"> bool CGFontGetDescriptor(CGFontRef, CGFontDescriptor*);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicocoaCoreTextSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -67,9 +67,6 @@
</span><span class="cx"> CTLineRef CTLineCreateWithUniCharProvider(CTUniCharProviderCallback provide, CTUniCharDisposeCallback dispose, void* refCon);
</span><span class="cx"> CTTypesetterRef CTTypesetterCreateWithUniCharProviderAndOptions(CTUniCharProviderCallback provide, CTUniCharDisposeCallback dispose, void* refCon, CFDictionaryRef options);
</span><span class="cx"> bool CTFontGetVerticalGlyphsForCharacters(CTFontRef, const UniChar characters[], CGGlyph glyphs[], CFIndex count);
</span><del>-#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt; 101000
-bool CTFontSetRenderingStyle(CTFontRef, CGContextRef, CGFontRenderingStyle* originalStyle, CGSize* originalDilation);
-#endif
</del><span class="cx"> 
</span><span class="cx"> CTFontDescriptorRef CTFontDescriptorCreateForUIType(CTFontUIFontType, CGFloat size, CFStringRef language);
</span><span class="cx"> CTFontDescriptorRef CTFontDescriptorCreateWithTextStyle(CFStringRef style, CFStringRef size, CFStringRef language);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspiwinCoreTextSPIWinh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -33,13 +33,24 @@
</span><span class="cx"> 
</span><span class="cx"> typedef const struct __CTFont* CTFontRef;
</span><span class="cx"> typedef const struct __CTLine* CTLineRef;
</span><ins>+typedef UInt32 FourCharCode;
+typedef FourCharCode CTFontTableTag;
</ins><span class="cx"> 
</span><span class="cx"> extern const CFStringRef kCTFontAttributeName;
</span><span class="cx"> extern const CFStringRef kCTForegroundColorFromContextAttributeName;
</span><span class="cx"> 
</span><del>-CTFontRef CTFontCreateWithName(CFStringRef name, CGFloat size, const CGAffineTransform* matrix);
</del><ins>+typedef CF_OPTIONS(uint32_t, CTFontTableOptions)
+{
+    kCTFontTableOptionNoOptions = 0,
+    kCTFontTableOptionExcludeSynthetic = (1 &lt;&lt; 0)
+};
+
+CTFontRef CTFontCreateWithName(CFStringRef, CGFloat size, const CGAffineTransform*);
+CTFontRef CTFontCreateWithGraphicsFont(CGFontRef, CGFloat size, const CGAffineTransform*, CTFontDescriptorRef attributes);
</ins><span class="cx"> CTLineRef CTLineCreateWithAttributedString(CFAttributedStringRef);
</span><span class="cx"> void CTLineDraw(CTLineRef, CGContextRef);
</span><ins>+CFDataRef CTFontCopyTable(CTFontRef, CTFontTableTag, CTFontTableOptions);
+CFArrayRef CTFontCopyAvailableTables(CTFontRef, CTFontTableOptions);
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderThemeIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -1652,7 +1652,7 @@
</span><span class="cx">         context.translate(toFloatSize(line.rect.minXMaxYCorner()));
</span><span class="cx">         context.scale(FloatSize(1, -1));
</span><span class="cx"> 
</span><del>-        CGContextSetTextMatrix(context.platformContext(), CGAffineTransformIdentity);
</del><ins>+        CGContextSetTextPosition(context.platformContext(), 0, 0);
</ins><span class="cx">         CTLineDraw(line.line.get(), context.platformContext());
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderThemeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderThemeMac.mm        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -2510,7 +2510,7 @@
</span><span class="cx">         context.translate(toFloatSize(line.origin));
</span><span class="cx">         context.scale(FloatSize(1, -1));
</span><span class="cx"> 
</span><del>-        CGContextSetTextMatrix(context.platformContext(), CGAffineTransformIdentity);
</del><ins>+        CGContextSetTextPosition(context.platformContext(), 0, 0);
</ins><span class="cx">         CTLineDraw(line.line.get(), context.platformContext());
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -2522,7 +2522,7 @@
</span><span class="cx">     context.translate(toFloatSize(layout.subtitleTextRect.minXMaxYCorner()));
</span><span class="cx">     context.scale(FloatSize(1, -1));
</span><span class="cx"> 
</span><del>-    CGContextSetTextMatrix(context.platformContext(), CGAffineTransformIdentity);
</del><ins>+    CGContextSetTextPosition(context.platformContext(), 0, 0);
</ins><span class="cx">     CTLineDraw(layout.subtitleLine.get(), context.platformContext());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGFontFaceElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (204857 => 204858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp        2016-08-23 20:43:56 UTC (rev 204857)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp        2016-08-23 21:11:20 UTC (rev 204858)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx"> {
</span><span class="cx">     const AtomicString&amp; value = attributeWithoutSynchronization(units_per_emAttr);
</span><span class="cx">     if (value.isEmpty())
</span><del>-        return gDefaultUnitsPerEm;
</del><ins>+        return FontMetrics::defaultUnitsPerEm;
</ins><span class="cx"> 
</span><span class="cx">     return static_cast&lt;unsigned&gt;(ceilf(value.toFloat()));
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>