Page MenuHomePhabricator

Font size in rem is handled incorrectly by the SVG rasterizer
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Add a <text> element in an SVG file
  • Set its size in rem units rather than px units (with the common formula px = rem×16)
  • The rendering size of the text differs
  • I should mention that my example uses a dynamically-sized SVG file with a viewBox but no width and height ; not sure if it influences the bug (tbt)

https://commons.wikimedia.org/wiki/File:Font_size_rem_bug.svg

What happens?:

The text renders in a smaller font than a pixel font size would

What should have happened instead?:

The text should have rendered with the same font size than a px counterpart (assuming the px = 16×rem conversion rule)

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Tested on Wikimedia Commons

Event Timeline

Note : the bug is circumvented (as shown in the second version of the file) by setting a size in px AND THEN an overriding size in rem.
The fact that the Commons rasterizer visibly uses the px version implies, as I understand it, that it recognizes a rem value as an incorrect value and ignores it – meaning that the issue is not something else, like the rasterizer having another value for rem than 16px for instance, which could have been another explanation.
It also means that the bug has presumably nothing to do with the width, height and viewBox as I mentioned earlier.

rem values are however very basic and common and baseline, so it's really not great that the rasterizer does not support it. Especially since a workaround seems to be so easy – I mean, the rasterizer could do that itself…