[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string-width error?



Peter Szolovits provided some useful code to size a bounding box for
displaying text. This answers Peter Stone's problem in a practical sense,
but his question of why

>(string-width
> "This adds new patterns and catalysts to a soup. A nil
>material can be used if nothing is added.
>This adds new patterns and catalysts to a soup. A nil
>material can be used if nothing is added.
>This adds new patterns and catalysts to a soup. A nil
>material can be used if nothing is added.
>This adds new patterns and catalysts to a soup. A nil
>material can be used if nothing is added."
> '("times" 12 :plain))
>
>=> 1164

but

>(string-width
> "This adds new patterns and catalysts to a soup. A nil
>material can be used if nothing is added.
>This adds new patterns and catalysts to a soup. A nil
>material can be used if nothing is added.
>This adds new patterns and catalysts to a soup. A nil
>material can be used if nothing is added."
> '("times" 12 :plain))
>
>=> 1164

remains.

A little testing reveals that string-width only uses the first 255
characters in its argument string to calculate the pixel width; any
characters beyond that are ignored. This is probably a reasonable limit for
most screen and font sizes, but it seems to be an undocumented one.





=== John R. Gersh                        John_Gersh@jhuapl.edu
=== The Johns Hopkins University Applied Physics Laboratory
=== Laurel, MD 20723-6099 USA
=== +1 (301)953-5503 (voice)             +1 (301)953-6583 (fax)