Title: [196559] trunk/Source/WebCore
Revision
196559
Author
mmaxfi...@apple.com
Date
2016-02-13 18:20:14 -0800 (Sat, 13 Feb 2016)

Log Message

[Win] [SVG -> OTF Converter] SVG fonts drawn into ImageBuffers are invisible
https://bugs.webkit.org/show_bug.cgi?id=154222

Reviewed by Antti Koivisto.

Windows ImageBuffer code is sensitive to broken bounding box and
descent code.

Covered by existing tests.

* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::appendHHEATable):
(WebCore::SVGToOTFFontConverter::appendOS2Table):
(WebCore::SVGToOTFFontConverter::processGlyphElement):
(WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (196558 => 196559)


--- trunk/Source/WebCore/ChangeLog	2016-02-14 02:17:22 UTC (rev 196558)
+++ trunk/Source/WebCore/ChangeLog	2016-02-14 02:20:14 UTC (rev 196559)
@@ -1,3 +1,21 @@
+2016-02-13  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Win] [SVG -> OTF Converter] SVG fonts drawn into ImageBuffers are invisible
+        https://bugs.webkit.org/show_bug.cgi?id=154222
+
+        Reviewed by Antti Koivisto.
+
+        Windows ImageBuffer code is sensitive to broken bounding box and
+        descent code.
+
+        Covered by existing tests.
+
+        * svg/SVGToOTFFontConversion.cpp:
+        (WebCore::SVGToOTFFontConverter::appendHHEATable):
+        (WebCore::SVGToOTFFontConverter::appendOS2Table):
+        (WebCore::SVGToOTFFontConverter::processGlyphElement):
+        (WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter):
+
 2016-02-13  Antti Koivisto  <an...@apple.com>
 
         Add version number for default stylesheet

Modified: trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp (196558 => 196559)


--- trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp	2016-02-14 02:17:22 UTC (rev 196558)
+++ trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp	2016-02-14 02:20:14 UTC (rev 196559)
@@ -194,7 +194,7 @@
 
     uint32_t calculateChecksum(size_t startingOffset, size_t endingOffset) const;
 
-    void processGlyphElement(const SVGElement& glyphOrMissingGlyphElement, const SVGGlyphElement*, float defaultHorizontalAdvance, float defaultVerticalAdvance, const String& codepoints, Optional<FloatRect> boundingBox);
+    void processGlyphElement(const SVGElement& glyphOrMissingGlyphElement, const SVGGlyphElement*, float defaultHorizontalAdvance, float defaultVerticalAdvance, const String& codepoints, Optional<FloatRect>& boundingBox);
 
     typedef void (SVGToOTFFontConverter::*FontAppendingFunction)();
     void appendTable(const char identifier[4], FontAppendingFunction);
@@ -431,7 +431,7 @@
 {
     append32(0x00010000); // Version
     append16(clampTo<int16_t>(m_ascent));
-    append16(clampTo<int16_t>(m_descent));
+    append16(clampTo<int16_t>(-m_descent));
     // WebKit SVG font rendering has hard coded the line gap to be 1/10th of the font size since 2008 (see r29719).
     append16(clampTo<int16_t>(m_lineGap));
     append16(clampTo<uint16_t>(m_advanceWidthMax));
@@ -547,7 +547,7 @@
     append16(0); // First unicode index
     append16(0xFFFF); // Last unicode index
     append16(clampTo<int16_t>(m_ascent)); // Typographical ascender
-    append16(clampTo<int16_t>(m_descent)); // Typographical descender
+    append16(clampTo<int16_t>(-m_descent)); // Typographical descender
     append16(clampTo<int16_t>(m_lineGap)); // Typographical line gap
     append16(clampTo<uint16_t>(m_ascent)); // Windows-specific ascent
     append16(clampTo<uint16_t>(m_descent)); // Windows-specific descent
@@ -1285,7 +1285,7 @@
     return result;
 }
 
-void SVGToOTFFontConverter::processGlyphElement(const SVGElement& glyphOrMissingGlyphElement, const SVGGlyphElement* glyphElement, float defaultHorizontalAdvance, float defaultVerticalAdvance, const String& codepoints, Optional<FloatRect> boundingBox)
+void SVGToOTFFontConverter::processGlyphElement(const SVGElement& glyphOrMissingGlyphElement, const SVGGlyphElement* glyphElement, float defaultHorizontalAdvance, float defaultVerticalAdvance, const String& codepoints, Optional<FloatRect>& boundingBox)
 {
     bool ok;
     float horizontalAdvance = scaleUnitsPerEm(glyphOrMissingGlyphElement.fastGetAttribute(SVGNames::horiz_adv_xAttr).toFloat(&ok));
@@ -1423,8 +1423,10 @@
     Optional<FloatRect> boundingBox;
     if (m_missingGlyphElement)
         processGlyphElement(*m_missingGlyphElement, nullptr, defaultHorizontalAdvance, defaultVerticalAdvance, String(), boundingBox);
-    else
+    else {
         m_glyphs.append(GlyphData(Vector<char>(m_emptyGlyphCharString), nullptr, s_outputUnitsPerEm, s_outputUnitsPerEm, FloatRect(), String()));
+        boundingBox = FloatRect(0, 0, s_outputUnitsPerEm, s_outputUnitsPerEm);
+    }
 
     for (auto& glyphElement : childrenOfType<SVGGlyphElement>(m_fontElement)) {
         auto& unicodeAttribute = glyphElement.fastGetAttribute(SVGNames::unicodeAttr);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to