mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
294 stars 28 forks source link

Issue after upgrading to macOS Ventura #239

Closed netw0rkf10w closed 1 year ago

netw0rkf10w commented 1 year ago

Hello,

I have upgraded my Mac to macOS Ventura and reinstalled MacTeX 2023 (that delivers also GhostScript 10.00.0), and unfortunately dvisvgm has stopped working. It was working before on macOS Catalina.

Example of my test.tex:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
    \usetikzlibrary{arrows,shapes}
    \tikzset{cat object/.style=   {node distance=4em}}

    \begin{tikzpicture}[]
        \node [cat object] (Del)                {$D$};
        \node [cat object] (L)   [below of=Del] {$X$};
        \node [cat object] (I)   [right of=L]   {$I$};
        \node [cat object] (F)   [left of=L]    {$F$};

        \draw [->] (Del) to node [left,near end]{$\scriptstyle{d_X}$}     (L);
        \draw [->] (I)   to node [below]        {$\scriptstyle{x}$}       (L);
        \draw [->] (Del) to node [above left]   {$\scriptstyle{d_{F}}$} (F);

        \draw [->,dashed] (Del) to node {/}(I);
    \end{tikzpicture}
\end{document}

DVI to SVG

latex test.tex
dvisvgm test.dvi

Output:

processing of PostScript specials is disabled (Ghostscript not found)
pre-processing DVI file (format version 2)
processing page 1
  WARNING: 153 PostScript specials ignored. The resulting SVG might look wrong.
  graphic size: 10.110872pt x 10pt (3.553565mm x 3.514598mm)
  output written to test.svg
1 of 1 page converted in 0.34458 seconds

PDF to SVG

pdflatex test.tex
dvisvgm --pdf test.pdf

Output:

ERROR: can't retrieve number of pages from file test.pdf

Environment

macOS Ventura 13.3.1

$ dvisvgm --version
dvisvgm 3.0.3

$ latex --version
pdfTeX 3.141592653-2.6-1.40.25 (TeX Live 2023)
kpathsea version 6.3.5
Copyright 2023 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.39; using libpng 1.6.39
Compiled with zlib 1.2.13; using zlib 1.2.13
Compiled with xpdf version 4.04

Thank you in advance!

mgieseki commented 1 year ago

Unfortunately, I can't really help here because I don't have access to a Mac. It seems, dvisvgm can't find or doesn't get access to the Ghostscript library any longer. Maybe it's now located in a different folder or there are some security measures in place that prevent dvisvgm from accessing the library. I suggest to contact the MacTeX team to have a look at this.

netw0rkf10w commented 1 year ago

@mgieseki Thanks. The Ghostscript library is present and is at the same place at before: /usr/local/share/ghostscript/10.00.0/lib/libgs.dylib.10.00. I tried passing the lib directly to dvisvgm but nothing has changed:

$ dvisvgm --libgs=/usr/local/share/ghostscript/10.00.0/lib/libgs.dylib.10.00 --pdf test.pdf
ERROR: can't retrieve number of pages from file test.pdf

The output of dvisvgm -h is as follows:

$ dvisvgm -h
dvisvgm 3.0.3

This program converts DVI files, as created by TeX/LaTeX, as well as
EPS and PDF files to the XML-based scalable vector graphics format SVG.

Usage: dvisvgm [options] dvifile
       dvisvgm --eps [options] epsfile
       dvisvgm --pdf [options] pdffile

Input options:
  -p, --page=ranges             choose page(s) to convert [1]
  -m, --fontmap=filenames       evaluate (additional) font map files
  -E, --eps                     convert EPS file to SVG
  -P, --pdf                     convert PDF file to SVG
      --stdin                   read input file from stdin

SVG output options:
  -b, --bbox=size               set size of bounding box [min]
  -B, --bitmap-format=fmt       set format used to embed PS/EPS bitmaps [jpeg]
  -j, --clipjoin                compute intersection of clipping paths
      --colornames              prefer color names to RGB values if possible
      --comments                add comments with additional information
      --embed-bitmaps           prevent references to external bitmap files
  -f, --font-format=format      set file format of embedded fonts [svg]
      --grad-overlap            create overlapping color gradient segments
      --grad-segments=number    number of color gradient segments per row [20]
      --grad-simplify=delta     reduce level of detail for small segments [0.05]
  -L, --linkmark=style          select how to mark hyperlinked areas [box]
  -O, --optimize[=modules]      perform several SVG optimizations [all]
  -o, --output=pattern          set name pattern of output files
  -d, --precision=number        set number of decimal points (0-6) [0]
  -R, --relative                create relative path commands
  -s, --stdout                  write SVG output to stdout
      --tmpdir[=path]           set/print the directory for temporary files
  -n, --no-fonts[=variant]      draw glyphs by using path elements [0]
      --no-merge                don't merge adjacent text elements
      --no-styles               don't use CSS styles to reference fonts
  -z, --zip[=level]             create compressed .svgz file [9]

SVG transformations:
  -r, --rotate=angle            rotate page content clockwise [0]
  -c, --scale=sx[,sy]           scale page content
  -t, --translate=tx[,ty]       shift page content
  -T, --transform=commands      transform page content
  -Z, --zoom=factor             zoom page content [1]

Processing options:
  -C, --cache[=dir]             set/print path of cache directory
  -e, --exact-bbox              compute exact glyph bounding boxes
      --keep                    keep temporary files
      --libgs=filename          set name of Ghostscript shared library
  -M, --mag=factor              magnification of Metafont output [4]
      --no-mktexmf              don't try to create missing fonts
  -S, --no-specials[=prefixes]  don't process [selected] specials
  -H, --page-hashes[=params]    activate usage of page hashes [xxh64]
  -a, --trace-all[=retrace]     trace all glyphs of bitmap fonts [no]

Message options:
      --color                   colorize messages
  -h, --help[=mode]             print this summary of options and exit [0]
  -l, --list-specials           print supported special sets and exit
      --progress[=delay]        enable progress indicator [0.5]
  -v, --verbosity=level         set verbosity level (0-7) [7]
  -V, --version[=extended]      print version and exit [no]

Copyright (C) 2005-2023 Martin Gieseking <martin.gieseking@uos.de>

I also tried re-installing Ghostscript from here: https://www.tug.org/mactex/morepackages.html but that didn't help either.

I wonder whether dvisvgm has other dependencies that Ghostscript...

mgieseki commented 1 year ago

What's the output of dvisvgm -V1? Is Ghostscript listed there? If not, dvisvgm can't find or access the Ghostscript library for some reason. Since the upgrade to Ventura broke the functionality and even --libgs doesn't work now, I presume that macOS prevents using the library. This really needs to be investigated by a Mac developer.

netw0rkf10w commented 1 year ago

Indeed, dvisvgm -V1 doesn't list Ghostscript:

$ dvisvgm -V1
dvisvgm 3.0.3 (x86_64-apple-darwin18.7.0)
-----------------------------------------
brotli:   1.0.9
clipper:  6.2.1
freetype: 2.13.0
kpathsea: 6.3.5
potrace:  1.16
xxhash:   0.8.1
zlib:     1.2.13

I guess I should report a bug to the MacTeX team then... In the mean time I'll try to build dvisvgm from source. Thanks!

netw0rkf10w commented 1 year ago

I tried using the dvisvgm binary from the backup of my computer before the upgrade (actually it was not un upgrade but an installation from scratch of Ventura), and it turns out that dvisvgm -V1 gives the same results:

$ dvisvgm -V1
dvisvgm 3.0.3 (x86_64-apple-darwin18.7.0)
-----------------------------------------
brotli:   1.0.9
clipper:  6.2.1
freetype: 2.13.0
kpathsea: 6.3.5
potrace:  1.16
xxhash:   0.8.1
zlib:     1.2.13

Yet this same binary was working before.

In my backup I also have TeXLive 2019, and its dvisvgm -V1 gives

$ dvisvgm -V1
dvisvgm 2.6.3
-------------
brotli:    1.0.7
clipper:   6.2.1
fontforge: 20160721
freetype:  2.9.1
kpathsea:  6.3.1
potrace:   1.15
xxhash:    0.6.5
zlib:      1.2.11

These lead me to believe that, the fact that dvisvgm -V1 doesn't show Ghostscript is an expected behaviour, and thus the issue seem to lie elsewhere.

netw0rkf10w commented 1 year ago

Also, when running the 2019 dvisvgm, I got a different error message:

$ dvisvgm_2.6.3 --pdf test.pdf 
ERROR: Ghostscript is required to process PDF files

which seems to indicate that the 2023 version does have access to Ghostscript.

mgieseki commented 1 year ago

which seems to indicate that the 2023 version does have access to Ghostscript.

No, there were many changes in dvisvgm 3 regarding the processing of PDF files. Hence, the error messages might differ as well. If dvisvgm -V1 doesn't list Ghostscript, dvisvgm definitely has no access to the Ghostscript library.

netw0rkf10w commented 1 year ago

@mgieseki I see, thanks. Trying to install Ghostscript via Homebrew. The latest version is 10.01.1 and is not supported by dvisvgm:

$ dvisvgm --pdf test.pdf
ERROR: To process PDF files, either Ghostscript < 10.1 or mutool is required.
The installed Ghostscript version 10.1.1 isn't supported.

(Not sure why it was dented as 10.1.1 while it's only 10.01.1).

Trying to downgrade to 10.00.0 now...

muzimuzhi commented 1 year ago

(Not sure why it was dented as 10.1.1 while it's only 10.01.1).

see #226

netw0rkf10w commented 1 year ago

@muzimuzhi Thanks a lot! I've installed mutool and now every thing works like a charm!!! Even dvisvgm --pdf works without any warning (which is something I don't really understand, because according to https://github.com/mgieseki/dvisvgm/issues/226, mutool should involve only DVI -> SVG).

mgieseki commented 1 year ago

(which is something I don't really understand, because according to #226, mutool should involve only DVI -> SVG)

The mutool-based PDF handler was introduced with dvisvgm 3.0 because GS replaced its PDF interpreter with a new one that can't be used as the previous one. You can find some information about this in the manual page. PDF files can be referenced from within DVI files so that mutool is used there as well but not exclusively. It's main purpose is to process PDF files.

netw0rkf10w commented 1 year ago

@mgieseki Thanks for the clarification. I guess that means Ghostscript is no longer needed as a dependency, starting from dvisvgm 3.0?

mgieseki commented 1 year ago

Ghostscript is still required for processing PostScript code, e.g. if you want to convert EPS files or DVI files that contain PS fragments as created by PSTricks for example. This functionality is not available if you build or run dvisvgm without access to the Ghostscript library.

netw0rkf10w commented 1 year ago

@mgieseki I see, thanks. I've just tried converting EPS to DVI using

# create test.ps from test.dvi
dvips test
# convert test.ps to test.svg
dvisvgm --eps test.ps

and it worked. Does this mean that my installation of dvisvgm is fully working now?


For those future users who will come across this discussion and who don't want to install Homebrew, there is an alternative solution: just install the following package that already includes mutool: Ghostscript-10.01.1-Extras.pkg.

mgieseki commented 1 year ago

Yes, it seems it's fully working now. In this case, Ghostscript should also be shown in the output of dvisvgm -V1.

netw0rkf10w commented 1 year ago

Oh, indeed:

$ dvisvgm -V1
dvisvgm 3.0.3 (x86_64-apple-darwin18.7.0)
-----------------------------------------
brotli:      1.0.9
clipper:     6.2.1
freetype:    2.13.0
Ghostscript: 10.1.1
kpathsea:    6.3.5
mutool:      1.22.0
potrace:     1.16
xxhash:      0.8.1
zlib:        1.2.13

I'm not really sure what happened, but I'm glad it's working :D

mgieseki commented 1 year ago

Great, glad to hear you finally got it working again.