I\'m using PIL to draw text on an image. How would I wrap a string of text. This is my code:
text = \"Lorem ipsum dolor sit amet, consectetur adipisicing eli
The accepted solution wraps text basing on the fixed limit of 40 characters per line, not taking into account the box width (in pixels) nor font size. This may easily lead to underfill or overfill.
Here is a better solution - a simple code snippet to wrap text taking into account font-based width measurement: https://gist.github.com/turicas/1455973