Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing unit of font size in generated font stylesheets #35

Closed
mgieseki opened this issue Jul 20, 2014 · 1 comment
Closed

missing unit of font size in generated font stylesheets #35

mgieseki opened this issue Jul 20, 2014 · 1 comment
Assignees
Labels
enhancement improve existing functionality
Milestone

Comments

@mgieseki
Copy link
Owner

For a minimal document like this:

\documentclass{article}

\begin{document}

Hallo Welt.

\end{document}

dvisvgm produces an svg like this:

...

<style type='text/css'> </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 is provided without a unit identifier (e.g., an unqualified number such as 128), the SVG user agent processes the as a height value in the current user coordinate system.

If a is provided with one of the unit identifiers (e.g., 12pt or 10%), then the SVG user agent converts the 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.

Launchpad Details: #LP1215857 Till Tantau - 2013-08-23 12:18:35 +0200

@mgieseki
Copy link
Owner Author

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

Launchpad Details: #LPC Martin Gieseking - 2013-08-23 14:25:52 +0200

@mgieseki mgieseki self-assigned this Jul 20, 2014
@mgieseki mgieseki added bug and removed bug labels Jul 20, 2014
@mgieseki mgieseki added this to the 1.5 milestone Jul 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing functionality
Projects
None yet
Development

No branches or pull requests

1 participant