% --- start of displayed preamble in the book ---
vardef stxp(expr s,p)=
  save len,prefix,car,lab,xpos,cpos,ratio;
  numeric len[];
  string prefix,car;
  picture lab;
  len0=0;
  for i:=length s step -1 until 1:
    prefix:=substring(0,i) of s;
    lab:=thelabel(prefix,(0,0));
    len[i]=2*(xpart(urcorner lab));
  endfor;
  ratio=arclength(p)/len[length s];

  for i=0 upto (length s)-1:
    car:=substring(i,i+1) of s;
    if car<>" ":
      xpos:=((len[i]+len[i+1])/2)*ratio;
      cpos:=arctime xpos of p;
      lab:=thelabel(car,(0,0));
      draw lab rotated (angle (direction cpos of p))
               shifted (point cpos of p);
    fi;
  endfor;
enddef;
% --- end of displayed preamble in the book ---
% graphic converted to gray in book using 'color2gray'
defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
path p;
p=((0,0)..(4cm,7cm)..(5cm,3cm)..(3cm,2cm)) yscaled .5;
draw p withcolor red;
stxp("IN PRINCIPIO CREAVIT DEUS C�LUM ET TERRAM.",p);
endfig;
end;