Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-1109

svggen.font.SVGFont doesn't always calculate the correct path

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7
    • Fix Version/s: None
    • Component/s: SVGGraphics2D
    • Labels:
      None

      Description

      We at PDFBox have used the code at
      https://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/svggen/font/SVGFont.java?view=markup
      for TT font rendering. There've been some problems (see PDFBOX-1435, scroll to second half), and after bugfixes didn't work (see PDFBOX-1206), I had the idea to create a SVG file by hand with the calculations mentioned in the file.

      I calculated the SVG values for the outer circle of that "o" of PDFBOX-1435 with the Batik source and added 100 to each y value (before I found out that svg allows translating). Here's the svg file I get:

      <?xml version="1.0" standalone="no"?>
      <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
        "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
      <svg width="12cm" height="12cm" viewBox="0 0 1200 1200"
           xmlns="http://www.w3.org/2000/svg" version="1.1">
        <rect x="1" y="1" width="1000" height="1000"
              fill="none" stroke="blue" stroke-width="1" />
      <g transform="scale(7)">
        <path d="M85,53 T74,49 T54,48.5 T39.5,59.5 T35.5,76.5 T44,94 T62,102 T79.5,97 T89.5,82.5 T88.5,63 Z"
              fill="none" stroke="red" stroke-width="5"  />
      </g>
      </svg>
      

      This can be displayed with firefox, and this "o" has an angle The reason is that the Batik algorithm doesn't work for contours made entirely with off-curve points.

      I didn't actually run the Batik code, the calculations were done on paper.

      Further thoughts on the TT path drawing algorithm can be found at PDFBOX-1206. We ended up using the code from PDF.js, and maybe you should too

        Attachments

        1. TestSVGGen.java
          2 kB
          Tilman Hausherr
        2. test.svg
          24 kB
          Tilman Hausherr
        3. FreeSans.ttf
          698 kB
          Tilman Hausherr

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tilman Tilman Hausherr
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: