Changeset 178647 in webkit


Ignore:
Timestamp:
Jan 19, 2015 8:32:26 AM (9 years ago)
Author:
mmaxfield@apple.com
Message:

[SVG -> OTF Converter] Glyphs get clipped weirdly
https://bugs.webkit.org/show_bug.cgi?id=137095

Reviewed by Antti Koivisto.

The Adobe CFF spec doesn't actually tell you how to serialize a
"FontBBox." After trial and error, it seems to be (x, y, width,
height).

Test: svg/text/kerning.svg

svg/W3C-SVG-1.1/fonts-kern-01-t.svg

  • svg/SVGToOTFFontConversion.cpp:

(WebCore::SVGToOTFFontConverter::appendHEADTable):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::appendVHEATable):
(WebCore::CFFBuilder::CFFBuilder):
(WebCore::SVGToOTFFontConverter::transcodeGlyphPaths):
(WebCore::SVGToOTFFontConverter::processGlyphElement):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r178646 r178647  
     12015-01-19  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [SVG -> OTF Converter] Glyphs get clipped weirdly
     4        https://bugs.webkit.org/show_bug.cgi?id=137095
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The Adobe CFF spec doesn't actually tell you how to serialize a
     9        "FontBBox." After trial and error, it seems to be (x, y, width,
     10        height).
     11
     12        Test: svg/text/kerning.svg
     13              svg/W3C-SVG-1.1/fonts-kern-01-t.svg
     14
     15        * svg/SVGToOTFFontConversion.cpp:
     16        (WebCore::SVGToOTFFontConverter::appendHEADTable):
     17        (WebCore::SVGToOTFFontConverter::appendCFFTable):
     18        (WebCore::SVGToOTFFontConverter::appendVHEATable):
     19        (WebCore::CFFBuilder::CFFBuilder):
     20        (WebCore::SVGToOTFFontConverter::transcodeGlyphPaths):
     21        (WebCore::SVGToOTFFontConverter::processGlyphElement):
     22
    1232015-01-19  Csaba Osztrogonác  <ossy@webkit.org>
    224
  • trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp

    r178292 r178647  
    323323    append32(0); // First half of modification date
    324324    append32(0); // Last half of modification date
    325     append16(m_boundingBox.x()); // Minimum X
    326     append16(m_boundingBox.y()); // Minimum Y
    327     append16(m_boundingBox.maxX()); // Maximum X
    328     append16(m_boundingBox.maxY()); // Maximum Y
     325    append16(clampTo<int16_t>(m_boundingBox.x()));
     326    append16(clampTo<int16_t>(m_boundingBox.y()));
     327    append16(clampTo<int16_t>(m_boundingBox.maxX()));
     328    append16(clampTo<int16_t>(m_boundingBox.maxY()));
    329329    append16((m_italic ? 1 << 1 : 0) | (m_weight >= 7 ? 1 : 0));
    330330    append16(3); // Smallest readable size in pixels
     
    576576    append32(clampTo<int32_t>(m_boundingBox.x()));
    577577    m_result.append(operand32Bit);
    578     append32(clampTo<int32_t>(m_boundingBox.maxX()));
    579     m_result.append(operand32Bit);
    580578    append32(clampTo<int32_t>(m_boundingBox.y()));
    581579    m_result.append(operand32Bit);
    582     append32(clampTo<int32_t>(m_boundingBox.maxY()));
     580    append32(clampTo<int32_t>(m_boundingBox.width()));
     581    m_result.append(operand32Bit);
     582    append32(clampTo<int32_t>(m_boundingBox.height()));
    583583    m_result.append(fontBBoxKey);
    584584    m_result.append(operand32Bit);
     
    888888    append16(clampTo<int16_t>(-static_cast<int>(m_unitsPerEm / 2))); // Vertical typographic descender
    889889    append16(m_unitsPerEm / 10); // Vertical typographic line gap
     890    // FIXME: m_unitsPerEm is almost certainly not correct
    890891    append16(clampTo<int16_t>(m_advanceHeightMax));
    891892    append16(clampTo<int16_t>(m_unitsPerEm - m_boundingBox.maxY())); // Minimum top side bearing
     
    10501051        , m_hasBoundingBox(false)
    10511052    {
     1053        // FIXME: Moving to the origin isn't going to work for subsequent absolute coordinates
    10521054        writeCFFEncodedNumber(m_cffData, width);
    10531055        writeCFFEncodedNumber(m_cffData, origin.x());
     
    11501152    bool ok;
    11511153    float horizontalOriginX = glyphOrMissingGlyphElement.fastGetAttribute(SVGNames::horiz_origin_xAttr).toFloat(&ok);
    1152     if (!ok)
    1153         horizontalOriginX = m_fontFaceElement ? m_fontFaceElement->horizontalOriginX() : 0;
     1154    if (!ok && m_fontFaceElement)
     1155        horizontalOriginX = m_fontFaceElement->horizontalOriginX();
    11541156    float horizontalOriginY = glyphOrMissingGlyphElement.fastGetAttribute(SVGNames::horiz_origin_yAttr).toFloat(&ok);
    11551157    if (!ok && m_fontFaceElement)
    1156         horizontalOriginY = m_fontFaceElement ? m_fontFaceElement->horizontalOriginY() : 0;
     1158        horizontalOriginY = m_fontFaceElement->horizontalOriginY();
    11571159
    11581160    CFFBuilder builder(result, width, FloatPoint(horizontalOriginX, horizontalOriginY));
     
    11961198    initialGlyph = false;
    11971199
    1198     m_glyphs.append(GlyphData(WTF::move(path), glyphElement, horizontalAdvance, verticalAdvance, m_boundingBox, codepoints));
     1200    m_glyphs.append(GlyphData(WTF::move(path), glyphElement, horizontalAdvance, verticalAdvance, glyphBoundingBox, codepoints));
    11991201}
    12001202
Note: See TracChangeset for help on using the changeset viewer.