S
S
S0ulReaver2012-01-12 02:34:00
Python
S0ulReaver, 2012-01-12 02:34:00

Python, PIL, text wrapping

Task: generate an image with text. Used PIL. Of course, there is a text output there, but it outputs exactly to the line, and it does not support hyphenation characters, but it is required. Is there any text formatting in the library? Well, or mb who has already written his cast, or do you still have to file your own?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
phasma, 2012-01-12
@S0ulReaver

margin = offset = 40
for line in textwrap.wrap(text, width=40):
draw.text((margin, offset), line, font=font, fill="#aa0000")
offset += font.getsize(line)[1]

stackoverflow.com/questions/8257147/wrap-text-in-pil

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question