-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use font metrics instead of fixed with calculations in text.py and textpos.py #142
Use font metrics instead of fixed with calculations in text.py and textpos.py #142
Conversation
Modified text.py and textpos.py to use font metrics instead of fixed width calculations. So non fixed width fonts (e.g. FreeSans) work as expected. In textpos.py do not display lines which are off the bottom of the screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding line 44 of text.py and line 123 of textpos.py: These appear to be inserting a space before the text. So all lines after the first line are indented by 1 space.
text_lines[current_line] += " " + word | ||
else: | ||
# No space left on line so move to next one | ||
text_lines.append("") | ||
text_lines.append(u"") | ||
current_line += 1 | ||
text_lines[current_line] += " " + word |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be: text_lines[current_line] += word
There is no need to add the space before as you have incremented the line.
else: | ||
# No space left on line so move to next one | ||
text_lines.append("") | ||
text_lines.append(u"") | ||
current_line += 1 | ||
text_lines[current_line] += " " + word |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be: text_lines[current_line] += word
There is no need to add the space before as you have incremented the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code had the leading space on continuation lines when the text autowraps, so I just left it.
If you do not want the leading space, you can include a new-line ('\n') character in the string for AddText, i.e: 'Text line 1\nText line 2'
@tvoverbeek I didn't follow this too closely so if you are OK with these changes you can merge yourself |
Thanks @tvoverbeek |
Modified text.py and textpos.py to use font metrics instead of fixed
width calculations.
So non fixed width fonts (e.g. FreeSans) work as expected.
In textpos.py do not display lines which are off the bottom of the
screen.