After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767481 - very serious text rendering bug: wrong kerning
very serious text rendering bug: wrong kerning
Status: RESOLVED FIXED
Product: librsvg
Classification: Core
Component: general
git master
Other Linux
: Normal critical
: ---
Assigned To: librsvg maintainers
librsvg maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-10 06:33 UTC by Werner Lemberg
Modified: 2017-01-05 21:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Rendering of string `Te' with rsvg-view-3 (3.49 KB, image/png)
2016-06-10 06:33 UTC, Werner Lemberg
Details
font-scaling.c (1018 bytes, text/plain)
2016-07-06 18:01 UTC, Federico Mena Quintero
Details

Description Werner Lemberg 2016-06-10 06:33:24 UTC
Created attachment 329528 [details]
Rendering of string `Te' with rsvg-view-3

[e68ec178]

This simple SVG file

```
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg"
     height="100"
     width="100">
  <g style="font-family:DejaVu Sans; font-size:32px">
    <text y="30" x="30">
      <tspan y="30" x="30">
        Te
      </tspan>
    </text>
  </g>
</svg>
```

renders as shown in the attached image with `rsvg-view-3` after pressing the zoom up button eight times.  I guess that the kerning value gets scaled incorrectly; looking into `DejavuSans.ttf` using the `ttx` tool, I see the line

```
<pair l="T" r="e" v="-348"/>
```

in its 'kern' table.

This is an *extremely* serious bug!  In particular, uploading any SVG files to Wikipedia that contains text yields very ugly PNG files.
Comment 1 Federico Mena Quintero 2016-07-06 17:42:57 UTC
Thanks for noticing this and making a minimal test case!

I suspect that librsvg is not at fault here.  By tracing the code, it's just setting the letter_spacing to 0, and from there on Pango handles things.

But now that you mention this, I've been printing maps with text that is scaled up, and I've seen weird spacing issues - I thought the fonts weren't handling those scales correctly or something.  But it may be the same problem after all.  I'll investigate.
Comment 2 Federico Mena Quintero 2016-07-06 18:01:32 UTC
Created attachment 330967 [details]
font-scaling.c

Indeed, not an librsvg problem.  This program uses Pango directly and shows the same problem.  Run it and look at the letter-spacing.png file it creates.
Comment 3 Federico Mena Quintero 2016-07-06 18:04:47 UTC
Ah.  The bug is present with Pango 1.36.8 (openSUSE 13.2), but does not happen with Pango 1.40.1 (openSUSE Tumbleweed).
Comment 4 Federico Mena Quintero 2016-07-06 18:16:32 UTC
This bug is similar to bug #341481, but that one is older... maybe Harfbuzz got fixed since then?

In any case, make sure to update your Pango/Cairo/Harfbuzz stack.  I think Wikipedia has some old libraries laying around ;)
Comment 5 Werner Lemberg 2016-07-06 18:24:55 UTC
Thanks a lot for your analysis!  I'll file a bug report to the Wikipedia people.
Comment 6 kaldari 2017-01-05 21:56:00 UTC
Downstream bug: https://phabricator.wikimedia.org/T36947