<!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>[206597] 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/206597">206597</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-09-29 11:45:08 -0700 (Thu, 29 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Win][Direct2D] Add D2D Font handling code
https://bugs.webkit.org/show_bug.cgi?id=162712
Reviewed by Brent Fulgham.
This patch lands a set of new files that implement
No new tests until complete backend lands.
* platform/graphics/Font.h:
* platform/graphics/FontCascade.h:
(WebCore::FontCascade::syntheticObliqueAngle): Added helper function.
* platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformData::dwFont): Added.
(WebCore::FontPlatformData::dwFontFace): Ditto.
* platform/graphics/GlyphBuffer.h:
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::drawGlyphs): Use helper function.
* platform/graphics/win/FontCGWin.cpp:
(WebCore::FontCascade::drawGlyphs): Ditto.
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::createFontPlatformData): Add case for Direct2D.
* platform/graphics/win/FontCascadeDirect2D.cpp: Added.
* platform/graphics/win/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::~FontCustomPlatformData): Fix whitespace.
(WebCore::FontCustomPlatformData::fontPlatformData): Add Direct2D case.
* platform/graphics/win/FontPlatformDataCGWin.cpp:
(WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.
* platform/graphics/win/FontPlatformDataCairoWin.cpp:
(WebCore::FontPlatformData::FontPlatformData): Ditto.
* platform/graphics/win/FontPlatformDataDirect2D.cpp: Added.
* platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.
* platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp: Added.
* platform/graphics/win/SimpleFontDataDirect2D.cpp: Added.
* platform/graphics/win/TextAnalyzerHelper.cpp: Added.
* platform/graphics/win/TextAnalyzerHelper.h: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFonth">trunk/Source/WebCore/platform/graphics/Font.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCascadeh">trunk/Source/WebCore/platform/graphics/FontCascade.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontPlatformDatah">trunk/Source/WebCore/platform/graphics/FontPlatformData.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGlyphBufferh">trunk/Source/WebCore/platform/graphics/GlyphBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCGWincpp">trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCacheWincpp">trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCustomPlatformDatacpp">trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCustomPlatformDatah">trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCustomPlatformDataCairocpp">trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontPlatformDataCGWincpp">trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontPlatformDataCairoWincpp">trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontPlatformDataWincpp">trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontWincpp">trunk/Source/WebCore/platform/graphics/win/FontWin.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCascadeDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/FontCascadeDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontPlatformDataDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGlyphPageTreeNodeDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinSimpleFontDataDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinTextAnalyzerHelpercpp">trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinTextAnalyzerHelperh">trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/ChangeLog        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2016-09-29 Brent Fulgham <bfulgham@apple.com>
+
+ [Win][Direct2D] Add D2D Font handling code
+ https://bugs.webkit.org/show_bug.cgi?id=162712
+
+ Reviewed by Brent Fulgham.
+
+ This patch lands a set of new files that implement
+
+ No new tests until complete backend lands.
+
+ * platform/graphics/Font.h:
+ * platform/graphics/FontCascade.h:
+ (WebCore::FontCascade::syntheticObliqueAngle): Added helper function.
+ * platform/graphics/FontPlatformData.h:
+ (WebCore::FontPlatformData::dwFont): Added.
+ (WebCore::FontPlatformData::dwFontFace): Ditto.
+ * platform/graphics/GlyphBuffer.h:
+ * platform/graphics/cocoa/FontCascadeCocoa.mm:
+ (WebCore::FontCascade::drawGlyphs): Use helper function.
+ * platform/graphics/win/FontCGWin.cpp:
+ (WebCore::FontCascade::drawGlyphs): Ditto.
+ * platform/graphics/win/FontCacheWin.cpp:
+ (WebCore::FontCache::createFontPlatformData): Add case for Direct2D.
+ * platform/graphics/win/FontCascadeDirect2D.cpp: Added.
+ * platform/graphics/win/FontCustomPlatformData.cpp:
+ (WebCore::FontCustomPlatformData::~FontCustomPlatformData): Fix whitespace.
+ (WebCore::FontCustomPlatformData::fontPlatformData): Add Direct2D case.
+ * platform/graphics/win/FontPlatformDataCGWin.cpp:
+ (WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.
+ * platform/graphics/win/FontPlatformDataCairoWin.cpp:
+ (WebCore::FontPlatformData::FontPlatformData): Ditto.
+ * platform/graphics/win/FontPlatformDataDirect2D.cpp: Added.
+ * platform/graphics/win/FontPlatformDataWin.cpp:
+ (WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.
+ * platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp: Added.
+ * platform/graphics/win/SimpleFontDataDirect2D.cpp: Added.
+ * platform/graphics/win/TextAnalyzerHelper.cpp: Added.
+ * platform/graphics/win/TextAnalyzerHelper.h: Added.
+
</ins><span class="cx"> 2016-09-29 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> URLParser should fail to parse unclosed IPv6 addresses
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.h (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.h        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/Font.h        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx"> * This file is part of the internal font implementation.
</span><span class="cx"> *
</span><del>- * Copyright (C) 2006, 2008, 2010, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2008, 2010, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2007-2008 Torch Mobile, Inc.
</span><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -57,6 +57,11 @@
</span><span class="cx"> #include "CoreGraphicsSPI.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if USE(DIRECT2D)
+interface IDWriteFactory;
+interface IDWriteGdiInterop;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class GlyphPage;
</span><span class="lines">@@ -143,7 +148,7 @@
</span><span class="cx"> m_adjustedSpaceWidth = spaceWidth;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if USE(CG) || USE(CAIRO)
</del><ins>+#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
</ins><span class="cx"> float syntheticBoldOffset() const { return m_syntheticBoldOffset; }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -198,6 +203,11 @@
</span><span class="cx"> static float ascentConsideringMacAscentHack(const WCHAR*, float ascent, float descent);
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if USE(DIRECT2D)
+ WEBCORE_EXPORT static IDWriteFactory* systemDWriteFactory();
+ WEBCORE_EXPORT static IDWriteGdiInterop* systemDWriteGdiInterop();
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx"> Font(const FontPlatformData&, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false);
</span><span class="cx">
</span><span class="lines">@@ -267,7 +277,7 @@
</span><span class="cx">
</span><span class="cx"> mutable std::unique_ptr<DerivedFonts> m_derivedFontData;
</span><span class="cx">
</span><del>-#if USE(CG) || USE(CAIRO)
</del><ins>+#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
</ins><span class="cx"> float m_syntheticBoldOffset;
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -338,7 +348,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(OPENTYPE_VERTICAL)
</span><span class="cx"> if (m_verticalData) {
</span><del>-#if USE(CG) || USE(CAIRO)
</del><ins>+#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
</ins><span class="cx"> width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset;
</span><span class="cx"> #else
</span><span class="cx"> width = m_verticalData->advanceHeight(this, glyph);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCascadeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCascade.h        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
</span><span class="cx"> * (C) 2000 Antti Koivisto (koivisto@kde.org)
</span><span class="cx"> * (C) 2000 Dirk Mueller (mueller@kde.org)
</span><del>- * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2003, 2006, 2007, 2010, 2011-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2008 Holger Hans Peter Freyther
</span><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -320,6 +320,8 @@
</span><span class="cx"> return advancedTextRenderingMode();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ static int syntheticObliqueAngle() { return 14; }
+
</ins><span class="cx"> FontCascadeDescription m_fontDescription;
</span><span class="cx"> mutable RefPtr<FontCascadeFonts> m_fonts;
</span><span class="cx"> WeakPtrFactory<FontCascade> m_weakPtrFactory;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontPlatformDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008, 2010, 2013 Apple Inc.
</del><ins>+ * Copyright (C) 2006, 2007, 2008, 2010, 2013-2016 Apple Inc.
</ins><span class="cx"> * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
</span><span class="cx"> * Copyright (C) 2007 Holger Hans Peter Freyther
</span><span class="cx"> * Copyright (C) 2007 Pioneer Research Center USA, Inc.
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "TextFlags.h"
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(WIN)
</span><ins>+#include "COMPtr.h"
</ins><span class="cx"> #include "SharedGDIObject.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -65,6 +66,8 @@
</span><span class="cx"> #if PLATFORM(WIN)
</span><span class="cx"> #include <wtf/win/GDIObject.h>
</span><span class="cx"> typedef struct HFONT__* HFONT;
</span><ins>+interface IDWriteFont;
+interface IDWriteFontFace;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -103,6 +106,8 @@
</span><span class="cx">
</span><span class="cx"> #if USE(CG)
</span><span class="cx"> FontPlatformData(GDIObject<HFONT>, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
</span><ins>+#elif USE(DIRECT2D)
+ FontPlatformData(GDIObject<HFONT>, IDWriteFont*, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
</ins><span class="cx"> #elif USE(CAIRO)
</span><span class="cx"> FontPlatformData(GDIObject<HFONT>, cairo_font_face_t*, float size, bool bold, bool italic);
</span><span class="cx"> #endif
</span><span class="lines">@@ -137,6 +142,11 @@
</span><span class="cx"> CGFontRef cgFont() const { return m_cgFont.get(); }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if USE(DIRECT2D)
+ IDWriteFont* dwFont() const { return m_dwFont.get(); }
+ IDWriteFontFace* dwFontFace() const { return m_dwFontFace.get(); }
+#endif
+
</ins><span class="cx"> bool isFixedPitch() const;
</span><span class="cx"> float size() const { return m_size; }
</span><span class="cx"> bool syntheticBold() const { return m_syntheticBold; }
</span><span class="lines">@@ -241,6 +251,10 @@
</span><span class="cx"> #if USE(CG) && (PLATFORM(WIN) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 100000))
</span><span class="cx"> RetainPtr<CGFontRef> m_cgFont;
</span><span class="cx"> #endif
</span><ins>+#if USE(DIRECT2D)
+ COMPtr<IDWriteFont> m_dwFont;
+ COMPtr<IDWriteFontFace> m_dwFontFace;
+#endif
</ins><span class="cx"> #if USE(CAIRO)
</span><span class="cx"> RefPtr<cairo_scaled_font_t> m_scaledFont;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGlyphBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GlyphBuffer.h (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GlyphBuffer.h        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/GlyphBuffer.h        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2009, 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2009, 2011, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2007-2008 Torch Mobile Inc.
</span><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -96,6 +96,7 @@
</span><span class="cx"> GlyphBufferAdvance* advances(unsigned from) { return m_advances.data() + from; }
</span><span class="cx"> const GlyphBufferGlyph* glyphs(unsigned from) const { return m_glyphs.data() + from; }
</span><span class="cx"> const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.data() + from; }
</span><ins>+ size_t advancesCount() const { return m_advances.size(); }
</ins><span class="cx">
</span><span class="cx"> const Font* fontAt(unsigned index) const { return m_font[index]; }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><span class="cx"> * (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><span class="cx"> * (C) 2000 Dirk Mueller (mueller@kde.org)
</span><del>- * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
</del><ins>+ * Copyright (C) 2003, 2006-2011, 2016 Apple Inc.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -50,8 +50,6 @@
</span><span class="cx"> SOFT_LINK(UIKit, _UIKitGetTextEffectsCatalog, CUICatalog *, (void), ())
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#define SYNTHETIC_OBLIQUE_ANGLE 14
-
</del><span class="cx"> #ifdef __LP64__
</span><span class="cx"> #define URefCon void*
</span><span class="cx"> #else
</span><span class="lines">@@ -244,7 +242,7 @@
</span><span class="cx"> matrix.b = -matrix.b;
</span><span class="cx"> matrix.d = -matrix.d;
</span><span class="cx"> if (platformData.syntheticOblique()) {
</span><del>- static float obliqueSkew = tanf(SYNTHETIC_OBLIQUE_ANGLE * piFloat / 180);
</del><ins>+ static float obliqueSkew = tanf(syntheticObliqueAngle() * piFloat / 180);
</ins><span class="cx"> if (platformData.orientation() == Vertical)
</span><span class="cx"> matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, obliqueSkew, 0, 1, 0, 0));
</span><span class="cx"> else
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2009, 2013, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -40,8 +40,6 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-const int syntheticObliqueAngle = 14;
-
</del><span class="cx"> static inline CGFloat toCGFloat(FIXED f)
</span><span class="cx"> {
</span><span class="cx"> return f.value + f.fract / CGFloat(65536.0);
</span><span class="lines">@@ -168,7 +166,7 @@
</span><span class="cx"> matrix.d = -matrix.d;
</span><span class="cx">
</span><span class="cx"> if (platformData.syntheticOblique()) {
</span><del>- static float skew = -tanf(syntheticObliqueAngle * piFloat / 180.0f);
</del><ins>+ static float skew = -tanf(syntheticObliqueAngle() * piFloat / 180.0f);
</ins><span class="cx"> matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, skew, 1, 0, 0));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCacheWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008, 2013-2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2008, 2013-2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -47,6 +47,10 @@
</span><span class="cx"> #include <WebKitSystemInterface/WebKitSystemInterface.h>
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
</ins><span class="cx"> using std::min;
</span><span class="cx">
</span><span class="cx"> namespace WebCore
</span><span class="lines">@@ -549,6 +553,7 @@
</span><span class="cx"> procData->m_traitsMasks.add(traitsMask);
</span><span class="cx"> return 1;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> Vector<FontTraitsMask> FontCache::getTraitsInFamily(const AtomicString& familyName)
</span><span class="cx"> {
</span><span class="cx"> HWndDC hdc(0);
</span><span class="lines">@@ -599,6 +604,8 @@
</span><span class="cx">
</span><span class="cx"> #if USE(CG)
</span><span class="cx"> bool fontCreationFailed = !result->cgFont();
</span><ins>+#elif USE(DIRECT2D)
+ bool fontCreationFailed = !result->dwFont();
</ins><span class="cx"> #elif USE(CAIRO)
</span><span class="cx"> bool fontCreationFailed = !result->scaledFont();
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCascadeDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/FontCascadeDirect2D.cpp (0 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCascadeDirect2D.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/FontCascadeDirect2D.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -0,0 +1,153 @@
</span><ins>+/*
+ * Copyright (C) 2016 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include "FontCascade.h"
+
+#if USE(DIRECT2D)
+
+#include "AffineTransform.h"
+#include "COMPtr.h"
+#include "FloatConversion.h"
+#include "Font.h"
+#include "GlyphBuffer.h"
+#include "GraphicsContext.h"
+#include "GraphicsContextPlatformPrivateDirect2D.h"
+#include "IntRect.h"
+#include "UniscribeController.h"
+#include "WebCoreTextRenderer.h"
+#include <d2d1.h>
+#include <dwrite.h>
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font, const GlyphBuffer& glyphBuffer,
+ unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode smoothingMode)
+{
+ auto context = graphicsContext.platformContext();
+ bool shouldUseFontSmoothing = WebCoreShouldUseFontSmoothing();
+
+ switch (smoothingMode) {
+ case Antialiased:
+ graphicsContext.setShouldAntialias(true);
+ shouldUseFontSmoothing = false;
+ break;
+ case SubpixelAntialiased:
+ graphicsContext.setShouldAntialias(true);
+ shouldUseFontSmoothing = true;
+ break;
+ case NoSmoothing:
+ graphicsContext.setShouldAntialias(false);
+ shouldUseFontSmoothing = false;
+ break;
+ case AutoSmoothing:
+ // For the AutoSmooth case, don't do anything! Keep the default settings.
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ const FontPlatformData& platformData = font.platformData();
+
+ graphicsContext.save();
+
+ D2D1_MATRIX_3X2_F matrix;
+ context->GetTransform(&matrix);
+
+ if (platformData.syntheticOblique()) {
+ static float skew = -tanf(syntheticObliqueAngle() * piFloat / 180.0f);
+ auto skewMatrix = D2D1::Matrix3x2F::Skew(skew, 0);
+ context->SetTransform(matrix * skewMatrix);
+ }
+
+ // Uniscribe gives us offsets to help refine the positioning of combining glyphs.
+ FloatSize translation = glyphBuffer.offsetAt(from);
+
+ RELEASE_ASSERT(platformData.dwFont());
+ RELEASE_ASSERT(platformData.dwFontFace());
+
+ Vector<FLOAT> horizontalAdvances(numGlyphs);
+ Vector<DWRITE_GLYPH_OFFSET> offsetAdvances(numGlyphs);
+ for (unsigned i = 0; i < numGlyphs; ++i) {
+ if (i + from >= glyphBuffer.advancesCount())
+ break;
+
+ auto advance = glyphBuffer.advances(i + from);
+ if (!advance)
+ continue;
+
+ horizontalAdvances[i] = advance->width();
+ offsetAdvances[i].advanceOffset = advance->width();
+ offsetAdvances[i].ascenderOffset = advance->height();
+ }
+
+ DWRITE_GLYPH_RUN glyphRun;
+ glyphRun.fontFace = platformData.dwFontFace();
+ glyphRun.fontEmSize = platformData.size();
+ glyphRun.glyphCount = numGlyphs;
+ glyphRun.glyphIndices = glyphBuffer.glyphs(from);
+ glyphRun.glyphAdvances = horizontalAdvances.data();
+ glyphRun.glyphOffsets = nullptr;
+ glyphRun.isSideways = platformData.orientation() == Vertical;
+ glyphRun.bidiLevel = 0;
+
+ FloatSize shadowOffset;
+ float shadowBlur;
+ Color shadowColor;
+ graphicsContext.getShadow(shadowOffset, shadowBlur, shadowColor);
+
+ bool hasSimpleShadow = graphicsContext.textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && (!graphicsContext.shadowsIgnoreTransforms() || graphicsContext.getCTM().isIdentityOrTranslationOrFlipped());
+ if (hasSimpleShadow) {
+ // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
+ graphicsContext.clearShadow();
+ Color fillColor = graphicsContext.fillColor();
+ Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
+ float shadowTextX = point.x() + translation.width() + shadowOffset.width();
+ // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
+ float shadowTextY = point.y() + translation.height() + shadowOffset.height() * (graphicsContext.shadowsIgnoreTransforms() ? -1 : 1);
+
+ COMPtr<ID2D1SolidColorBrush> shadowBrush;
+ if (!SUCCEEDED(context->CreateSolidColorBrush(graphicsContext.colorWithGlobalAlpha(shadowFillColor), &shadowBrush)))
+ return;
+
+ context->DrawGlyphRun(D2D1::Point2F(shadowTextX, shadowTextY), &glyphRun, shadowBrush.get());
+ if (font.syntheticBoldOffset())
+ context->DrawGlyphRun(D2D1::Point2F(shadowTextX + font.syntheticBoldOffset(), shadowTextY), &glyphRun, shadowBrush.get());
+ }
+
+ context->DrawGlyphRun(D2D1::Point2F(point.x() + translation.width(), point.y() + translation.height()), &glyphRun, graphicsContext.solidFillBrush());
+ if (font.syntheticBoldOffset())
+ context->DrawGlyphRun(D2D1::Point2F(point.x() + translation.width() + font.syntheticBoldOffset(), point.y() + translation.height()), &glyphRun, graphicsContext.solidFillBrush());
+
+ if (hasSimpleShadow)
+ graphicsContext.setShadow(shadowOffset, shadowBlur, shadowColor);
+
+ graphicsContext.restore();
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCustomPlatformDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2010, 2013, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -25,20 +25,26 @@
</span><span class="cx"> #include "FontPlatformData.h"
</span><span class="cx"> #include "OpenTypeUtilities.h"
</span><span class="cx"> #include "SharedBuffer.h"
</span><del>-#include <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
</del><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> #include <wtf/text/Base64.h>
</span><span class="cx"> #include <wtf/win/GDIObject.h>
</span><span class="cx">
</span><ins>+#if USE(CG)
+#include <ApplicationServices/ApplicationServices.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
+
+#if USE(DIRECT2D)
+#include "Font.h"
+#include <dwrite.h>
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-using namespace std;
-
</del><span class="cx"> FontCustomPlatformData::~FontCustomPlatformData()
</span><span class="cx"> {
</span><span class="cx"> if (m_fontReference)
</span><del>- RemoveFontMemResourceEx(m_fontReference);
</del><ins>+ RemoveFontMemResourceEx(m_fontReference);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic)
</span><span class="lines">@@ -68,8 +74,15 @@
</span><span class="cx">
</span><span class="cx"> auto hfont = adoptGDIObject(::CreateFontIndirect(&logFont));
</span><span class="cx">
</span><ins>+#if USE(CG)
</ins><span class="cx"> RetainPtr<CGFontRef> cgFont = adoptCF(CGFontCreateWithPlatformFont(&logFont));
</span><span class="cx"> return FontPlatformData(WTFMove(hfont), cgFont.get(), size, bold, italic, renderingMode == FontRenderingMode::Alternate);
</span><ins>+#else
+ COMPtr<IDWriteFont> dwFont;
+ HRESULT hr = Font::systemDWriteGdiInterop()->CreateFontFromLOGFONT(&logFont, &dwFont);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+ return FontPlatformData(WTFMove(hfont), dwFont.get(), size, bold, italic, renderingMode == FontRenderingMode::Alternate);
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Creates a unique and unpredictable font name, in order to avoid collisions and to
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCustomPlatformDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2008, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCustomPlatformDataCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008, 2013 Apple Inc.
</del><ins>+ * Copyright (C) 2007-2008, 2013, 2016 Apple Inc.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontPlatformDataCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> * This file is part of the internal font implementation. It should not be included by anyone other than
</span><span class="cx"> * FontMac.cpp, FontWin.cpp and Font.cpp.
</span><span class="cx"> *
</span><del>- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.
</del><ins>+ * Copyright (C) 2006-2009, 2016 Apple Inc.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -120,12 +120,9 @@
</span><span class="cx"> FontPlatformData::FontPlatformData(GDIObject<HFONT> hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI)
</span><span class="cx"> : m_syntheticBold(bold)
</span><span class="cx"> , m_syntheticOblique(oblique)
</span><del>- , m_orientation(Horizontal)
</del><span class="cx"> , m_size(size)
</span><del>- , m_widthVariant(RegularWidth)
</del><span class="cx"> , m_font(SharedGDIObject<HFONT>::create(WTFMove(hfont)))
</span><span class="cx"> , m_cgFont(font)
</span><del>- , m_isColorBitmapFont(false)
</del><span class="cx"> , m_useGDI(useGDI)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontPlatformDataCairoWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> * This file is part of the internal font implementation. It should not be included by anyone other than
</span><span class="cx"> * FontMac.cpp, FontWin.cpp and Font.cpp.
</span><span class="cx"> *
</span><del>- * Copyright (C) 2006, 2007, 2008 Apple Inc.
</del><ins>+ * Copyright (C) 2006-2008, 2016 Apple Inc.
</ins><span class="cx"> * Copyright (C) 2007 Alp Toker
</span><span class="cx"> * Copyright (C) 2008, 2010, 2011 Brent Fulgham
</span><span class="cx"> *
</span><span class="lines">@@ -62,12 +62,7 @@
</span><span class="cx"> FontPlatformData::FontPlatformData(GDIObject<HFONT> font, cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
</span><span class="cx"> : m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
</span><span class="cx"> , m_size(size)
</span><del>- , m_orientation(Horizontal)
- , m_widthVariant(RegularWidth)
- , m_isColorBitmapFont(false)
- , m_syntheticBold(bold)
</del><span class="cx"> , m_syntheticOblique(oblique)
</span><del>- , m_useGDI(false)
</del><span class="cx"> {
</span><span class="cx"> cairo_matrix_t fontMatrix;
</span><span class="cx"> cairo_matrix_init_scale(&fontMatrix, size, size);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontPlatformDataDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp (0 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -0,0 +1,116 @@
</span><ins>+/*
+ * Copyright (C) 2016 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include "FontPlatformData.h"
+
+#if USE(DIRECT2D)
+
+#include "GraphicsContext.h"
+#include "SharedGDIObject.h"
+#include <d2d1.h>
+#include <dwrite.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName)
+{
+ LOGFONT logfont;
+ GetObject(font, sizeof(logfont), &logfont);
+
+ HRESULT hr = Font::systemDWriteGdiInterop()->CreateFontFromLOGFONT(&logfont, &m_dwFont);
+ if (!SUCCEEDED(hr))
+ return;
+
+ hr = m_dwFont->CreateFontFace(&m_dwFontFace);
+ if (!SUCCEEDED(hr))
+ return;
+
+ if (!m_useGDI)
+ m_isSystemFont = !wcscmp(faceName, L"Lucida Grande");
+}
+
+FontPlatformData::FontPlatformData(GDIObject<HFONT> hfont, IDWriteFont* font, float size, bool bold, bool oblique, bool useGDI)
+ : m_syntheticBold(bold)
+ , m_syntheticOblique(oblique)
+ , m_size(size)
+ , m_font(SharedGDIObject<HFONT>::create(WTFMove(hfont)))
+ , m_dwFont(font)
+ , m_useGDI(useGDI)
+{
+ HRESULT hr = m_dwFont->CreateFontFace(&m_dwFontFace);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+}
+
+static bool fontsAreEqual(IDWriteFont* a, IDWriteFont* b)
+{
+ if (!a && !b)
+ return true;
+
+ if (a == b)
+ return true;
+
+ if ((!a && b) || (a && !b))
+ return false;
+
+ if (a->GetWeight() != b->GetWeight())
+ return false;
+
+ if (a->GetStyle() != b->GetStyle())
+ return false;
+
+ if (a->GetStretch() != b->GetStretch())
+ return false;
+
+ DWRITE_FONT_METRICS aMetrics, bMetrics;
+ a->GetMetrics(&aMetrics);
+ b->GetMetrics(&bMetrics);
+
+ if ((aMetrics.designUnitsPerEm != bMetrics.designUnitsPerEm)
+ || (aMetrics.ascent != bMetrics.ascent)
+ || (aMetrics.descent != bMetrics.ascent)
+ || (aMetrics.lineGap != bMetrics.lineGap)
+ || (aMetrics.capHeight != bMetrics.capHeight)
+ || (aMetrics.xHeight != bMetrics.xHeight)
+ || (aMetrics.underlinePosition != bMetrics.underlinePosition)
+ || (aMetrics.underlineThickness != bMetrics.underlineThickness)
+ || (aMetrics.strikethroughPosition != bMetrics.strikethroughPosition)
+ || (aMetrics.strikethroughThickness != bMetrics.strikethroughThickness))
+ return false;
+
+ return true;
+}
+
+bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
+{
+ return m_font == other.m_font
+ && m_useGDI == other.m_useGDI
+ && fontsAreEqual(m_dwFont.get(), other.m_dwFont.get());
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontPlatformDataWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> * This file is part of the internal font implementation. It should not be included by anyone other than
</span><span class="cx"> * FontMac.cpp, FontWin.cpp and Font.cpp.
</span><span class="cx"> *
</span><del>- * Copyright (C) 2006, 2007, 2008 Apple Inc.
</del><ins>+ * Copyright (C) 2006-2008, 2016 Apple Inc.
</ins><span class="cx"> * Copyright (C) 2008 Brent Fulgham
</span><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -40,9 +40,6 @@
</span><span class="cx"> FontPlatformData::FontPlatformData(GDIObject<HFONT> font, float size, bool bold, bool oblique, bool useGDI)
</span><span class="cx"> : m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
</span><span class="cx"> , m_size(size)
</span><del>- , m_orientation(Horizontal)
- , m_widthVariant(RegularWidth)
- , m_isColorBitmapFont(false)
</del><span class="cx"> , m_syntheticBold(bold)
</span><span class="cx"> , m_syntheticOblique(oblique)
</span><span class="cx"> , m_useGDI(useGDI)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontWin.cpp (206596 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontWin.cpp        2016-09-29 18:44:54 UTC (rev 206596)
+++ trunk/Source/WebCore/platform/graphics/win/FontWin.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2008, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGlyphPageTreeNodeDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp (0 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -0,0 +1,87 @@
</span><ins>+/*
+ * Copyright (C) 2016 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include "GlyphPage.h"
+
+#if USE(DIRECT2D)
+
+#include "Font.h"
+#include "TextAnalysisHelper.h"
+#include <dwrite.h>
+
+namespace WebCore {
+
+bool GlyphPage::fill(UChar* buffer, unsigned bufferLength)
+{
+ if (bufferLength > GlyphPage::size)
+ return false;
+
+ const Font& font = this->font();
+ bool haveGlyphs = false;
+
+ COMPtr<IDWriteTextAnalyzer> analyzer;
+ HRESULT hr = Font::systemDWriteFactory()->CreateTextAnalyzer(&analyzer);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+
+ auto& fontPlatformData = font.platformData();
+
+ UChar localeName[LOCALE_NAME_MAX_LENGTH + 1] = { };
+ int localeLength = GetUserDefaultLocaleName(reinterpret_cast<LPWSTR>(&localeName), LOCALE_NAME_MAX_LENGTH);
+ RELEASE_ASSERT(localeLength <= LOCALE_NAME_MAX_LENGTH);
+ localeName[localeLength] = '\0';
+
+ TextAnalyzerHelper helper(localeName, buffer, bufferLength);
+
+ hr = analyzer->AnalyzeScript(&helper, 0, bufferLength, &helper);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+
+ unsigned returnedCount = 0;
+ Glyph localGlyphBuffer[GlyphPage::size];
+ Glyph clusterMap[GlyphPage::size];
+ Vector<DWRITE_SHAPING_TEXT_PROPERTIES> textProperties(GlyphPage::size);
+ Vector<DWRITE_SHAPING_GLYPH_PROPERTIES> glyphProperties(GlyphPage::size);
+
+ hr = analyzer->GetGlyphs(buffer, bufferLength, fontPlatformData.dwFontFace(), fontPlatformData.orientation() == Vertical, false,
+ &helper.m_analysis, nullptr, nullptr, nullptr, nullptr, 0, GlyphPage::size, clusterMap, textProperties.data(),
+ localGlyphBuffer, glyphProperties.data(), &returnedCount);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+
+ for (unsigned i = 0; i < GlyphPage::size; i++) {
+ Glyph glyph = localGlyphBuffer[i];
+ if (!glyph)
+ setGlyphForIndex(i, 0);
+ else {
+ setGlyphForIndex(i, glyph);
+ haveGlyphs = true;
+ }
+ }
+
+ return haveGlyphs;
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinSimpleFontDataDirect2Dcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp (0 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -0,0 +1,235 @@
</span><ins>+/*
+ * Copyright (C) 2016 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include "Font.h"
+
+#if USE(DIRECT2D)
+
+#include "CoreTextSPIWin.h"
+#include "FloatRect.h"
+#include "FontCache.h"
+#include "FontDescription.h"
+#include "GlyphPage.h"
+#include "GraphicsContext.h"
+#include "HWndDC.h"
+#include <comutil.h>
+#include <dwrite.h>
+#include <mlang.h>
+#include <unicode/uchar.h>
+#include <unicode/unorm.h>
+#include <winsock2.h>
+#include <wtf/MathExtras.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+IDWriteFactory* Font::systemDWriteFactory()
+{
+ static IDWriteFactory* directWriteFactory = nullptr;
+ if (!directWriteFactory) {
+ HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(directWriteFactory), reinterpret_cast<IUnknown**>(&directWriteFactory));
+ RELEASE_ASSERT(SUCCEEDED(hr));
+ }
+
+ return directWriteFactory;
+}
+
+IDWriteGdiInterop* Font::systemDWriteGdiInterop()
+{
+ static IDWriteGdiInterop* directWriteGdiInterop = nullptr;
+ if (!directWriteGdiInterop) {
+ HRESULT hr = systemDWriteFactory()->GetGdiInterop(&directWriteGdiInterop);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+ }
+
+ return directWriteGdiInterop;
+}
+
+static Vector<WCHAR> getFaceName(IDWriteFont* font)
+{
+ if (!font)
+ return Vector<WCHAR>();
+
+ COMPtr<IDWriteLocalizedStrings> localizedFaceNames;
+ HRESULT hr = font->GetFaceNames(&localizedFaceNames);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+
+ UINT32 localeIndex = 0;
+ BOOL exists = false;
+
+ wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
+ int localeLength = GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH);
+ if (localeLength)
+ hr = localizedFaceNames->FindLocaleName(localeName, &localeIndex, &exists);
+
+ if (!exists || !SUCCEEDED(hr))
+ hr = localizedFaceNames->FindLocaleName(L"en-us", &localeIndex, &exists);
+
+ if (!exists || !SUCCEEDED(hr))
+ localeIndex = 0;
+
+ UINT32 faceNameLength = 0;
+ hr = localizedFaceNames->GetStringLength(localeIndex, &faceNameLength);
+ if (!SUCCEEDED(hr))
+ return Vector<WCHAR>();
+
+ Vector<WCHAR> faceName(faceNameLength + 1);
+ hr = localizedFaceNames->GetString(localeIndex, faceName.data(), faceName.size());
+
+ return faceName;
+}
+
+void Font::platformInit()
+{
+ m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
+ m_scriptCache = 0;
+ m_scriptFontProperties = 0;
+
+ if (m_platformData.useGDI())
+ return initGDIFont();
+
+ float pointSize = m_platformData.size();
+
+ auto font = m_platformData.dwFont();
+ RELEASE_ASSERT(font);
+
+ auto fontFace = m_platformData.dwFontFace();
+ RELEASE_ASSERT(fontFace);
+
+ DWRITE_FONT_METRICS fontMetrics;
+ font->GetMetrics(&fontMetrics);
+
+ int iAscent = fontMetrics.ascent;
+ int iDescent = fontMetrics.descent;
+ int iLineGap = fontMetrics.lineGap;
+ int iCapHeight = fontMetrics.capHeight;
+
+ unsigned unitsPerEm = fontMetrics.designUnitsPerEm;
+ float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
+ float fDescent = scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
+ float fCapHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize;
+ float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
+
+ if (!isCustomFont()) {
+ Vector<WCHAR> faceName = getFaceName(font);
+ fAscent = ascentConsideringMacAscentHack(faceName.data(), fAscent, fDescent);
+ }
+
+ m_fontMetrics.setAscent(fAscent);
+ m_fontMetrics.setDescent(fDescent);
+ m_fontMetrics.setCapHeight(fCapHeight);
+ m_fontMetrics.setLineGap(fLineGap);
+ m_fontMetrics.setLineSpacing(lroundf(fAscent) + lroundf(fDescent) + lroundf(fLineGap));
+
+ Glyph xGlyph = glyphDataForCharacter('x').glyph;
+
+ if (xGlyph) {
+ // 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.
+ Vector<DWRITE_GLYPH_METRICS> glyphMetrics(1);
+ HRESULT hr = fontFace->GetDesignGlyphMetrics(&xGlyph, 1, glyphMetrics.data(), m_platformData.orientation() == Vertical);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+ m_fontMetrics.setXHeight(scaleEmToUnits(glyphMetrics.first().verticalOriginY, unitsPerEm) * pointSize);
+ } else {
+ int iXHeight = fontMetrics.xHeight;
+ m_fontMetrics.setXHeight(scaleEmToUnits(iXHeight, unitsPerEm) * pointSize);
+ }
+
+ m_fontMetrics.setUnitsPerEm(unitsPerEm);
+}
+
+FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
+{
+ if (!platformData().size())
+ return FloatRect();
+
+ if (m_platformData.useGDI())
+ return boundsForGDIGlyph(glyph);
+
+ auto font = m_platformData.dwFont();
+ RELEASE_ASSERT(font);
+
+ auto fontFace = m_platformData.dwFontFace();
+ RELEASE_ASSERT(fontFace);
+
+ float pointSize = m_platformData.size();
+ bool vertical = m_platformData.orientation() == Vertical;
+
+ Vector<DWRITE_GLYPH_METRICS> glyphMetrics(1);
+ HRESULT hr = fontFace->GetDesignGlyphMetrics(&glyph, 1, glyphMetrics.data(), m_platformData.orientation() == Vertical);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+
+ const auto& metrics = glyphMetrics.first();
+
+ unsigned unitsPerEm = m_fontMetrics.unitsPerEm();
+
+ FloatPoint origin(scaleEmToUnits(metrics.leftSideBearing, unitsPerEm) * pointSize, scaleEmToUnits(metrics.verticalOriginY, unitsPerEm) * pointSize);
+ FloatSize size(scaleEmToUnits(metrics.advanceWidth - metrics.leftSideBearing - metrics.rightSideBearing, unitsPerEm) * pointSize,
+ scaleEmToUnits(metrics.advanceHeight - metrics.topSideBearing - metrics.bottomSideBearing, unitsPerEm) * pointSize);
+
+ FloatRect boundingBox(origin, size);
+ if (m_syntheticBoldOffset)
+ boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset);
+
+ return boundingBox;
+}
+
+float Font::platformWidthForGlyph(Glyph glyph) const
+{
+ if (!platformData().size())
+ return 0;
+
+ if (m_platformData.useGDI())
+ return widthForGDIGlyph(glyph);
+
+ ASSERT(glyph);
+
+ auto font = m_platformData.dwFont();
+ RELEASE_ASSERT(font);
+
+ auto fontFace = m_platformData.dwFontFace();
+ RELEASE_ASSERT(fontFace);
+
+ bool isVertical = m_platformData.orientation() == Vertical;
+
+ Vector<DWRITE_GLYPH_METRICS> glyphMetrics(1);
+ HRESULT hr = fontFace->GetDesignGlyphMetrics(&glyph, 1, glyphMetrics.data(), isVertical);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+
+ const auto& metrics = glyphMetrics.first();
+ int widthInEm = metrics.advanceWidth;
+
+ float pointSize = m_platformData.size();
+ unsigned unitsPerEm = m_fontMetrics.unitsPerEm();
+ float width = scaleEmToUnits(widthInEm, unitsPerEm) * pointSize;
+
+ return width + m_syntheticBoldOffset;
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinTextAnalyzerHelpercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.cpp (0 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.cpp        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -0,0 +1,142 @@
</span><ins>+/*
+ * Copyright (C) 2016 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include "TextAnalyzerHelper.h"
+
+#if USE(DIRECT2D)
+
+namespace WebCore {
+
+TextAnalyzerHelper::TextAnalyzerHelper(WCHAR* localeName, WCHAR* buffer, unsigned bufferLength)
+ : m_localeName(localeName)
+ , m_buffer(buffer)
+ , m_bufferLength(bufferLength)
+{
+}
+
+HRESULT TextAnalyzerHelper::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
+{
+ if (!ppvObject)
+ return E_POINTER;
+ *ppvObject = nullptr;
+ if (IsEqualGUID(riid, __uuidof(IDWriteTextAnalysisSink)))
+ *ppvObject = static_cast<IDWriteTextAnalysisSink*>(this);
+ else if (IsEqualGUID(riid, __uuidof(IDWriteTextAnalysisSource)))
+ *ppvObject = static_cast<IDWriteTextAnalysisSink*>(this);
+ else
+ return E_FAIL;
+
+ AddRef();
+ return S_OK;
+}
+
+ULONG TextAnalyzerHelper::AddRef()
+{
+ return ++m_refCount;
+}
+
+ULONG TextAnalyzerHelper::Release()
+{
+ ULONG newRef = --m_refCount;
+ if (!newRef)
+ delete(this);
+
+ return newRef;
+}
+
+HRESULT TextAnalyzerHelper::GetTextAtPosition(UINT32 textPosition, const WCHAR** textString, UINT32* textLength)
+{
+ if (!textString || !textLength)
+ return E_POINTER;
+
+ if (textPosition >= m_bufferLength) {
+ *textString = nullptr;
+ *textLength = 0;
+ return S_OK;
+ }
+
+ *textString = &m_buffer[textPosition];
+ *textLength = m_bufferLength - textPosition;
+
+ return S_OK;
+}
+
+HRESULT TextAnalyzerHelper::GetTextBeforePosition(UINT32 textPosition, const WCHAR** textString, UINT32* textLength)
+{
+ if (!textString || !textLength)
+ return E_POINTER;
+
+ if (!textPosition || textPosition > m_bufferLength) {
+ *textString = nullptr;
+ *textLength = 0;
+ return S_OK;
+ }
+
+ *textString = &m_buffer[0];
+ *textLength = textPosition;
+
+ return S_OK;
+}
+
+HRESULT TextAnalyzerHelper::GetLocaleName(UINT32 textPosition, UINT32* textLength, const WCHAR** localeName)
+{
+ *localeName = m_localeName;
+ *textLength = m_bufferLength - textPosition;
+
+ return S_OK;
+}
+
+HRESULT TextAnalyzerHelper::GetNumberSubstitution(UINT32 textPosition, UINT32* textLength, IDWriteNumberSubstitution** numberSubstitution)
+{
+ *textLength = m_bufferLength - textPosition;
+ return S_OK;
+}
+
+HRESULT TextAnalyzerHelper::SetLineBreakpoints(UINT32 textPosition, UINT32 textLength, const DWRITE_LINE_BREAKPOINT*)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT TextAnalyzerHelper::SetScriptAnalysis(UINT32 textPosition, UINT32 textLength, const DWRITE_SCRIPT_ANALYSIS* analysis)
+{
+ m_analysis = *analysis;
+
+ return S_OK;
+}
+
+HRESULT TextAnalyzerHelper::SetBidiLevel(UINT32 textPosition, UINT32 textLength, UINT8 explicitLevel, UINT8 resolvedLevel)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT TextAnalyzerHelper::SetNumberSubstitution(UINT32 textPosition, UINT32 textLength, IDWriteNumberSubstitution*)
+{
+ return E_NOTIMPL;
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinTextAnalyzerHelperh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.h (0 => 206597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/win/TextAnalyzerHelper.h        2016-09-29 18:45:08 UTC (rev 206597)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2016 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. ``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
+ * 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.
+ */
+
+#pragma once
+
+#include <dwrite.h>
+
+namespace WebCore {
+
+struct TextAnalyzerHelper : public IDWriteTextAnalysisSink, IDWriteTextAnalysisSource {
+ TextAnalyzerHelper(WCHAR* localeName, WCHAR* buffer, unsigned bufferLength);
+
+ // IUnknown
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID, _COM_Outptr_ void**);
+ virtual ULONG STDMETHODCALLTYPE AddRef();
+ virtual ULONG STDMETHODCALLTYPE Release();
+
+ // IDWriteTextAnalysisSource
+ virtual HRESULT STDMETHODCALLTYPE GetTextAtPosition(UINT32 textPosition, const WCHAR** textString, UINT32* textLength);
+ virtual HRESULT STDMETHODCALLTYPE GetTextBeforePosition(UINT32 textPosition, const WCHAR** textString, UINT32* textLength);
+ virtual DWRITE_READING_DIRECTION STDMETHODCALLTYPE GetParagraphReadingDirection() { return DWRITE_READING_DIRECTION_LEFT_TO_RIGHT; }
+ virtual HRESULT STDMETHODCALLTYPE GetLocaleName(UINT32 textPosition, UINT32* textLength, const WCHAR** localeName);
+ virtual HRESULT STDMETHODCALLTYPE GetNumberSubstitution(UINT32 textPosition, UINT32* textLength, IDWriteNumberSubstitution**);
+
+ // IDWriteTextAnalysisSink
+ virtual HRESULT STDMETHODCALLTYPE SetLineBreakpoints(UINT32 textPosition, UINT32 textLength, const DWRITE_LINE_BREAKPOINT*);
+ virtual HRESULT STDMETHODCALLTYPE SetScriptAnalysis(UINT32 textPosition, UINT32 textLength, const DWRITE_SCRIPT_ANALYSIS*);
+ virtual HRESULT STDMETHODCALLTYPE SetBidiLevel(UINT32 textPosition, UINT32 textLength, UINT8 explicitLevel, UINT8 resolvedLevel);
+ virtual HRESULT STDMETHODCALLTYPE SetNumberSubstitution(UINT32 textPosition, UINT32 textLength, IDWriteNumberSubstitution*);
+
+ WCHAR* m_localeName { nullptr };
+ WCHAR* m_buffer { nullptr };
+ unsigned m_bufferLength { 0 };
+ DWRITE_SCRIPT_ANALYSIS m_analysis { };
+ ULONG m_refCount { 0 };
+};
+
+}
</ins></span></pre>
</div>
</div>
</body>
</html>