Work around a Cocoa font parsing bug
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Mar 2015 19:58:37 +0000 (19:58 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Mar 2015 19:58:37 +0000 (19:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142446
Source/WebCore:

<rdar://problem/20086223>

Reviewed by Simon Fraser.

Work around a bug in Cocoa regarding font parsing.

* svg/SVGToOTFFontConversion.cpp:

LayoutTests:

Reviewed by Simon Fraser.

Adding a few extra tests for bits of SVG fonts that could use some more tests.

* svg/fonts/resources/svg-font-general.svg: Updated and moved from svg-font-horiz-origin-font.svg
* svg/fonts/svg-font-general.html: Updated and moved from svg-font-horiz-origin.html
* svg/fonts/svg-font-general-expected.html: Updated and moved from svg-font-horiz-origin-expected.html

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181278 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/fonts/resources/svg-font-general.svg [new file with mode: 0644]
LayoutTests/svg/fonts/resources/svg-font-horiz-origin-font.svg [deleted file]
LayoutTests/svg/fonts/svg-font-general-expected.html [new file with mode: 0644]
LayoutTests/svg/fonts/svg-font-general.html [new file with mode: 0644]
LayoutTests/svg/fonts/svg-font-horiz-origin-expected.html [deleted file]
LayoutTests/svg/fonts/svg-font-horiz-origin.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGToOTFFontConversion.cpp

index 3a4945323ecc1d18b8b0880fd83adf290cf9c510..409678ca47dcc66670630545e29bcdb81e641def 100644 (file)
@@ -1,3 +1,16 @@
+2015-03-09  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Work around a Cocoa font parsing bug
+        https://bugs.webkit.org/show_bug.cgi?id=142446
+
+        Reviewed by Simon Fraser.
+
+        Adding a few extra tests for bits of SVG fonts that could use some more tests.
+
+        * svg/fonts/resources/svg-font-general.svg: Updated and moved from svg-font-horiz-origin-font.svg
+        * svg/fonts/svg-font-general.html: Updated and moved from svg-font-horiz-origin.html
+        * svg/fonts/svg-font-general-expected.html: Updated and moved from svg-font-horiz-origin-expected.html
+
 2015-03-09  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [SVG -> OTF Converter] x-height cannot be specified
diff --git a/LayoutTests/svg/fonts/resources/svg-font-general.svg b/LayoutTests/svg/fonts/resources/svg-font-general.svg
new file mode 100644 (file)
index 0000000..98e06ec
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" standalone="yes"?>
+<svg  version="1.1" viewBox="0 0 160 160" xmlns = 'http://www.w3.org/2000/svg' xmlns:xlink="http://www.w3.org/1999/xlink">
+  <defs>
+    <font id="Litherum" horiz-adv-x="1000">
+      <font-face units-per-em="1000" ascent="1000" descent="0">
+      </font-face>
+    <glyph unicode="A" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 H 500 z"/>
+    <glyph unicode="B" horiz-adv-x="1000"/>
+    </font>
+    <font id="Litherum2" horiz-adv-x="1000" horiz-origin-x="500" horiz-origin-y="300">
+      <font-face units-per-em="1000" ascent="1000" descent="0">
+      </font-face>
+    <glyph unicode="A" horiz-adv-x="1000" d="M 0 -300 H 500 V 300 H 0 z"/>
+    </font>
+    <font id="Litherum3" horiz-adv-x="1000">
+      <font-face font-weight="normal" font-style="normal" units-per-em="1000" cap-height="600" x-height="400" ascent="1000" descent="0">
+      </font-face>
+    <glyph unicode="A" d="M 0 0 H 500 V 600 H 0 z"/>
+    <glyph unicode="BC" horiz-adv-x="500" d="M 0 0 H 500 L 250 600 z"/>
+    <glyph unicode="&#x672c;" horiz-adv-x="500" d="M 0 0 H 500 L 0 600 z"/>
+    </font>
+    <font id="Litherum4" horiz-adv-x="500">
+      <font-face font-weight="normal" font-style="normal" units-per-em="1000" cap-height="600" x-height="400" ascent="1000" descent="0">
+      </font-face>
+    <glyph unicode="A" horiz-adv-x="1000" d="M 0 0 H 500 V 600 H 0 z"/>
+    <glyph unicode="D" horiz-adv-x="500" d="M 0 0 H 500 L 250 600 z"/>
+    <glyph unicode="&#x672c;" horiz-adv-x="500" d="M 0 0 H 500 L 0 600 z"/>
+    </font>
+    <font id="Litherum5" horiz-adv-x="500">
+    <glyph unicode="A" horiz-adv-x="1000" d="M 0 0 H 250 V 600 H 0 z"/>
+    </font>
+    <font id="Litherum6">
+      <font-face units-per-em="1000" ascent="1000" descent="1000">
+      </font-face>
+    <glyph unicode="A" horiz-adv-x="1000" d="M 0 0 V -1000 H 1000 V 1000 H 0 z"/>
+    <glyph unicode="B" horiz-adv-x="1000" d="M 0 0 H 1000 V 1000 H 0 z"/>
+    </font>
+    <font horiz-adv-x="1000" id="Litherum7">
+      <font-face units-per-em="1000" ascent="1000" descent="0"/>
+      <glyph unicode="A" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 z"/>
+    </font>
+    <font horiz-adv-x="1000" id="Litherum8">
+      <font-face units-per-em="1000" ascent="1000" descent="0"/>
+      <glyph unicode="A" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 z"/>
+      <missing-glyph d="M0 0V1000H1000V0z"/>
+    </font>
+  </defs>
+</svg>
diff --git a/LayoutTests/svg/fonts/resources/svg-font-horiz-origin-font.svg b/LayoutTests/svg/fonts/resources/svg-font-horiz-origin-font.svg
deleted file mode 100644 (file)
index ea6da9d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" standalone="yes"?>
-<svg  version="1.1" viewBox="0 0 160 160" xmlns = 'http://www.w3.org/2000/svg' xmlns:xlink="http://www.w3.org/1999/xlink">
-  <defs>
-    <font id="Litherum" horiz-adv-x="1000">
-      <font-face font-family="Litherum" font-weight="normal" font-style="normal" units-per-em="1000" cap-height="600" x-height="400" ascent="1000" descent="0" alphabetic="0" mathematical="500" ideographic="400" hanging="500">
-        <font-face-src>
-          <font-face-name name="Litherum"/>
-        </font-face-src>
-      </font-face>
-    <glyph unicode="A" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 H 500 z"/>
-    </font>
-    <font id="Litherum2" horiz-adv-x="1000" horiz-origin-x="500" horiz-origin-y="300">
-      <font-face font-family="Litherum" font-weight="normal" font-style="normal" units-per-em="1000" cap-height="600" x-height="400" ascent="1000" descent="0" alphabetic="0" mathematical="500" ideographic="400" hanging="500">
-        <font-face-src>
-          <font-face-name name="Litherum"/>
-        </font-face-src>
-      </font-face>
-    <glyph unicode="A" horiz-adv-x="1000" d="M 0 -300 H 500 V 300 H 0 z"/>
-    </font>
-  </defs>
-</svg>
diff --git a/LayoutTests/svg/fonts/svg-font-general-expected.html b/LayoutTests/svg/fonts/svg-font-general-expected.html
new file mode 100644 (file)
index 0000000..1c29b10
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: 'Litherum';
+    src: url("resources/svg-font-general.svg#Litherum2") format(svg);
+}
+@font-face {
+    font-family: 'Litherum4';
+    src: url("resources/svg-font-general.svg#Litherum4") format(svg);
+}
+@font-face {
+    font-family: 'Litherum8';
+    src: url("resources/svg-font-general.svg#Litherum8") format(svg);
+}
+.a {
+    font-family: 'Litherum4';
+}
+</style>
+</head>
+<body style="-webkit-font-smoothing: none;">
+These tests test horiz-origin, fallback of horiz-adv property, glyph rendering, ligatures, svg -&gt; native fallback, and units-per-em, respectively.
+<div><span style="font: 50px Litherum;">AAA</span><span style="position: relative; left: 50px;">AAA</span></div>
+<div><span style="font: 50px Litherum4;">AAA</span>AAA</div>
+<div><div style="display: inline-block; width: 150px; height: 52px; position: relative;"><div style="position: absolute; width: 25px; height: 30px; left: 0px; bottom: 0px; background: black;"></div><div style="position: absolute; width: 25px; height: 30px; left: 50px; bottom: 0px; background: black;"></div><div style="position: absolute; width: 25px; height: 30px; left: 100px; bottom: 0px; background: black;"></div></div>AAA</div>
+<div style="height: 7px;"></div>
+<div><span style="font: 50px Litherum4;">D</span><span style="font-size: 50px;">A</span></div>
+<div style="font-size: 50px;"><span class="a">A</span>Z<span class="a">A</span>Z<span class="a">A</span></span><span class="a">&#x672c;</span>N<span class="a">&#x672c;</span>N<span class="a">&#x672c;</span></span></div>
+<div style="display: inline-block; position: relative; width: 200px; height: 206px;"><div style="position: absolute; top: 2px; left: 0px; width: 50px; height: 100px; background: black;"></div><div style="position: absolute; top: 2px; left: 50px; width: 50px; height: 50px; background: black;"></div><div style="position: absolute; bottom: -1px; left: 0px; width: 50px; height: 100px; background: black;"></div><div style="position: absolute; bottom: 49px; left: 50px; width: 50px; height: 50px; background: black;"></div></div>
+<div style="font: 50px Litherum8; position: absolute; left: 400px; top: 100px;">A</div>
+</body>
+</html>
diff --git a/LayoutTests/svg/fonts/svg-font-general.html b/LayoutTests/svg/fonts/svg-font-general.html
new file mode 100644 (file)
index 0000000..2301be9
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: 'Litherum';
+    src: url("resources/svg-font-general.svg#Litherum") format(svg);
+}
+@font-face {
+    font-family: 'Litherum3';
+    src: url("resources/svg-font-general.svg#Litherum3") format(svg);
+}
+@font-face {
+    font-family: 'Litherum5';
+    src: url("resources/svg-font-general.svg#Litherum5") format(svg);
+}
+@font-face {
+    font-family: 'Litherum6';
+    src: url("resources/svg-font-general.svg#Litherum6") format(svg);
+}
+@font-face {
+    font-family: 'Litherum7';
+    src: url("resources/svg-font-general.svg#Litherum7") format(svg);
+}
+</style>
+</head>
+<body style="-webkit-font-smoothing: none;">
+These tests test horiz-origin, fallback of horiz-adv property, glyph rendering, ligatures, svg -&gt; native fallback, and units-per-em, respectively.
+<div><span style="font: 50px Litherum;">AAAB</span>AAA</div>
+<div><span style="font: 50px Litherum3;">AAA</span>AAA</div>
+<div><span style="font: 50px Litherum3;">AAA</span>AAA</div>
+<div><span style="font: 50px Litherum3;">BC</span><span style="font: 50px Litherum5;">A</span></div>
+<div style="font-size: 50px;"><span style="font-family: Litherum3, Times;">AZAZA</span><span style="font-family: Times, Litherum3">&#x672c;N&#x672c;N&#x672c;</span></div>
+<div style="font-size: 50px;"><span style="font-family: Litherum6;">AB</span><br/><span style="font-family: Litherum6;">AB</span></div>
+<div style="font: 50px Litherum7; position: absolute; left: 400px; top: 100px;">A</div>
+</body>
+</html>
diff --git a/LayoutTests/svg/fonts/svg-font-horiz-origin-expected.html b/LayoutTests/svg/fonts/svg-font-horiz-origin-expected.html
deleted file mode 100644 (file)
index 009d7d1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-@font-face {
-    font-family: 'Litherum';
-    src: url("resources/svg-font-horiz-origin-font.svg#Litherum2") format(svg)
-}
-</style>
-</head>
-<body>
-This test makes sure that the horiz-origin-x and horiz-origin-y attributes are correctly converted.
-<div><span style="font: 48px Litherum;">AAA</span>AAA</div>
-</body>
-</html>
diff --git a/LayoutTests/svg/fonts/svg-font-horiz-origin.html b/LayoutTests/svg/fonts/svg-font-horiz-origin.html
deleted file mode 100644 (file)
index 67f0a14..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-@font-face {
-    font-family: 'Litherum';
-    src: url("resources/svg-font-horiz-origin-font.svg#Litherum") format(svg)
-}
-</style>
-</head>
-<body>
-This test makes sure that the horiz-origin-x and horiz-origin-y attributes are correctly converted.
-<div><span style="font: 48px Litherum;">AAA</span>AAA</div>
-</body>
-</html>
index 36bb1c2c0dfc4d94b58050360f290a0896d00a07..b7fa73787b3889f3fd38bc1acf92976f6dfcc871 100644 (file)
@@ -1,3 +1,15 @@
+2015-03-09  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Work around a Cocoa font parsing bug
+        https://bugs.webkit.org/show_bug.cgi?id=142446
+        <rdar://problem/20086223>
+
+        Reviewed by Simon Fraser.
+
+        Work around a bug in Cocoa regarding font parsing.
+
+        * svg/SVGToOTFFontConversion.cpp:
+
 2015-03-09  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Fix the build after r181153
index 9466a42d60ae0b1129050f0932c9247764f7ee0c..955e5041e74b57af3b8fd30220f302f870527add 100644 (file)
@@ -1300,6 +1300,10 @@ SVGToOTFFontConverter::SVGToOTFFontConverter(const SVGFontElement& fontElement)
             processGlyphElement(glyphElement, &glyphElement, defaultHorizontalAdvance, defaultVerticalAdvance, unicodeAttribute, initialGlyph);
     }
 
+    // <rdar://problem/20086223> Cocoa has a bug where glyph bounding boxes are not correctly respected for frustum culling. Work around this by
+    // inflating the font's bounding box
+    m_boundingBox.extend(FloatPoint(0, 0));
+
     appendLigatureGlyphs();
 
     if (m_glyphs.size() > std::numeric_limits<Glyph>::max()) {