SVG font scaling bug ("%" and "em" misconverted to "px")
Closed, ResolvedPublic



SVG images containing text elements whose sizes are given in "%" or "em" (and possibly other non-px units?), do not correctly convert sizes such as "120%" or "2em" to their px equivalents, causing serious rendering errors.

Example #1:

<text style="font-size:14px;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Arial">

<tspan x="13" y="25" font-weight = "bold" font-size = "120%">HEADER</tspan>


fails, and renders the font as 120px (!). If the "120%" is replaced by its exact px equivalent "16.8px" (=14px x 120%) it succeeds. The effect of this bug is the font renders at a huge size, causing large (often black) rectangles and "letterboxes" to hide part or all of the image, or indeed not being visible at all.

Example #2:

<text style="font-size:14px;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Arial">

<tspan x="13" y="25">HEADER</tspan>
<tspan x="13" dy="2em">My paragraph text</tspan>


fails (puts 2nd line on same y-co-ordinate as first line rather than 2 lines below it). If the "2em" is replaced by its exact px equivalent "28px" (=14px x 2) it succeeds.

(May also affect rendering of other elements that can have sizes given in "%" or "em" terms too.)

Version: unspecified
Severity: normal

bzimport added a subscriber: wikibugs-l.
bzimport set Reference to bz13494.
bzimport created this task.Via LegacyMar 24 2008, 8:55 PM
bzimport added a comment.Via ConduitMar 25 2008, 4:02 AM wrote:

(Initial report and examples: bug 13486 )

bzimport added a comment.Via ConduitMar 26 2008, 4:09 AM wrote:

Work-around - state font sizes as "px" rather than "%" or "em" for now.

bzimport added a comment.Via ConduitMay 24 2008, 10:03 PM

az6024283313 wrote:

What are you people talking about? I am not technical enough to understand that.

brion added a comment.Via ConduitMay 27 2008, 8:06 PM

Translation: there's a bug in the library we use to render SVG images. It's possible to work around it by making your SVG files in a slightly different way (specify font sizes in pixel units instead of percentage or "em" height).

brion added a comment.Via ConduitAug 3 2009, 4:53 PM

Assigning SVG bugs to Ariel -- need a cleanup pass to see what's fixed up by a librsvg upgrade, what can be resolved with fixes to our font configuration, what can be fixed on our end, and what still needs to be pushed upstream.

ArielGlenn added a comment.Via ConduitSep 18 2011, 9:14 AM

giving SVG bugs back to the pool.

TheDJ added a comment.Via ConduitDec 4 2011, 1:37 PM

Fix committed upstream on 2010-05-02

TheDJ added a comment.Via ConduitDec 4 2011, 1:44 PM

It seems the dy offset is fixed, but the font size still seems present in our live deploy ?

TheDJ added a comment.Via ConduitJul 29 2012, 11:06 PM

This issue still is present with our librsvg version it seems.

TheDJ added a comment.Via ConduitOct 26 2012, 9:03 AM

This issue is now fixed. This is visible in revision 20:06, 23 March 2008 of file

which now renders correctly.

Add Comment