missing unit of font size in generated font stylesheets
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dvisvgm |
Fix Released
|
Medium
|
Martin Gieseking |
Bug Description
For a minimal document like this:
\documentclass{
\begin{document}
Hallo Welt.
\end{document}
dvisvgm produces an svg like this:
<?xml version='1.0' encoding=
...
<style type='text/
text.f0 {font-family:
]]>
</style>
...
Now, the problem is the "font-size:10". It causes the SVG-Viewer in Safari-based browsers (Mac, iOS) to display the fonts incorrectly. The problem disappears, when it is replaced by "font-size:10px".
I tracked this down and according to the SVG specification for the font-size attribute:
"This property refers to the size of the font from baseline to baseline when multiple lines of text are set solid in a multiline layout environment. For SVG, if a <length> is provided without a unit identifier (e.g., an unqualified number such as 128), the SVG user agent processes the <length> as a height value in the current user coordinate system.
If a <length> is provided with one of the unit identifiers (e.g., 12pt or 10%), then the SVG user agent converts the <length> into a corresponding value in the current user coordinate system by applying the rules described in Units."
Now, it seems to me that in "font-size:10" causes "10" to be interpreted in some strange user coordinate system (or not at all since it makes no difference which size is provided), while "10px" is interpreted correctly in the correct system.
I suggest changing line 292 of SVGTree.cpp from
<< ";font-size:" << it->second-
to
<< ";font-size:" << it->second-
That should fix the problem.
Changed in dvisvgm: | |
assignee: | nobody → Martin Gieseking (martin-gieseking) |
importance: | Undecided → Medium |
status: | New → Fix Committed |
Changed in dvisvgm: | |
status: | Fix Committed → Fix Released |
milestone: | none → 1.5 |
Thanks for reporting this issue. Since I don't have any Apple device available, I can't reproduce the bug on it. However, the missing unit specifier affects the text rendering in Opera too.
I've added the "px" unit to the font-size attribute. As far as my recent tests can tell, it works fine and doesn't break the text layout created by SVG renderers that also create correct results without the additional unit (e.g. Squiggle).