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

Share common font across all SVGs #119

Open
shreevatsa opened this issue Nov 21, 2019 · 2 comments
Open

Share common font across all SVGs #119

shreevatsa opened this issue Nov 21, 2019 · 2 comments
Assignees
Labels
feature feature request

Comments

@shreevatsa
Copy link

First, I should say that dvisvgm is a wonderful tool, and even its source code appears to be very high-quality and understandable. Thank you!

This request is possibly the same as #55 but asking separately just in case my use-case is different (using WOFF fonts) or things are different now: I have a multi-page DVI document on which I use dvisvgm to extract each page as a separate SVG file (for displaying on a HTML webpage), with the following command:

dvisvgm --page=1- --font-format=woff2,autohint --bbox=10 --output="%f-%0p.svg" $dvi

where $dvi is the name of the DVI (or XDV) file. In each of the resulting SVG files, I see a bunch of fonts defined like:

@font-face{font-family:cmr8;src:url(data:application/x-font-woff2;base64,d09GMgAB...AAA==) format('woff2');}

and these fonts are then used in the remainder of the SVG file, like

text.f14 {font-family:cmr10;font-size:9.96264px}

which is a CSS declaration. When all these SVGs are included on a single web-page, the result is that the browser has to download a lot of data, and also process each font separately (so it takes a while to load each SVG).

Example: see https://shreevatsa.github.io/tex/program/tangle/tangle-15 or (warning: very slow and downloads a lot of data) https://shreevatsa.github.io/tex/program/

Would it be possible to add an option to share the (full) fonts across all pages, so that they would only have to be downloaded and processed once? I'm thinking of a single common.svg or whatever file containing all the fonts and CSS declarations, after which each later SVG would only need to contain the text elements that reference these CSS declarations.

@mgieseki
Copy link
Owner

Thank you for your feedback and the detailed feature request. Actually, separating the font data from the page SVGs is on my to-do list for a long time. Since the implementation requires a fair amount of work including a redesign of the current font handling, I've put it aside so far. If I find enough free time, I'll take it up again. But when I look at my planner, I'm afraid that won't be the case in the next few months.

@eric-wieser
Copy link

A variant of this request; I have a LuaLaTeX file that loads in a ttf font, which I want to generate an SVG from. My website will already be serving the ttf font, so there's no need to embed it in the SVG.

For now I can hack around this by manually stripping and renaming the embedded font (inconsolata) with:

sed -i -E 's/@font-face\{.*?\}//g;s/font-family:nf0/font-family:inconsolata/g' ${1%.tex}.svg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature request
Projects
None yet
Development

No branches or pull requests

3 participants