[luatex] LuaLaTeX + TikZ + dvisvgm font problem

Alexander,J jalex at lse.ac.uk
Fri Jan 19 19:16:27 CET 2024


I’ve encountered a curious font problem with lualatex, TikZ, and dvisvgm, and I was wondering if someone could help diagnose the problem.  If I use the ‘fontspec’ package to set the main font to Optima, font selection commands in TikZ diagrams on *later* pages affect the appearance of fonts on *earlier* pages.  However, this problem disappears if I use the ‘classico’ package.

Here’s a minimal file:

% figure.tex
\documentclass[dvisvgm]{article}
\usepackage{tikz}
\usepackage{fontspec}
\setmainfont{Optima}
% \usepackage[sfdefault]{classico}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}
  \draw (0, 0) node {\bf Some bold text};
\end{tikzpicture}

\newpage

\begin{tikzpicture}
  \draw (0, 0) node {\em Some italic text};
\end{tikzpicture}
\end{document}

Now process this as follows:

lualatex —output-format=dvi figure.tex
dvisvgm -n —page=1- figure.dvi

If you inspect figure-1.svg and figure-2.svg, you’ll notice that the \em font command in the second picture actually overrides the \bf font command in the first picture!  Both  appear in italics.

However, if I comment out the two lines for the ‘fontspec' package and use ‘classico’ instead, everything appears correctly.

Could someone please advise what I might be doing wrong?  I need to do this with a DVI file as an intermediary because I’m generating SVG graphics for inclusion in HTML, and dvisvgm allows me to embed SVG elements in the LaTeX source using \special{dvisvgm: raw … } which is really useful for CSS / javascript targeting later.

Many thanks,

Jason

—
Prof. J. McKenzie Alexander
Department of Philosophy, Logic and Scientific Method
London School of Economics and Political Science
Houghton Street, London WC2A 2AE

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/luatex/attachments/20240119/d709d0a7/attachment.htm>


More information about the luatex mailing list.