Closed bustercopley closed 9 months ago
Using concepts used in https://simoncozens.github.io/fonts-and-layout/concepts.html#advance-widths, it seems the outline bounding box for $C$
is wider than the corresponding glyph bounding box. That's said, the left sidebearing for C
in math mode is positive.
\documentclass{article}
\pagestyle{empty}
\begin{document}
\fboxsep=0pt
\fbox{C}
\fbox{\textit{C}}
\fbox{$C$}
\end{document}
Yes, that's exactly the issue here. The character offset is not taken into account when computing the bounding box. I've fixed it and will commit the patch after some more testing.
Using concepts used in https://simoncozens.github.io/fonts-and-layout/concepts.html#advance-widths, it seems the outline bounding box for
$C$
is wider than the corresponding glyph bounding box. That's said, the left sidebearing forC
in math mode is positive.
Indeed! You would use other options (for example --bbox=dvi
) to get a bounding box that takes such things into account, to allow further text layout operations.
Then my previous understanding of --bbox=min
was wrong. I had thought side bearings are taken into consideration. Thank you both.
Update: Sorry I was wrong to think this issue is about --bbox-min
, but actually it's about --exact-bbox
. According to doc for --exact-bbox
, yes it should trim side bearings.
Yes, they are usually enclosed in the box when calling dvisvgm without --exact-bbox
because the TFM metrics used in this case include the side bearings and it's not possible to derive the glyph extents from them. In order to allow for tight boxes that only consider the visual parts of the characters, --exact-bbox
was introduced.
Wow, that was fast! Looks great, thank you.
There is apparently a mistake in calculating the minimum x coordinate of the bounding box (for DVI input). In the MWE below, the SVG viewBox is too wide, and has min-X equal to 0; however the content's left edge is about 0.5 units to the right. (The other three edges are correct.)
Here is a Bash script to reproduce the issue (tested on Debian and on Windows in MINGW64-variant MSYS bash, with dvisvgm built from
master
today).The output from the script:
Attached are the output SVG (it's very small!) and a cropped screenshot from Inkscape showing the bounding box and content.
![inkscape](https://github.com/mgieseki/dvisvgm/assets/8483414/1921a8ef-afd5-4da7-b758-d6f586f68fc2)