pgf
pgf copied to clipboard
For dvisvgm backend, position tracking gets broken upon coloring within node
Brief outline of the bug
Partial \color
ing of node text corrupts position tracking for the following texts.
Minimal working example (MWE)
For example
\documentclass[tikz, dvisvgm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[draw, circle] {test {\color{blue!50}coloring}!};
\end{tikzpicture}
\end{document}
results to
while when it comes to dvipdfmx backend,
\documentclass[tikz, dvipdfmx]{standalone}
\begin{document}
\begin{tikzpicture}
\node[draw, circle] {test {\color{blue!50}coloring}!};
\end{tikzpicture}
\end{document}
TikZ produces the figure correctly as following
Note that if I set color for the subsequent text after local coloring, this kind of malfunction disappears. I.e., rather than
\node[draw, circle] {test {\color{blue!50}coloring}!};
the following corresponds to that from dvipdfmx version:
\node[draw, circle] {test {\color{blue!50}coloring}{\color{.}!}};
Don't know how I find this (by searching for color
in pgfsys-dvisvgm.def
?) but letting \pgfsys@text@to@black@hook
to empty (its default definition) seems to work. It is currently defined as
https://github.com/pgf-tikz/pgf/blob/28b9756fef06fc59ebee7241261ebd0e51d83c21/tex/generic/pgf/systemlayer/pgfsys-dvisvgm.def#L136-L141
for dvisvgm and is empty for any other drivers. This macro was added in https://github.com/pgf-tikz/pgf/commit/b7447e057a83a0dd95e4f83813060805e00d2756, Mar 2016, with comment
https://github.com/pgf-tikz/pgf/blob/28b9756fef06fc59ebee7241261ebd0e51d83c21/tex/generic/pgf/systemlayer/pgfsys.code.tex#L467-L470
I don't see how color "black" is special, in dvisvgm v2.11.1. (Perhaps that was caused by an already fixed dvisvgm bug?) Also I wonder why raw <g>
is both opened and closed first, rather than raw <g> ... \set@color ... \reset@color ... raw </g>
?
Thanks, I can confirm that with latex preamble of
\makeatletter
\def\pgfsys@text@to@black@hook{}
\makeatother
The raised malfunction has gone. I hope the resolution gets merged to upstream in a day!