Title: [192894] trunk
Revision
192894
Author
mmaxfi...@apple.com
Date
2015-12-01 11:10:07 -0800 (Tue, 01 Dec 2015)

Log Message

[Win] Web fonts with small caps have excess whitespace with the complex text codepath
https://bugs.webkit.org/show_bug.cgi?id=151698

Reviewed by Darin Adler.

Source/WebCore:

When performing small-caps on OS X, we bake in the smaller font size into the platform's native font
object. On Windows, we currently don't do that; instead, we just change some ancillary data inside
the FontPlatformData, and our advance & drawing calculations are sensitive to this ancillary data.
However, in the complex text codepath, Uniscribe only takes the native font object as input, and
therefore operates with the wrong font size.

The solution is to bake the smaller font size into the native platform font on Windows, similar to
OS X. It isn't clear why we didn't do this previously, but it seems like we weren't sure that
Windows would select the correct font when we provide new selection criteria. However, for web fonts,
we already use the same mechanism (CreateFontIndirect()) when we create the font in the first place;
therefore, this scaled font request will always work as well.

Test: fast/text/small-caps-complex.html

* platform/graphics/win/SimpleFontDataWin.cpp:
(WebCore::Font::platformCreateScaledFont): Deleted.

LayoutTests:

* fast/text/resources/tinyfont.svg: Added.
* fast/text/small-caps-complex-expected.html: Added.
* fast/text/small-caps-complex.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (192893 => 192894)


--- trunk/LayoutTests/ChangeLog	2015-12-01 19:08:48 UTC (rev 192893)
+++ trunk/LayoutTests/ChangeLog	2015-12-01 19:10:07 UTC (rev 192894)
@@ -1,3 +1,14 @@
+2015-12-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Win] Web fonts with small caps have excess whitespace with the complex text codepath
+        https://bugs.webkit.org/show_bug.cgi?id=151698
+
+        Reviewed by Darin Adler.
+
+        * fast/text/resources/tinyfont.svg: Added.
+        * fast/text/small-caps-complex-expected.html: Added.
+        * fast/text/small-caps-complex.html: Added.
+
 2015-12-01  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking http/tests/xmlhttprequest/workers/methods.html as flaky on Yosemite WK2

Added: trunk/LayoutTests/fast/text/resources/tinyfont.svg (0 => 192894)


--- trunk/LayoutTests/fast/text/resources/tinyfont.svg	                        (rev 0)
+++ trunk/LayoutTests/fast/text/resources/tinyfont.svg	2015-12-01 19:10:07 UTC (rev 192894)
@@ -0,0 +1,13 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
+<svg xmlns="http://www.w3.org/2000/svg">
+<metadata></metadata>
+<defs>
+<font id="Litherum" horiz-adv-x="100">
+<font-face units-per-em="100" ascent="80" descent="-20"/>
+<glyph unicode=" "/>
+<glyph horiz-adv-x="80" unicode="e&#x300;" d="M0 -20v100h100v-100z"/>
+<glyph horiz-adv-x="80" unicode="&#xe8;" d="M0 -20v100h100v-100z"/>
+</font>
+</defs>
+</svg>

Added: trunk/LayoutTests/fast/text/small-caps-complex-expected.html (0 => 192894)


--- trunk/LayoutTests/fast/text/small-caps-complex-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/small-caps-complex-expected.html	2015-12-01 19:10:07 UTC (rev 192894)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebAhem";
+    src: url("../../resources/Ahem.ttf") format(truetype);
+}
+@font-face {
+    font-family: "WebFallbackFont";
+    src: url("resources/tinyfont.svg") format("svg");
+}
+</style>
+</head>
+<body>
+This test makes sure that small-caps works in both the simple and complex text codepaths.
+<div style="position: relative;">
+<div style="font: 100px WebAhem, WebFallbackFont; font-variant: small-caps;">a&#xe8;bcd</div>
+<div style="position: absolute; left: 50px; top: 0px; width: 125px; height: 100px; background-color: black;"></div>
+<div style="position: absolute; left: 350px; top: 0px; width: 20px; height: 100px; background-color: black;"></div>
+</div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/text/small-caps-complex-expected.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/text/small-caps-complex.html (0 => 192894)


--- trunk/LayoutTests/fast/text/small-caps-complex.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/small-caps-complex.html	2015-12-01 19:10:07 UTC (rev 192894)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebAhem";
+    src: url("../../resources/Ahem.ttf") format("truetype");
+}
+@font-face {
+    font-family: "WebFallbackFont";
+    src: url("resources/tinyfont.svg") format("svg");
+}
+</style>
+</head>
+<body>
+This test makes sure that small-caps works in both the simple and complex text codepaths.
+<div style="position: relative;">
+<div style="font: 100px WebAhem, WebFallbackFont; font-variant: small-caps;">ae&#x300;bcd</div>
+<div style="position: absolute; left: 50px; top: 0px; width: 125px; height: 100px; background-color: black;"></div>
+<div style="position: absolute; left: 350px; top: 0px; width: 20px; height: 100px; background-color: black;"></div>
+</div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/text/small-caps-complex.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (192893 => 192894)


--- trunk/Source/WebCore/ChangeLog	2015-12-01 19:08:48 UTC (rev 192893)
+++ trunk/Source/WebCore/ChangeLog	2015-12-01 19:10:07 UTC (rev 192894)
@@ -1,3 +1,27 @@
+2015-12-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Win] Web fonts with small caps have excess whitespace with the complex text codepath
+        https://bugs.webkit.org/show_bug.cgi?id=151698
+
+        Reviewed by Darin Adler.
+
+        When performing small-caps on OS X, we bake in the smaller font size into the platform's native font
+        object. On Windows, we currently don't do that; instead, we just change some ancillary data inside
+        the FontPlatformData, and our advance & drawing calculations are sensitive to this ancillary data.
+        However, in the complex text codepath, Uniscribe only takes the native font object as input, and
+        therefore operates with the wrong font size.
+
+        The solution is to bake the smaller font size into the native platform font on Windows, similar to
+        OS X. It isn't clear why we didn't do this previously, but it seems like we weren't sure that
+        Windows would select the correct font when we provide new selection criteria. However, for web fonts,
+        we already use the same mechanism (CreateFontIndirect()) when we create the font in the first place;
+        therefore, this scaled font request will always work as well.
+
+        Test: fast/text/small-caps-complex.html
+
+        * platform/graphics/win/SimpleFontDataWin.cpp:
+        (WebCore::Font::platformCreateScaledFont): Deleted.
+
 2015-12-01  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: storage/indexeddb/create-and-remove-object-store.html fails.

Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp (192893 => 192894)


--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp	2015-12-01 19:08:48 UTC (rev 192893)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp	2015-12-01 19:10:07 UTC (rev 192894)
@@ -135,12 +135,6 @@
 RefPtr<Font> Font::platformCreateScaledFont(const FontDescription& fontDescription, float scaleFactor) const
 {
     float scaledSize = scaleFactor * m_platformData.size();
-    if (isCustomFont()) {
-        FontPlatformData scaledFont(m_platformData);
-        scaledFont.setSize(scaledSize);
-        return Font::create(scaledFont, true, false);
-    }
-
     LOGFONT winfont;
     GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winfont);
     winfont.lfHeight = -lroundf(scaledSize * (m_platformData.useGDI() ? 1 : 32));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to