tingbot / tingbot-python

🔩 Python APIs to write apps for Tingbot
Other
18 stars 9 forks source link

Added auto word wrap for text #3

Closed galli-leo closed 8 years ago

galli-leo commented 8 years ago

This pull request enables auto word wrapping for text. This means that if the text would flow over the screen, it is prevented. It also adds the possibility of getting back the size of the text created. This allows for better layout managing.

Before: before

After: after

Example:

size = screen.text(
                "Very long text that spans across the whole screen and therefore needs be split up into two lines."
                xy=(0, 0),
                color='white',
                font_size=20,
            )
print(size) #gives you (450, 40)
joerick commented 8 years ago

Hi @DJLectr0, thanks for submitting this. Sorry it didn't get merged, I've been working on a word wrap implementation that uses Font.metrics(), and also does truncation (https://github.com/tingbot/tingbot-python/blob/master/tingbot/typesetter.py). That's merged now, so I'm closing this PR out.