feature request: use of @font-face

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

Bug Description

Hi, this is not a bug, but a feature request. However, I did not find a special forum for posting feature requests, so I put this here...

I would like to request that future versions of dvisvgm support the @font-face feature of CSS (http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#font-descriptions) to embed a link to the original OpenType / Type1 / whatever fonts into the generated SVG files alongside the embedded <font> element.

The idea would be that

\documentclass{article}
\usepackage{lmodern}
\begin{document}
Hallo Welt.
\end{document}

produces something like this:

<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- This file was generated by dvisvgm 1.2.2 (x86_64-apple-darwin10.8.0) -->
<!-- Fri Aug 23 12:45:33 2013 -->
<svg height='630.635pt' version='1.1' viewBox='-46.3263 27.9508 405.479 630.635' width='405.479pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<font horiz-adv-x='0' id='rm-lmr10'>
<font-face ascent='1127' descent='-290' font-family='rm-lmr10' units-per-em='1000'/>
<missing-glyph d=''/>
<glyph d='M192 53...' glyph-name='period' horiz-adv-x='278' unicode='.'/>
<glyph d='M419 0...' glyph-name='one' horiz-adv-x='500' unicode='1'/>
...
</font>
</defs>
<style type='text/css'><![CDATA[
@font-face {
  font-family:rm-lmr10;
  src: url("lmroman10-regular.otf");
}
text.f0 {font-family:rm-lmr10;font-size:10px}
]]>
</style>
<g id='page1' transform='matrix(0.996264 0 0 0.996264 0 0)'>
<text class='f0' x='77' y='63'>Hallo<tspan x='103.389'>W</tspan>
<tspan x='112.833'>elt.</tspan>
<tspan x='232' y='633'>1</tspan>
</text>
</g>
</svg>

Note the added @font-face. At least on Safari, this causes the fonts to be rendered using the real OpenType font, if the font is available at the specified URL and, if not, the embedded font is used as a fallback.

I know this is kind of tough to implement since it is hard to "tell" where the actual fonts are and it is not clear what the URLs should look like (absolute? relative? should the fonts be copied?). However, if one wishes to use SVG as a replacement for PDF during a presentation or for longer text to be read online, high-quality fonts would be a real plus.

Revision history for this message
Martin Gieseking (martin-gieseking) wrote :

Thanks for your suggestion. I have to think about it a bit more before I assess whether it works in a generic way.
Especially, one problem might be the fact that there's not always a simple relation between the DVI character code and the corresponding UTF-8 code point. All recent versions of dvisvgm create SVG files that use the DVI char codes to mark and reference the characters. Thus, if some of them differ from the unicode points, you get wrong results when directly accessing the font files.
However, I'm currently switching the code to correct UTF-8 encoding which requires a lot of font table magic. I'll see if an acceptable support of @font-face descriptions is possible.

Changed in dvisvgm:
importance: Undecided → Medium
assignee: nobody → Martin Gieseking (martin-gieseking)
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.