Skip to content

Use of get_bounding_box is not safe for certain fonts #25

Closed
@kevinjwalters

Description

@kevinjwalters

The documentation informs the user that there needs to be a get_bounding_box method on the font. There are fonts which do meet this criteria but may return None. Fonts loaded using adafruit_bitmap_font have a return value that depends on the content of a bdf file:

https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font/blob/master/adafruit_bitmap_font/bdf.py#L67-L79

There are two sequence dereferences in the code currently for [1] from get_bounding_box() which won't handle this elegantly and will confuse users who are not intimately familiar with the content of the bdf file. Perhaps many/all bdf files include this data, though?

I'm a hardcore terminalio.FONT user myself, I only noticed this as part of a discussion in Adafruit Forums: Centre text string on TFTFeatherwing with @wildestpixel

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions