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

Will fail if font does not have expected glyphs #50

Closed
caternuson opened this issue Jun 18, 2020 · 1 comment
Closed

Will fail if font does not have expected glyphs #50

caternuson opened this issue Jun 18, 2020 · 1 comment

Comments

@caternuson
Copy link
Contributor

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'>
>>> 
@caternuson
Copy link
Contributor Author

Hopefully fixed with #51

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

No branches or pull requests

1 participant