Title: [103155] trunk
Revision
103155
Author
[email protected]
Date
2011-12-17 12:23:37 -0800 (Sat, 17 Dec 2011)

Log Message

Text dispappear when SVG font has no latin character
https://bugs.webkit.org/show_bug.cgi?id=71765

Reviewed by Nikolas Zimmermann.

Source/WebCore:

Initialize SVG font metrics even if the font doesn't contain latin characters.

Test: svg/custom/svg-fonts-no-latin-glyph.html

* svg/SVGFontData.cpp:
(WebCore::SVGFontData::initializeFontData): Initializes metrics even if the zeroGlyphPage doesn't exist.

LayoutTests:

Test that text can be displayed with a SVG font which has no latin character.

* svg/custom/svg-fonts-no-latin-glyph-expected.txt: Added.
* svg/custom/resources/no-latin-glyph-font.svg: Added.
* svg/custom/svg-fonts-no-latin-glyph.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (103154 => 103155)


--- trunk/LayoutTests/ChangeLog	2011-12-17 20:09:35 UTC (rev 103154)
+++ trunk/LayoutTests/ChangeLog	2011-12-17 20:23:37 UTC (rev 103155)
@@ -1,3 +1,16 @@
+2011-12-17  Kenichi Ishibashi  <[email protected]>
+
+        Text dispappear when SVG font has no latin character
+        https://bugs.webkit.org/show_bug.cgi?id=71765
+
+        Reviewed by Nikolas Zimmermann.
+
+        Test that text can be displayed with a SVG font which has no latin character.
+
+        * svg/custom/svg-fonts-no-latin-glyph-expected.txt: Added.
+        * svg/custom/resources/no-latin-glyph-font.svg: Added.
+        * svg/custom/svg-fonts-no-latin-glyph.html: Added.
+
 2011-12-17  Adrienne Walker  <[email protected]>
 
         [chromium] Rebaseline huge-layer-rotated after r103129.

Added: trunk/LayoutTests/svg/custom/resources/no-latin-glyph-font.svg (0 => 103155)


--- trunk/LayoutTests/svg/custom/resources/no-latin-glyph-font.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/resources/no-latin-glyph-font.svg	2011-12-17 20:23:37 UTC (rev 103155)
@@ -0,0 +1,18 @@
+<svg width="100%" height="100%" version="1.1"
+ xmlns='http://www.w3.org/2000/svg' style="display:none;">
+  <defs>
+    <font id="Font" horiz-adv-x="1000">
+      <font-face font-family="Font" font-weight="normal" font-style="normal"
+          units-per-em="1000" cap-height="600" x-height="400"
+          ascent="700" descent="300"
+          alphabetic="0" mathematical="350" ideographic="400" hanging="500">
+        <font-face-src>
+          <font-face-name name="Font"/>
+        </font-face-src>
+      </font-face>
+      <missing-glyph><path d="M0,0h200v200h-200z"/></missing-glyph>
+      <glyph unicode="あ" horiz-adv-x="427" d="M288.642 270q0 -32.39 -20.374 -55.367q-20.375 -22.977 -52.313 -22.977q-34.227 0 -55.286 20.252q-21.059 20.252 -21.059 55.229v326.435q0 30.548 20.971 51.824q20.971 21.275 54.263 21.275q33.487 0 53.642 -20.085q20.156 -20.084 20.156 -51.061v-325.525z
+M289.535 74.0771q0 -31.0502 -21.975 -53.0251q-21.975 -21.9749 -53.025 -21.9749t-53.025 21.9749q-21.975 21.9749 -21.975 53.0251q0 31.1949 21.975 53.1709q21.975 21.975 53.025 21.975t53.025 -21.975q21.975 -21.976 21.975 -53.1709z" />
+    </font>
+  </defs>
+</svg>

Added: trunk/LayoutTests/svg/custom/svg-fonts-no-latin-glyph-expected.txt (0 => 103155)


--- trunk/LayoutTests/svg/custom/svg-fonts-no-latin-glyph-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/svg-fonts-no-latin-glyph-expected.txt	2011-12-17 20:23:37 UTC (rev 103155)
@@ -0,0 +1,5 @@
+Following character should be rendered as an exlamation.
+
+あ
+character height is 16
+PASS

Added: trunk/LayoutTests/svg/custom/svg-fonts-no-latin-glyph.html (0 => 103155)


--- trunk/LayoutTests/svg/custom/svg-fonts-no-latin-glyph.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/svg-fonts-no-latin-glyph.html	2011-12-17 20:23:37 UTC (rev 103155)
@@ -0,0 +1,34 @@
+<head>
+<style>
+@font-face {
+    font-family: f;
+    src: url(resources/no-latin-glyph-font.svg#Font) format("svg");
+}
+</style>
+<script>
+function doTest() {
+    var height = document.getElementById('text').offsetHeight;
+    var result = document.getElementById('result');
+    result.innerHTML = 'character height is ' + height + '<br />';
+    if (height == 16)
+        result.innerHTML += 'PASS';
+    else
+        result.innerHTML += 'FAIL';
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+</script>
+</head>
+<body>
+<p>Following character should be rendered as an exlamation.</p>
+<span id="text" style="font-family: f;">&#x3042;</span>
+<div id="result"></div>
+<script>
+document.body.offsetWidth;
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+window.addEventListener('load', doTest, true);
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (103154 => 103155)


--- trunk/Source/WebCore/ChangeLog	2011-12-17 20:09:35 UTC (rev 103154)
+++ trunk/Source/WebCore/ChangeLog	2011-12-17 20:23:37 UTC (rev 103155)
@@ -1,3 +1,17 @@
+2011-12-17  Kenichi Ishibashi  <[email protected]>
+
+        Text dispappear when SVG font has no latin character
+        https://bugs.webkit.org/show_bug.cgi?id=71765
+
+        Reviewed by Nikolas Zimmermann.
+
+        Initialize SVG font metrics even if the font doesn't contain latin characters.
+
+        Test: svg/custom/svg-fonts-no-latin-glyph.html
+
+        * svg/SVGFontData.cpp:
+        (WebCore::SVGFontData::initializeFontData): Initializes metrics even if the zeroGlyphPage doesn't exist.
+
 2011-12-17  David Barton  <[email protected]>
 
         Radical sign drawn incorrectly due to refactoring typo

Modified: trunk/Source/WebCore/svg/SVGFontData.cpp (103154 => 103155)


--- trunk/Source/WebCore/svg/SVGFontData.cpp	2011-12-17 20:09:35 UTC (rev 103154)
+++ trunk/Source/WebCore/svg/SVGFontData.cpp	2011-12-17 20:23:37 UTC (rev 103155)
@@ -63,13 +63,6 @@
     fontData->setZeroWidthSpaceGlyph(0);
     fontData->determinePitch();
 
-    GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(fontData, 0)->page();
-    if (!glyphPageZero) {
-        fontData->setSpaceGlyph(0);
-        fontData->setSpaceWidth(0);
-        return;
-    }
-
     unsigned unitsPerEm = svgFontFaceElement->unitsPerEm();
     float scale = scaleEmToUnits(fontSize, unitsPerEm);
     float xHeight = svgFontFaceElement->xHeight() * scale;
@@ -77,7 +70,9 @@
     float descent = svgFontFaceElement->descent() * scale;
     float lineGap = 0.1f * fontSize;
 
-    if (!xHeight) {
+    GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(fontData, 0)->page();
+
+    if (!xHeight && glyphPageZero) {
         // Fallback if x_heightAttr is not specified for the font element.
         Glyph letterXGlyph = glyphPageZero->glyphDataForCharacter('x').glyph;
         xHeight = letterXGlyph ? fontData->widthForGlyph(letterXGlyph) : 2 * ascent / 3;
@@ -91,6 +86,14 @@
     fontMetrics.setLineSpacing(roundf(ascent) + roundf(descent) + roundf(lineGap));
     fontMetrics.setXHeight(xHeight);
 
+    if (!glyphPageZero) {
+        fontData->setSpaceGlyph(0);
+        fontData->setSpaceWidth(0);
+        fontData->setAvgCharWidth(0);
+        fontData->setMaxCharWidth(ascent);
+        return;
+    }
+
     // Calculate space width.
     Glyph spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
     fontData->setSpaceGlyph(spaceGlyph);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to