vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

Why does the bounding box of a frame containing just a label not just the label's bounding box? #455

Closed user202729 closed 1 month ago

user202729 commented 2 months ago
frame f;
label(f, "\rule{60pt}{200pt}");
//draw(f,(0,1cm)--(1cm,0));
add(f);
write(max(f)-min(f));
add(new void(frame h, transform t){
  dot(h, min(f), blue);
  dot(h, max(f), blue);
});
(62.7668742216687,202.243835616438)

Surely it should be (60, 200)? Running asy -vvv shows TeX give Asymptote the correct values.

Note that if you change 200 to 2000 then the second value is 1995 and the black box goes outside the boundary.

I'm suspecting something wrong with

const double tex2ps=72.0/72.27;
const double ps2tex=1.0/tex2ps;

although changing it to 1 makes it even more wrong.

Looks like there's a padding of 3 TeX point inserted in somewhere...

johncbowman commented 1 month ago

There's nothing wrong with those unit conversions: 72.27 TeX points=72.0 Adobe points (bp)=1inch. You are probably enountering the "Magic dvips offsets" in picture.cc, which were empirically tuned to support dvips. I once asked the author of dvips Tomas Rokicki if he knew why they are needed but he didn't know either. The solution is to use -tex pdflatex.