[metapost] accessing letters in picture (for...within loop)

Stephan Hennig mailing_list at arcor.de
Tue Nov 21 13:21:06 CET 2006


Taco Hoekwater schrieb:
> Stephan Hennig wrote:
>> want to access the coordinates of single letters.  Is there any way to
>> tell MetaPost to process pictures letter by letter?
> 
> With a "Thank you!" to Hans for a behind-the-scenes answer:
> 
>    string s;
>    for i=0 upto length(t)-1:
>      s := substring(i,i+1) of t ;
>      show s;
>    endfor;

I might be missing the point (in fact, I've not seen Hans' answer yet).
 I need to access properties of single letters such as their coordinates
in the picture, but see no way to get them using the substring operator.
   The coordinates returned for t apply to the left most character's
baseline only.  Since I'm using a proportional font interpolation is no
elegant solution.  Any more help?

Best regards,
Stephan Hennig

PS:  Taco, would it take much to change MetaPost's behaviour in this
respect?  I mean, could for...each process single characters by default?
 Or what is the rationale for returning those arbitrary bunches of
letters?  Since the current behaviour seems not to be documented or
explained I don't think iterating over single letters would introduce an
incompatible change.  What do you think?


More information about the metapost mailing list