missing unit of font size in generated font stylesheets

Bug #1215857 reported by Till Tantau
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dvisvgm
Fix Released
Medium
Martin Gieseking

Bug Description

For a minimal document like this:

\documentclass{article}

\begin{document}

Hallo Welt.

\end{document}

dvisvgm produces an svg like this:

<?xml version='1.0' encoding='ISO-8859-1'?>
...
<style type='text/css'><![CDATA[
text.f0 {font-family:cmr10;font-size:10}
]]>
</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->scaledSize() << "}\n";

to
    << ";font-size:" << it->second->scaledSize() << "px}\n";

That should fix the problem.

Changed in dvisvgm:
assignee: nobody → Martin Gieseking (martin-gieseking)
importance: Undecided → Medium
status: New → Fix Committed
Revision history for this message
Martin Gieseking (martin-gieseking) wrote :

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).

Changed in dvisvgm:
status: Fix Committed → Fix Released
milestone: none → 1.5
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.