mgieseki / dvisvgm

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

xetex XDV depth information #236

Closed drdv closed 1 year ago

drdv commented 1 year ago

If I use \usepackage[active,tightpage]{preview} in an example.tex file, then

latex example.tex
dvisvgm --no-fonts example.dvi

displays something like

...
processing page 1
  computing extents based on data set by preview package (version 13.1)
  width=...pt, height=...pt, depth=...pt
  graphic size: ...

On the other hand, if I use \usepackage[active,tightpage,xetex]{preview} in an example.tex file, then

xelatex example.tex
dvisvgm --no-fonts example.xdv

displays something like

...
processing page 1
  graphic size: ...

i.e., the width, height and depth properties are missing.

This seems to be caused by the condition

if (_boxExtents.size() < 7)
    return false;

in PSPreviewFilter::getBoundingBox. Is it possible that DVI version 2 and DVI version 7 store the 7 parameters (adj_left, adj_bottom, adj_right, adj_top, height, depth, width) differently (and dvisvgm doesn't parse them correctly)? Of course it could be that there is a bug in the xetex option in the preview package ...

I use dvisvgm 3.0.2.

mgieseki commented 1 year ago

dvisvgm reads the box extents from the PostScript data written to the DVI file by the preview package. When XeTeX is used, preview assumes PDF output by default and therefore doesn't write any PS data to the XDV file, i.e. dvisvgm can't evaluate it. I guess you can work around this by adding package option dvips, e.g.

\usepackage[active,tightpage,dvips]{preview}
drdv commented 1 year ago

Problem solved, thanks.