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

[PATCH] Font fallback mechanism selects wrong font

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • GVT Text
    • None

    Description

      If there is a SVG text element that is displayed with different fonts, the StrokingTextPainter selects the wrong font for the first char after switching from the first to the fallback font.

      E.g.
      <tspan x="10" y="100" style="font-size:100px;font-family:Arial,'Arial Unicode MS';">= 的槽接触面</tspan>

      "= " --> Will be rendered with "Arial"
      "的" --> Will be rendered with any font that can display this character
      "槽接触面" --> Will be rendered with "Arial Unicode MS"

      See also the attached SVG test case and two PNG files, which were transcoded from this SVG after and before my fix.

      This issue is caused by the createModifiedACIForFontMatching() method inside StrokingTextPainter, which skips one character after the first few characters are matched to "Arial". This leaves one character with no font assigned (see fontAssigned array), which causes the subsequent code to assign any font, that can display the character.

      I'll add a patch that, so that
      "= " is rendered with "Arial" and
      "的槽接触面" with "Arial Unicode MS".

      Attachments

        1. 1178_test_case.svg
          0.3 kB
          Matthias Reischenbacher
        2. 1178_test_case.png
          8 kB
          Matthias Reischenbacher
        3. 1178_test_case_fixed.png
          8 kB
          Matthias Reischenbacher
        4. 1178.patch
          0.8 kB
          Matthias Reischenbacher

        Activity

          People

            Unassigned Unassigned
            matthias8283 Matthias Reischenbacher
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: