Skip to content
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

Merged

Conversation

tvoverbeek
Copy link
Contributor

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.

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.
Copy link
Contributor

@eat-sleep-code eat-sleep-code left a 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
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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'

@francesco-vannini
Copy link
Contributor

@tvoverbeek I didn't follow this too closely so if you are OK with these changes you can merge yourself

@tvoverbeek tvoverbeek merged commit cca998b into PiSupply:master Jul 25, 2017
@tvoverbeek tvoverbeek deleted the text-textpos-use-font-metrics branch July 25, 2017 10:43
@francesco-vannini
Copy link
Contributor

Thanks @tvoverbeek

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.

3 participants