Title: [174466] trunk
Revision
174466
Author
[email protected]
Date
2014-10-08 11:55:59 -0700 (Wed, 08 Oct 2014)

Log Message

Text drawn with an SVG font has no spaces when word-rounding hacks are enabled
https://bugs.webkit.org/show_bug.cgi?id=137463

Reviewed by Darin Adler.

Source/WebCore:

When rounding hacks are enabled, we use the "adjusted space width" instead of the
regular space width. However, the SVG-font-specific implementation of the
SimpleFontData constructor doesn't initialize this value, so it was getting set
to an undefined value (which happened to be close to 0 in my tests).

Test: svg/text/svg-font-word-rounding-hacks-spaces.html

* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::getFontData):
(WebCore::CSSFontFaceSource::ensureFontData):
* loader/cache/CachedFont.cpp:
(WebCore::CachedFont::ensureCustomFontData):
(WebCore::CachedFont::getSVGFontById):
* platform/graphics/SimpleFontData.h:
* svg/SVGFontData.cpp:
(WebCore::SVGFontData::initializeFontData):

LayoutTests:

Make sure that spaces are present.

* svg/text/svg-font-word-rounding-hacks-spaces.html:
* svg/text/svg-font-word-rounding-hacks-spaces-expected.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (174465 => 174466)


--- trunk/LayoutTests/ChangeLog	2014-10-08 18:32:12 UTC (rev 174465)
+++ trunk/LayoutTests/ChangeLog	2014-10-08 18:55:59 UTC (rev 174466)
@@ -1,3 +1,15 @@
+2014-10-08  Myles C. Maxfield  <[email protected]>
+
+        Text drawn with an SVG font has no spaces when word-rounding hacks are enabled
+        https://bugs.webkit.org/show_bug.cgi?id=137463
+
+        Reviewed by Darin Adler.
+
+        Make sure that spaces are present.
+
+        * svg/text/svg-font-word-rounding-hacks-spaces.html:
+        * svg/text/svg-font-word-rounding-hacks-spaces-expected.html:
+
 2014-10-08  Simon Fraser  <[email protected]>
 
         Remove tests that always pass from the TestExpectations files.

Modified: trunk/LayoutTests/svg/text/resources/Litherum.svg (174465 => 174466)


--- trunk/LayoutTests/svg/text/resources/Litherum.svg	2014-10-08 18:32:12 UTC (rev 174465)
+++ trunk/LayoutTests/svg/text/resources/Litherum.svg	2014-10-08 18:55:59 UTC (rev 174466)
@@ -3,10 +3,12 @@
 <svg xmlns="http://www.w3.org/2000/svg">
 <metadata></metadata>
 <defs>
-<font id="Litherum" horiz-adv-x="1024">
+<font id="Litherum" horiz-adv-x="14">
 <font-face units-per-em="14" ascent="14" descent="-7"/>
-<glyph unicode="|" horiz-adv-x="14" d="M5 -7v21h4v-21z"/>
-<glyph unicode="&#x20001;" horiz-adv-x="14" d="M5 -7v21h4v-21z"/>
+<glyph unicode="|" d="M5 -7v21h4v-21z"/>
+<glyph unicode="&#x20001;" d="M5 -7v21h4v-21z"/>
+<glyph unicode="a" d="M0 -7v21h14v-21z"/>
+<glyph unicode=" "/>
 </font>
 </defs>
 </svg>

Added: trunk/LayoutTests/svg/text/svg-font-word-rounding-hacks-spaces-expected.html (0 => 174466)


--- trunk/LayoutTests/svg/text/svg-font-word-rounding-hacks-spaces-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/text/svg-font-word-rounding-hacks-spaces-expected.html	2014-10-08 18:55:59 UTC (rev 174466)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.blackbox {
+    display: inline-block;
+    width: 14px;
+    height: 21px;
+    background: black;
+}
+.whitebox {
+    display: inline-block;
+    width: 14px;
+    height: 21px;
+    background: white;
+}
+</style>
+</head>
+<body>
+This test makes sure that text drawn with an SVG font with word-wrapping hacks has spaces.
+The test is successful if the space between the two boxes below is the same as the width of each of the boxes.
+<div><div class="blackbox"></div><div class="whitebox"></div><div class="blackbox"></div></div>
+</body>
+</html>

Added: trunk/LayoutTests/svg/text/svg-font-word-rounding-hacks-spaces.html (0 => 174466)


--- trunk/LayoutTests/svg/text/svg-font-word-rounding-hacks-spaces.html	                        (rev 0)
+++ trunk/LayoutTests/svg/text/svg-font-word-rounding-hacks-spaces.html	2014-10-08 18:55:59 UTC (rev 174466)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: 'Litherum';
+    src: url("resources/Litherum.svg") format(svg)
+}
+</style>
+<script>
+if (window.internals)
+    window.internals.allowRoundingHacks();
+</script>
+</head>
+<body>
+This test makes sure that text drawn with an SVG font with word-wrapping hacks has spaces.
+The test is successful if the space between the two boxes below is the same as the width of each of the boxes.
+<div style="font: 14px Litherum;">a a</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (174465 => 174466)


--- trunk/Source/WebCore/ChangeLog	2014-10-08 18:32:12 UTC (rev 174465)
+++ trunk/Source/WebCore/ChangeLog	2014-10-08 18:55:59 UTC (rev 174466)
@@ -1,3 +1,27 @@
+2014-10-08  Myles C. Maxfield  <[email protected]>
+
+        Text drawn with an SVG font has no spaces when word-rounding hacks are enabled
+        https://bugs.webkit.org/show_bug.cgi?id=137463
+
+        Reviewed by Darin Adler.
+
+        When rounding hacks are enabled, we use the "adjusted space width" instead of the
+        regular space width. However, the SVG-font-specific implementation of the
+        SimpleFontData constructor doesn't initialize this value, so it was getting set
+        to an undefined value (which happened to be close to 0 in my tests).
+
+        Test: svg/text/svg-font-word-rounding-hacks-spaces.html
+
+        * css/CSSFontFaceSource.cpp:
+        (WebCore::CSSFontFaceSource::getFontData):
+        (WebCore::CSSFontFaceSource::ensureFontData):
+        * loader/cache/CachedFont.cpp:
+        (WebCore::CachedFont::ensureCustomFontData):
+        (WebCore::CachedFont::getSVGFontById):
+        * platform/graphics/SimpleFontData.h:
+        * svg/SVGFontData.cpp:
+        (WebCore::SVGFontData::initializeFontData):
+
 2014-10-08  Brent Fulgham  <[email protected]>
 
         [Win] Resolve various static analyzer warnings in WebCore.

Modified: trunk/Source/WebCore/platform/graphics/SimpleFontData.h (174465 => 174466)


--- trunk/Source/WebCore/platform/graphics/SimpleFontData.h	2014-10-08 18:32:12 UTC (rev 174465)
+++ trunk/Source/WebCore/platform/graphics/SimpleFontData.h	2014-10-08 18:55:59 UTC (rev 174466)
@@ -159,7 +159,11 @@
 
     float spaceWidth() const { return m_spaceWidth; }
     float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
-    void setSpaceWidth(float spaceWidth) { m_spaceWidth = spaceWidth; }
+    void setSpaceWidths(float spaceWidth)
+    {
+        m_spaceWidth = spaceWidth;
+        m_adjustedSpaceWidth = spaceWidth;
+    }
 
 #if USE(CG) || USE(CAIRO)
     float syntheticBoldOffset() const { return m_syntheticBoldOffset; }

Modified: trunk/Source/WebCore/svg/SVGFontData.cpp (174465 => 174466)


--- trunk/Source/WebCore/svg/SVGFontData.cpp	2014-10-08 18:32:12 UTC (rev 174465)
+++ trunk/Source/WebCore/svg/SVGFontData.cpp	2014-10-08 18:55:59 UTC (rev 174466)
@@ -98,7 +98,7 @@
 
     if (!glyphPageZero) {
         fontData->setSpaceGlyph(0);
-        fontData->setSpaceWidth(0);
+        fontData->setSpaceWidths(0);
         fontData->setAvgCharWidth(0);
         fontData->setMaxCharWidth(ascent);
         return;
@@ -107,7 +107,7 @@
     // Calculate space width.
     Glyph spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
     fontData->setSpaceGlyph(spaceGlyph);
-    fontData->setSpaceWidth(fontData->widthForGlyph(spaceGlyph));
+    fontData->setSpaceWidths(fontData->widthForGlyph(spaceGlyph));
 
     // Estimate average character width.
     Glyph numeralZeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to