Breaking/Wrapping lines "automatically"

Jorge Godoy godoy at
Thu Mar 23 15:06:22 CET 2006

"Fredrik Lundh" <fredrik at> writes:

> Jorge Godoy wrote:
>> Is there something I can do in PIL to restrict a line to a certain size and
>> have it to break/wrap into a newline automatically?  (Or by using some
>> code, of course...)
> there's no standard function for this purpose, no.
> here's a somewhat rough implementation, based on a WCK demo:
> a somewhat better approach would be to use collect words as long as
> they fit, and write each line as a single string.

Then I'd have to have some means to determine the width of the char (I'm using
a TrueType font due to my need of using Unicode text) to calculate how many
words I can put on a single line... 

I'll take a look at the page above.


Jorge Godoy      <godoy at>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.

More information about the Python-list mailing list