[dev-context] metafun: colored dotlabel fails (fix included)

Sanjoy Mahajan sanjoy at mrao.cam.ac.uk
Wed Jul 25 06:41:48 CEST 2007


In metafun, a colored dotlabel fails.  A fix is included below.

Here is a minimal test file:

  beginfig(1)
    dotlabel(btex etex, origin) withcolor green;
  endfig;
  end

It produces this error:

  $ mpost -mem=metafun t
  This is MetaPost, Version 0.993 (Web2C 7.5.6)
  (t.mp
  ! Extra tokens will be flushed.
  <to be read again> 
		     withcolor
  l.2   dotlabel(btex etex, origin) withcolor
					      green;
  ? 

[I'm using the metafun that was built from context 2007.04.17.]

Metapost used to have this problem, for which John Hobby sent the
following updated definition of dotlabel():

  vardef dotlabel@#(expr s,z) text t_ =
    label@#(s,z) t_;
    interim linecap:=rounded;
    draw z withpen pencircle scaled dotlabeldiam t_;
  enddef;

It is part of the current plain.mp (mpost 0.993).  But the metafun.mp
format-generation file includes mp-base.mp, which has the old definition
of dotlabel:

  vardef dotlabel@#(expr s,z) =
    label@#(s,z);
    interim linecap:=rounded;
    draw z withpen pencircle scaled dotlabeldiam;
  enddef;

The patch below fixes the minimal test case above as well as the
larger real file that I started with:

--- a/metapost/context/base/mp-base.mp	2007-07-25 00:19:15.379198092 -0400
+++ b/metapost/context/base/mp-base.mp	2007-07-25 00:19:37.072411646 -0400
@@ -477,10 +477,10 @@
 
 def label = draw thelabel enddef;
 newinternal dotlabeldiam; dotlabeldiam:=3bp;
-vardef dotlabel@#(expr s,z) =
-  label@#(s,z);
+vardef dotlabel@#(expr s,z) text t_ =
+  label@#(s,z) t_;
   interim linecap:=rounded;
-  draw z withpen pencircle scaled dotlabeldiam;
+  draw z withpen pencircle scaled dotlabeldiam t_;
 enddef;
 def makelabel = dotlabel enddef;
 


More information about the dev-context mailing list