Skip to content

Conversation

@radarhere
Copy link
Member

Helps #6201

This adds a wrap() method to ImageText.Text. It will allow the user to wrap text within a certain width

from PIL import ImageText
text = ImageText.Text("Hello World!")
text.wrap(50)
print(text.text)  # "Hello\nWorld!"

or within a certain width and height

text = ImageText.Text("Text does not fit within height")
print(text.wrap(50, 25).text == " within height")  # May return a `ImageText.Text` instance
print(text.text)  # "Text does\nnot fit"

or scaling, optionally with a font size limit.

text.wrap(50, 15, "shrink")
text.wrap(50, 15, ("shrink", 7))
text.wrap(58, 10, "grow")
text.wrap(50, 50, ("grow", 12))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant