pgf icon indicating copy to clipboard operation
pgf copied to clipboard

`svg.path` library incorrectly renders path made up of sub-paths

Open dcpurton opened this issue 2 years ago • 0 comments

Brief outline of the bug

The svg.path library incorrectly renders complex paths made up of multiple sub-paths. I think the problem is when the second sub-path begins with the m operator. The moveto command is relative to the initial starting point before the svg path rather than the end point of the first sub-path.

See https://tex.stackexchange.com/q/656957/87678

The MWE below outputs a simple SVG file which ought to be rendered as:

correct rendering

However, the svg.path library renders it as:

tikz.path rendering

Minimal working example (MWE)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{svg.path}
\begin{filecontents*}[overwrite]{\jobname.svg}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   width="214.798pt"
   version="1.1"
   viewBox="0 0 214.798 40.4164"
   height="40.4164pt"
   id="svg1"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <path
     d="m 90.2532,20.89279 c 0,2.632 1.4,4.032 4.032,4.032 h 3.136 c 2.632,0 4.032,-1.4 4.032,-4.032 v -14.336 c 0,-2.632 -1.4,-4.032 -4.032,-4.032 h -3.136 c -2.632,0 -4.032,1.4 -4.032,4.032 z m 4.844,0.42 c -0.728,0 -1.12,-0.364 -1.12,-1.12 v -12.936 c 0,-0.728 0.392,-1.12 1.12,-1.12 h 1.624 c 0.728,0 1.12,0.392 1.12,1.12 v 12.936 c 0,0.756 -0.392,1.12 -1.12,1.12 z"
     id="path1"
     style="fill:#000000;stroke:none;" />
</svg>
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
  \fill svg {m 90.2532,20.89279 c 0,2.632 1.4,4.032 4.032,4.032 h 3.136 c
    2.632,0 4.032,-1.4 4.032,-4.032 v -14.336 c 0,-2.632 -1.4,-4.032
    -4.032,-4.032 h -3.136 c -2.632,0 -4.032,1.4 -4.032,4.032 z m 4.844,0.42 c
    -0.728,0 -1.12,-0.364 -1.12,-1.12 v -12.936 c 0,-0.728 0.392,-1.12
    1.12,-1.12 h 1.624 c 0.728,0 1.12,0.392 1.12,1.12 v 12.936 c 0,0.756
  -0.392,1.12 -1.12,1.12 z};
\end{tikzpicture}
\end{document}

dcpurton avatar Sep 13 '22 01:09 dcpurton