[metapost] Mptopdf crops its output

Taco Hoekwater taco at elvenkind.com
Sat Jun 23 18:14:35 CEST 2007


Franck Pastor wrote:
> Hello,
> 
> I am using MetaPost version 0.993 (TeXLive 2007) on MacOSX Tiger. I  
> usually convert my MetaPost files with mptopdf (version 1.3.2),  
> before transmitting them my to colleagues. But the pdf pictures  
> produces by mptopdf are often cropped, part of the drawing are cut in  
> the edges of the frame.  To give an example, if I create this simple  
> program, which produces an ovegrown "eight":
> 
> beginfig(0);
> 	label(btex 8 etex, (0, 0)) scaled 20 pt;
> endfig;
> end;
> 
> save it under the name "example.mp", enter "mpost example" and then  
> "mptopdf example.0", and view the resulting pdf file or print it, the  
> numeral 8 is  cropped at its top and its bottom.
> 
> Is it the same on other configurations ? And what could I do to avoid  
> it ?

The real problem occurs not in mptopdf, but much sooner, when TeX
typesets the label. The metric information (tfm) specifies a bounding
box for the figure 8 that is not actually large enough to contain
everything that is put on paper.

Editting tfm files is not much fun, it is probably easier to lie to
mpost about the size of the label. The needed correction will
vary per font (and perhaps per character). Here is what seems to
work for this particular image:

beginfig(0);
   label(btex 8 etex, (0, 0)) scaled 20 pt;
   % either enlarge whatever is there
   if false:
     z1 = llcorner currentpicture;  y1 := y1-5pt;
     z3 = urcorner currentpicture;  y3 := y3+10pt;
   else:
   % or use a hardwired value found in a previous run
     z1 = (-59, -80);
     z3 = (59, 85);
   fi;
   z2 = (x3, y1);
   z4 = (x1, x3);
   setbounds currentpicture to z1--z2--z3--z4--cycle;
endfig;
end;






More information about the metapost mailing list