Skip to content

Will fail if font does not have expected glyphs #50

Closed
@caternuson

Description

@caternuson

Not all fonts have all expected characters used to check height. Maybe add some try/except to catch this?

Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit Circuit Playground Bluefruit with nRF52840
>>> from adafruit_bitmap_font import bitmap_font
>>> from adafruit_display_text import label
>>> font = bitmap_font.load_font("/monoMMM_5_90.bdf")
>>> my_label = label.Label(font, text="hello", color=0xFFFFFF)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_display_text/label.py", line 122, in __init__
  File "adafruit_display_text/label.py", line 264, in _update_text
  File "adafruit_display_text/label.py", line 144, in _create_background_box
AttributeError: 'NoneType' object has no attribute 'height'
>>> glyph = font.get_glyph(ord("M"))
>>> type(glyph)
<class 'Glyph'>
>>> glyph = font.get_glyph(ord(" "))
>>> type(glyph)
<class 'NoneType'>
>>> glyph = font.get_glyph(ord("j"))
>>> type(glyph)
<class 'NoneType'>
>>> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions