Closed rfdonnelly closed 1 year ago
- Copy the example from https://texample.net/tikz/examples/focused-ion-beam-system/ verbatim into
input.tex
latex input.tex
dvisvgm --font-format=woff input.dvi
Just after step 1, adding class option dvisvgm
to \documentclass{minimal}
works for me on macOS with latest texlive 2022 and dvisvgm 2.13.3.
The reason is, tikz need to know the name of backend. See related tikz doc https://tikz.dev/drivers#sec-10.2.4 (html but unofficial).
It seems, TikZ changed some internals which now create different PostScript code. The background shading applied in the example is now realized by axial shading patterns which dvisvgm don't support yet. Formerly, the gradients were approximated by sequences of differently colored lines or rectangles. I still have an old DVI file of this TikZ example and were able to compare the two files:
Here's an excerpt of the affected parts:
Old PS code:
100.00128 100.00128 pgfV 75.00096 0.6 0.6 0.6 0.6 0.6 0.6 pgfshade 50.00064 0.6 0.6 0.6 0.75 0.75 0.75 pgfshade 25.00032 0.75 0.75 0.75 0.9 0.9 0.9 pgfshade 0.0 0.9 0.9 0.9 0.9 0.9 0.9 pgfshade pop
New PS code:
100.00128 100.00128 0 0 pgfe << /PatternType 2 /Shading << /ShadingType 2 /ColorSpace /DeviceRGB /Domain [0.0 100.00128] /Coords [0 0.0 0 100.00128] /Function << /FunctionType 3 /Domain [0.0 100.00128] /Functions [ << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0.9 0.9 0.9] /C1 [0.9 0.9 0.9] /N 1 >> << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0.9 0.9 0.9] /C1 [0.75 0.75 0.75] /N 1 >> << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0.75 0.75 0.75] /C1 [0.6 0.6 0.6] /N 1 >> << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0.6 0.6 0.6] /C1 [0.6 0.6 0.6] /N 1 >> ] /Bounds [ 25.00032 50.00064 75.00096] /Encode [0 1 0 1 0 1 0 1] >> >> >> matrix makepattern setpattern fill
As @muzimuzhi wrote above, you can get proper results with document class option dvisvgm
.
Thank you @muzimuzhi and @mgieseki! That fixed it. I just read that section of the TikZ doc too but didn't think to try it.
To be explicit, here are the revised steps:
Copy the example from https://texample.net/tikz/examples/focused-ion-beam-system/ verbatim into input.tex
Modify as follows:
--- a/examples/focused-ion-beam-system/input.tex
+++ b/examples/focused-ion-beam-system/input.tex
@@ -2,7 +2,7 @@
% Focused ion beam system
% Author: Clemens Helfmeier
-\documentclass{minimal}
+\documentclass[dvisvgm]{minimal}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing}
latex input.tex
dvisvgm --font-format=woff input.dvi
Side note: Both pdf2svg
and pdftocairo
produce an SVG that is 1.4MB while dvisvgm
produces an SVG that is 70KB. Amazing!
It seems, TikZ changed some internals which now create different PostScript code.
@mgieseki Seems it took place in https://github.com/pgf-tikz/pgf/pull/907 and was shipped with pgf-tikz v3.1.6 (Sep 29, 2020).
It seems, TikZ changed some internals which now create different PostScript code. The background shading applied in the example is now realized by axial shading patterns which dvisvgm don't support yet.
Yes, that's my fault. I implemented PS-3 shadings into the dvips driver code of pgf in August 2020. I did this for their better visual quality and smaller file size.
It's not a fault, of course. 😀 Since there is now a dedicated dvisvgm backend for TikZ, the changes in the PS backend don't really matter any longer, and the real gradients actually look much better than the old approximated ones.
Hello, I am having issues with converting this example: https://texample.net/tikz/examples/focused-ion-beam-system/
The FAQ shows that it renders correctly for Chrome:
But I get this instead:
I get a similarly bad (if not the same) result in Firefox.
More Results
I tried various combinations of dvisvgm version and ghostscript version. All have the same issue.
Steps to Reproduce
input.tex
latex input.tex
dvisvgm --font-format=woff input.dvi