mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
295 stars 28 forks source link

missing fonts #237

Closed drdv closed 1 month ago

drdv commented 1 year ago

I have installed dvisvgm using sudo dnf install dvisvgm (version 3.0.4).

Let math.tex contains (it is based on the sphinx.ext.imgmath template preview.tex_t)

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{anyfontsize}
\usepackage{bm}
\pagestyle{empty}

\usepackage{bbm}
\usepackage{xcolor}
\usepackage{mathtools}

\AtBeginDvi{\special{color rgb 0.08984375 0.3125 0.91796875}}

\newcommand\cc[1]{\texttt{#1}}

\usepackage[active,tightpage,dvips]{preview}

\begin{document}
\begin{preview}
\fontsize{14}{17}\selectfont $\beta = \frac{\cc{leads}_h}{\cc{leads}}$
\end{preview}
\end{document}

When I use

tectonic --outfmt xdv math.tex
dvisvgm --no-fonts math.xdv

the stdout of dvisvgm is

pre-processing DVI file (format version 7)
WARNING: font file 'lmmono10-regular' not found
processing page 1
  computing extents based on data set by preview package (version 13.1)
  width=60.523759pt, height=12.68417pt, depth=4.827759pt
  graphic size: 60.523759pt x 17.511929pt (21.271668mm x 6.154739mm)
  running Metafont for cmmi7
  WARNING: failed to create cmmi7.gf
  WARNING: can't embed font 'lmmono10-regular'
  running Metafont for cmr12
  WARNING: failed to create cmr12.gf
  running Metafont for cmmi12
  WARNING: failed to create cmmi12.gf
  output written to math.svg
1 of 1 page converted in 0.0860379 seconds

and math.svg is "broken". If I then dnf install texlive-fontspec, all is as expected:

pre-processing DVI file (format version 7)
processing page 1
  computing extents based on data set by preview package (version 13.1)
  width=59.061234pt, height=11.81332pt, depth=4.886559pt
  graphic size: 59.061234pt x 16.699879pt (20.75765mm x 5.869336mm)
  output written to math.svg
1 of 1 page converted in 0.06586 seconds

I presume that tectonic has already downloaded the required fonts but dvisvgm is looking for texlive -installed fonts. Is it possible for dvisvgm to use tectonic fonts (maybe it is just a matter of providing the right path)?

mgieseki commented 1 year ago

On Linux, dvisvgm uses the linked kpathsea library which belongs to the corresponding TeX Live system to lookup font files. If tectonic comes with its own TeX environment and settings and you use a dvisvgm binary that was built for TeX Live, you probably need to adapt some TeX environment variables in order to tell dvisvgm where the tectonic texmf directories are located. I don't know the details of tectonic so I can't help here, unfortunately.