- Revision
- 201228
- Author
- [email protected]
- Date
- 2016-05-20 15:10:58 -0700 (Fri, 20 May 2016)
Log Message
[Cocoa] REGRESSION(r184899): Ascent adjustments are applied to web fonts
https://bugs.webkit.org/show_bug.cgi?id=157954
<rdar://problem/24204349>
Reviewed by Dean Jackson.
Source/WebCore:
There are a few specific fonts which exist on Windows and Cocoa OSes, and we will adjust
the ascents of these fonts to better match their counterparts on Windows. However, in
r184899, we started applying this adjustment to web fonts too.
Test: fast/text/ascent-adjustment-webfont.html
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::platformInit):
* svg/SVGToOTFFontConversion.cpp: We were reporting the length of font names wrong, so
it made the test pass without this patch even when it shouldn't have. Previously, we
were recording the number of characters in the font, not the number of bytes (each
character is 2 bytes).
LayoutTests:
* fast/text/ascent-adjustment-webfont-expected-mismatch.html: Added.
* fast/text/ascent-adjustment-webfont.html: Added.
* fast/text/resources/Helvetica-light.svg: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (201227 => 201228)
--- trunk/LayoutTests/ChangeLog 2016-05-20 22:05:01 UTC (rev 201227)
+++ trunk/LayoutTests/ChangeLog 2016-05-20 22:10:58 UTC (rev 201228)
@@ -1,3 +1,15 @@
+2016-05-20 Myles C. Maxfield <[email protected]>
+
+ [Cocoa] REGRESSION(r184899): Ascent adjustments are applied to web fonts
+ https://bugs.webkit.org/show_bug.cgi?id=157954
+ <rdar://problem/24204349>
+
+ Reviewed by Dean Jackson.
+
+ * fast/text/ascent-adjustment-webfont-expected-mismatch.html: Added.
+ * fast/text/ascent-adjustment-webfont.html: Added.
+ * fast/text/resources/Helvetica-light.svg: Added.
+
2016-05-20 Enrica Casucci <[email protected]>
Drag cannot start if no drag data or custom data is available in the Pasteboard.
Added: trunk/LayoutTests/fast/text/ascent-adjustment-webfont-expected-mismatch.html (0 => 201228)
--- trunk/LayoutTests/fast/text/ascent-adjustment-webfont-expected-mismatch.html (rev 0)
+++ trunk/LayoutTests/fast/text/ascent-adjustment-webfont-expected-mismatch.html 2016-05-20 22:10:58 UTC (rev 201228)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div style="position: absolute; left: 8px; top: 18px; font: 100px Helvetica">l</div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/text/ascent-adjustment-webfont.html (0 => 201228)
--- trunk/LayoutTests/fast/text/ascent-adjustment-webfont.html (rev 0)
+++ trunk/LayoutTests/fast/text/ascent-adjustment-webfont.html 2016-05-20 22:10:58 UTC (rev 201228)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+ font-family: "HelveticaLight";
+ src: url("resources/Helvetica_light.svg") format("svg");
+}
+</style>
+</head>
+<body>
+<!-- Inside Font::platformInit(), we adjust the ascent of some fonts to make them better match the metrics of their Windows counterparts. However, we should only do that for preinstalled fonts, not web fonts. Therefore, the ascent for a web font Helvetica should not be the same as for a preinstalled font Helvetica. -->
+<div style="position: absolute; left: 8px; top: 13px; font: 100px HelveticaLight">l</div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/text/resources/Helvetica_light.svg (0 => 201228)
--- trunk/LayoutTests/fast/text/resources/Helvetica_light.svg (rev 0)
+++ trunk/LayoutTests/fast/text/resources/Helvetica_light.svg 2016-05-20 22:10:58 UTC (rev 201228)
@@ -0,0 +1,10 @@
+<?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">
+<defs>
+<font id="HelveticaLight" horiz-adv-x="1024">
+<font-face units-per-em="2048" ascent="1577" descent="-471" font-family="Helvetica"/>
+<glyph unicode="l" horiz-adv-x="455" d="M137 1469H317V0H137z"/>
+</font>
+</defs>
+</svg>
Modified: trunk/Source/WebCore/ChangeLog (201227 => 201228)
--- trunk/Source/WebCore/ChangeLog 2016-05-20 22:05:01 UTC (rev 201227)
+++ trunk/Source/WebCore/ChangeLog 2016-05-20 22:10:58 UTC (rev 201228)
@@ -1,3 +1,24 @@
+2016-05-20 Myles C. Maxfield <[email protected]>
+
+ [Cocoa] REGRESSION(r184899): Ascent adjustments are applied to web fonts
+ https://bugs.webkit.org/show_bug.cgi?id=157954
+ <rdar://problem/24204349>
+
+ Reviewed by Dean Jackson.
+
+ There are a few specific fonts which exist on Windows and Cocoa OSes, and we will adjust
+ the ascents of these fonts to better match their counterparts on Windows. However, in
+ r184899, we started applying this adjustment to web fonts too.
+
+ Test: fast/text/ascent-adjustment-webfont.html
+
+ * platform/graphics/cocoa/FontCocoa.mm:
+ (WebCore::Font::platformInit):
+ * svg/SVGToOTFFontConversion.cpp: We were reporting the length of font names wrong, so
+ it made the test pass without this patch even when it shouldn't have. Previously, we
+ were recording the number of characters in the font, not the number of bytes (each
+ character is 2 bytes).
+
2016-05-20 John Wilander <[email protected]>
Remove unnecessary PageOverlay client function pageOverlayDestroyed
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (201227 => 201228)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2016-05-20 22:05:01 UTC (rev 201227)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2016-05-20 22:10:58 UTC (rev 201228)
@@ -134,7 +134,7 @@
// incorrectly added to line spacing, so we use a 15% adjustment instead
// and add it to the ascent.
RetainPtr<CFStringRef> familyName = adoptCF(CTFontCopyFamilyName(m_platformData.font()));
- if (familyName && (CFStringCompare(familyName.get(), CFSTR("Times"), kCFCompareCaseInsensitive) == kCFCompareEqualTo
+ if (!m_isCustomFont && familyName && (CFStringCompare(familyName.get(), CFSTR("Times"), kCFCompareCaseInsensitive) == kCFCompareEqualTo
|| CFStringCompare(familyName.get(), CFSTR("Helvetica"), kCFCompareCaseInsensitive) == kCFCompareEqualTo
|| CFStringCompare(familyName.get(), CFSTR("Courier"), kCFCompareCaseInsensitive) == kCFCompareEqualTo))
ascent += floorf(((ascent + descent) * 0.15f) + 0.5f);
Modified: trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp (201227 => 201228)
--- trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp 2016-05-20 22:05:01 UTC (rev 201227)
+++ trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp 2016-05-20 22:10:58 UTC (rev 201228)
@@ -486,7 +486,7 @@
append16(3); // Unicode version 2.0 or later
append16(0); // Language
append16(1); // Name identifier. 1 = Font family
- append16(m_fontFamily.length());
+ append16(m_fontFamily.length() * 2);
append16(0); // Offset into name data
for (auto codeUnit : StringView(m_fontFamily).codeUnits())