Skip to content

displayio.bitmap "Space" character gives ValueError #7904

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

Closed
jposada202020 opened this issue Apr 24, 2023 · 3 comments
Closed

displayio.bitmap "Space" character gives ValueError #7904

jposada202020 opened this issue Apr 24, 2023 · 3 comments

Comments

@jposada202020
Copy link

CircuitPython version

Adafruit CircuitPython 8.1.0-beta.0-62-g4986ad6d6-dirty on 2023-03-30; Adafruit PyPortal Titano with samd51j20

and

Adafruit CircuitPython 8.1.0-beta.1-36-g7d02bff6b on 2023-04-20; Adafruit Feather RP2040 DVI with rp2040

Code/REPL

import board
import displayio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import label, bitmap_label

display = board.DISPLAY
main_group = displayio.Group()
MEDIUM_FONT = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf")

bitmap = displayio.Bitmap(display.height, display.width, 1)
palette = displayio.Palette(2)
palette[0] = 0xFFFFFF

some_text = label.Label(
    MEDIUM_FONT,
    text="CircuitPython",
    x=display.width // 2,
    y=display.height // 2,
)
main_group.append(some_text)
display.show(main_group)

print("This is good")

some_text2 = label.Label(
    MEDIUM_FONT,
    text="Circuit Python",
    x=display.width // 3,
    y=display.height // 3,
)
main_group.append(some_text2)
display.show(main_group)

Behavior

>>> import t
This is good
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "t.py", line 29, in <module>
  File "/lib/adafruit_display_text/label.py", line 100, in __init__
  File "/lib/adafruit_display_text/label.py", line 424, in _reset_text
  File "/lib/adafruit_display_text/label.py", line 281, in _update_text
  File "/lib/adafruit_bitmap_font/glyph_cache.py", line 54, in get_glyph
  File "/lib/adafruit_bitmap_font/bdf.py", line 191, in load_glyphs
ValueError: width must be 1-32767

Description

As showed in the bug code the text gives a ValueError. This used to work as in the advance example (aka test suite) for the library... here https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/blob/main/examples/display_text_advance_example.py

I used the example for this PR
adafruit/Adafruit_CircuitPython_Display_Text#181

Additional information

Not sure, maybe we change for checking the value of the bitmap. the number sounds familiar but I did not look in the core for clues

@jposada202020 jposada202020 changed the title displayio.bitmap "Space" characther given ValueError displayio.bitmap "Space" character gives ValueError Apr 24, 2023
@RetiredWizard
Copy link

RetiredWizard commented Apr 25, 2023

I think this may have been fixed by #7867 which was merged on 4/20. I tested using the Feather RP2040 DVI using a build from 4/21 and didn't see the issue. Can you try the latest build and retest?

@jposada202020
Copy link
Author

Thanks. @RetiredWizard ill try tomorrow. Day pystack ran out 😆

@jposada202020
Copy link
Author

That made it. Thank you @RetiredWizard :)

@tannewt tannewt added this to the Long term milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants