%!PS-Adobe-2.0
%%Title: Blue Book Program 11, on page 171
%%Creator: Adobe Systems Incorporated 
%%CreationDate: Thu Dec 28 17:41:49 PST 1989
%%EndComments

/pathtextdict 26 dict def

/pathtext
  { pathtextdict begin
	/offset exch def
	/str exch def
	
	/pathdist 0 def
	/setdist offset def
	/charcount 0 def
	gsave
	  flattenpath
	  {movetoproc}  {linetoproc}
	  {curvetoproc} {closepathproc }
	  pathforall
	grestore
	newpath
	end
  } def
  
pathtextdict begin
/movetoproc
  { /newy exch def /newx exch def
	/firstx newx def /firsty newy def
	/ovr 0 def
	newx newy transform
	/cpy exch def /cpx exch def
	} def
	
/linetoproc
  { /oldx newx def /oldy newy def
	/newy exch def /newx exch def
	/dx newx oldx sub def
	/dy newy oldy sub def
	/dist dx dup mul dy dup mul add sqrt def
	dist 0 ne
	  { /dsx dx dist div ovr mul def
	    /dsy dy dist div ovr mul def
	    
	    oldx dsx add oldy dsy add transform
	    /cpy exch def /cpx exch def
	    /pathdist pathdist dist add def
		{ setdist pathdist le
		  { charcount str length lt
			{setchar} {exit} ifelse }
		  { /ovr setdist pathdist sub def
			exit }
		  ifelse
		} loop
      } if
  } def
  
/curvetoproc
  { (ERROR: No curveto's after flattenpath!) print
  } def
  
/closepathproc
  { firstx firsty linetoproc
	firstx firsty movetoproc
  } def
  
/setchar
  { /char str charcount 1 getinterval def

	/charcount charcount 1 add def
	/charwidth char stringwidth pop def
	gsave
	  cpx cpy itransform translate
	  dy dx atan rotate
	  0 0 moveto char show
	  currentpoint transform
	  /cpy exch def /cpx exch def
	grestore
	/setdist setdist charwidth add def
  } def
end


/Helvetica findfont 16 scalefont setfont

newpath
  200 500 70 0 270 arc
  200 110 add 500 70 270 180 arc
  
(If my film makes one more person feel\
 miserable I'll feel I've done my job.\
 -- WOODY ALLEN) 55 pathtext
 
newpath
  150 310 moveto 360 310 lineto
  360 400 lineto 150 400 lineto
  closepath
  360 347 moveto 410 330 lineto
  410 380 lineto 360 363 lineto
2 setlinewidth stroke

% A PROBLEM FOR THE READER:  This algorithm places characters 
% along the path according to the origin of each character.  
% Rewrite the algorithm so that the characters are placed 
% according to the center of their width. This will yield 
% better results around sharp curves and when larger point
% sizes are used.

showpage
% But what does it do?