Skip to content

displayio.bitmap "Space" character gives ValueError #7904

@jposada202020

Description

@jposada202020

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions