Skip to content

fix max_glyphs count when text wasn't passed in constructor #56

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

Merged
merged 1 commit into from
Jun 27, 2020

Conversation

FoamyGuy
Copy link
Contributor

Issue was originally raised here: https://forums.adafruit.com/viewtopic.php?f=60&t=166798

This change will always include +1 to the value it passes for max_size to the super class Group. The extra one accounts for the background tilegrid which was introduced recently to fix background color for custom fonts. This way it does not matter whether the user passes text or max_glyphs in the constructor, the behavior is the same both ways.

Crash with current version and fix with new version tested with this:

import board
import terminalio
from adafruit_display_text import label


text = "Hello"
text_area = label.Label(terminalio.FONT, max_glyphs=5)
text_area.x = 10
text_area.y = 10
text_area.text = text
board.DISPLAY.show(text_area)
while True:
    pass

@FoamyGuy FoamyGuy requested a review from a team June 27, 2020 14:59
Copy link
Contributor

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Didn't actually test.

@jepler jepler merged commit 1dcecb9 into adafruit:master Jun 27, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 28, 2020
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.

2 participants