pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.15k stars 108 forks source link

Buggy dvisvgm export for transparency group=knockout #1349

Open tobiasBora opened 4 months ago

tobiasBora commented 4 months ago

Brief outline of the bug

I'd love to be able to use the awesome transparency group=knockout feature, that allows us to paint in transparent color to reveal the underlying image. For instance (taken from the doc):

\documentclass[dvisvgm]{minimal}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \shade [left color=red,right color=blue] (-2,-1) rectangle (2,1);
  \begin{scope}[transparency group=knockout]
    \fill[white] (-1.9,-.9) rectangle (1.9,.9);
    \node[opacity=0,font=\fontencoding{T1}\fontfamily{ptm}\fontsize{45}{45}\bfseries]{Ti\emph{k}Z};
  \end{scope}
\end{tikzpicture}
\end{document}

is supposed to write TikZ in a rainbow-like fashion. But since this is poorly supported by pdf viewers/printers, I wanted to export to svg directly. But running:

$ lualatex --output-format=dvi test
$ dvisvgm test
$ inkscape test.svg

gives me

image

which is not at all the expected result as we cannot read tikz in rainbow like colors, and the huge right margin is also weird.

Thanks a lot for considering this!

NB: I asked first in https://github.com/mgieseki/dvisvgm/issues/272 and they told me that tikz needed to solve it on their side.

Minimal working example (MWE)

\documentclass[dvisvgm]{minimal}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \shade [left color=red,right color=blue] (-2,-1) rectangle (2,1);
  \begin{scope}[transparency group=knockout]
    \fill[white] (-1.9,-.9) rectangle (1.9,.9);
    \node[opacity=0,font=\fontencoding{T1}\fontfamily{ptm}\fontsize{45}{45}\bfseries]{Ti\emph{k}Z};
  \end{scope}
\end{tikzpicture}
\end{document}