svg won't show text containing g tags

151 views Asked by At

I have reduced my problem to a minimal working example. This code snippet won't show any text:

<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> 
<svg viewBox="-361.65944 -228.02199 723.31888 284.92749 ">
    <text > 
        <g fill="#000">
            <g stroke="none">
                <tspan font-family="cmr" font-size="17">Render</tspan>
                <tspan font-family="cmr" font-size="17">Process</tspan>
            </g>
        </g>
    </text> 
</svg>

Now, if I comment out the two g tags, the text is shown:

<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> 
<svg viewBox="-361.65944 -228.02199 723.31888 284.92749 ">
    <text > 
        <!-- <g fill="#000"> -->
            <!-- <g stroke="none"> -->
                <tspan font-family="cmr" font-size="17">Render</tspan>
                <tspan font-family="cmr" font-size="17">Process</tspan>
            <!-- </g> -->
        <!-- </g> -->
    </text> 
</svg>

Why does it happen? I am generating the svg via htlatex out of the following tikz document:

\documentclass[tikz]{standalone}
\def\pgfsysdriver{pgfsys-tex4ht.def} 

\usepackage{tikz}
\usepackage{anyfontsize}
\usetikzlibrary{shapes, positioning}
\begin{document}
\begin{tikzpicture}[
    main/.style={rounded corners, fill=blue!15, align=center, inner sep=10, text width=6cm, minimum height=4cm, font={\fontsize{50 pt}{40 pt}\selectfont}},
    render/.style={rounded corners, fill=red!15, align=center, inner sep=6, text width=5cm, minimum height=3.5cm, font={\fontsize{40 pt}{40 pt}\selectfont}},
]
    \node[main] (main) {Main Process};
    \node[render] [below=of main, xshift=10cm, yshift=-1.5cm] (render1) {Render Process};
    \node[render] [below=of main, xshift=3.2cm, yshift=-1.5cm] (render2) {Render Process};
    \node[render] [below=of main, xshift=-3.2cm, yshift=-1.5cm] (render3) {...};
    \node[render] [below=of main, xshift=-10cm, yshift=-1.5cm] (render4) {Render Process};

    \draw [->] (main) -- (render1.north);
    \draw [->] (main) -- (render2.north);
    \draw [->] (main) -- (render3.north);
    \draw [->] (main) -- (render4.north);
\end{tikzpicture}
\end{document}

I have no clue what is going on here. I would really appreciate any kind of input!

1

There are 1 answers

0
enanone On

htlatex is not the best tool for producing a svg file out of a latex file. pdf2svg works better. To convert your tex file to svg:

  1. Compile your latex to pdf, using e.g. latexmk -pdf main.tex
  2. Convert the output pdf to svg using pdf2svg: pdf2svg main.pdf main.svg

The resulting svg will not contain the bugs that you would find using htlatex main.tex to produce the svg