[tex-k] note from Don Knuth -- bug(s) in MetaPost?
Maggie McLoughlin
mam at theory.Stanford.EDU
Thu Jan 16 05:31:55 CET 2014
Dear TeX-Kers,
The "drawdot" command in MetaPost hasn't been working for me.
Consider the following input file test.mp:
> beginfig(1)
> for j=1 upto 9:
> pickup pencircle scaled .4;
> drawdot (10j,0) withpen pencircle scaled .5j;
> pickup pencircle scaled .5j;
> drawdot (10j,10);
> endfor
> endfig;
> bye.
I ran this with newly installed MacTeX from the TeX Collection 2013.
When I say "tex mproof test.1" and then "dvips test -o", I get an output
file that contains nine correctly filled circles above nine strange
partially filled circles. The Postscript file begins with
> %!PS-Adobe-2.0
> %%Creator: dvips(k) 5.993 Copyright 2013 Radical Eye Software
> %%Title: mproof.dvi
> %%CreationDate: Wed Jan 15 19:07:45 2014
> %%Pages: 1
> %%PageOrder: Ascend
> %%BoundingBox: 0 0 612 792
> %%DocumentFonts: CMTEX10 CMR7 CMR10
> %%DocumentPaperSizes: Letter
and then a whole bunch of infrastructure stuff and then the guts starts with
> %%BeginDocument: test.1
> %!PS
> %%BoundingBox: 9 -3 93 13
> %%HiResBoundingBox: 9.55 -2.45 92.45 12.25
> %%Creator: MetaPost 1.803
> %%CreationDate: 2014.01.15:1907
> %%Pages: 1
> %%BeginProlog
> %%EndProlog
> %%Page: 1 1
> 0 0 0 setrgbcolor 0 0.5 dtransform truncate idtransform setlinewidth pop
> [] 0 setdash 1 setlinejoin 10 setmiterlimit
> newpath 10.2 0 moveto
> 10.2 0.05304 10.17892 0.10391 10.14142 0.14142 curveto
> 10.10391 0.17892 10.05304 0.2 10 0.2 curveto
> 9.94696 0.2 9.89609 0.17892 9.85858 0.14142 curveto
> 9.82108 0.10391 9.8 0.05304 9.8 0 curveto
> 9.8 -0.05304 9.82108 -0.10391 9.85858 -0.14142 curveto
> 9.89609 -0.17892 9.94696 -0.2 10 -0.2 curveto
> 10.05304 -0.2 10.10391 -0.17892 10.14142 -0.14142 curveto
> 10.17892 -0.10391 10.2 -0.05304 10.2 0 curveto closepath
> gsave fill grestore stroke
> newpath 10.25 10 moveto
> 10.25 10.0663 10.22366 10.12988 10.17677 10.17677 curveto
> 10.12988 10.22366 10.0663 10.25 10 10.25 curveto
> 9.9337 10.25 9.87012 10.22366 9.82323 10.17677 curveto
> 9.77634 10.12988 9.75 10.0663 9.75 10 curveto
> 9.75 9.9337 9.77634 9.87012 9.82323 9.82323 curveto
> 9.87012 9.77634 9.9337 9.75 10 9.75 curveto
> 10.0663 9.75 10.12988 9.77634 10.17677 9.82323 curveto
> 10.22366 9.87012 10.25 9.9337 10.25 10 curveto closepath fill
> 0 1 dtransform truncate idtransform setlinewidth pop
The bottom "newpath .. pop" works better, but the top "newpath .. stroke"
fails rather spectacularly. The definition of "drawdot" in the
"plain mem" file seems to use currentpen, without setting currentpen.
I believe the semantics of drawdot specify that "withpen" overrides
the current pen, while lack of "withpen" uses the current pen.
Thus, it seems to me, both lines of dots should have been identical.
But they obviously aren't.
Looking further, I believe BOTH of these are incorrect; because
both of them do a "stroke" as well as a "fill", while drawdot
in METAFONT is simply a "fill".
I also see that "withpen pencircle scaled 2" gives different results
from "withpen (pencircle scaled 2)"! In METAFONT there is no difference
between these.
Thus it seems that there are MULTIPLE errors in METAPOST with respect
to drawdot.
The idea of drawdot (see the METAFONT manual page 150) is to
"draw" a one-point path. When making fonts, this can help to
correct pixels at the endpoints of another path (as mentioned there).
With PostScript there is no such problem, at least not usually;
I suppose that's why people who come to METAPOST without beginning
with METAFONT have not used drawdot enough to run into this bug.
I'm kludging around this in my own METAPOST programs until the bug is fixed.
Sincerely, Don
More information about the tex-k
mailing list