Skip to content

pystack exhausted error in load_glyphs #39

Closed
@kmatch98

Description

@kmatch98

When using bitmap_label I can sometimes trigger a RuntimeError: pystack exhausted.

Hardware: PyPortal
CircuitPython version: Adafruit CircuitPython 6.2.0-beta.3-5-g2ae8a44b2 on 2021-03-04; Adafruit PyPortal with samd51j20

Traceback (most recent call last):
  File "code.py", line 84, in <module>
  File "/lib/adafruit_displayio_layout/widgets/dial.py", line 300, in __init__
  File "/lib/adafruit_displayio_layout/widgets/dial.py", line 567, in draw_labels
  File "/lib/adafruit_display_text/bitmap_label.py", line 137, in __init__
  File "/lib/adafruit_display_text/bitmap_label.py", line 244, in _reset_text
  File "/lib/adafruit_display_text/bitmap_label.py", line 370, in _text_bounding_box
  File "/lib/adafruit_bitmap_font/glyph_cache.py", line 48, in get_glyph
  File "/lib/adafruit_bitmap_font/pcf.py", line 346, in load_glyphs
  File "/lib/adafruit_bitmap_font/pcf.py", line 184, in _read_metrics
RuntimeError: pystack exhausted

Code done running.

This Error happens when I load the font (see snippet below) and then use bitmap_label to generate the bitmap. I tried with various PCF font files generated with the adafruit web BDF->PCF converter code.

font_file2 = "fonts/BitstreamVeraSans-Bold-16.pcf"
my_font2 = bitmap_font.load_font(font_file2)

Strangely, if I perform load_glyphs earlier in my code then it works just fine, like so:

font_file2 = "fonts/BitstreamVeraSans-Bold-16.pcf"
my_font2 = bitmap_font.load_font(font_file2)
glyphs = "0123456789"
my_font2.load_glyphs(glyphs)

The error seems to be triggered in this self._read:

        if compressed_metrics:
            (
                left_side_bearing,
                right_side_bearing,
                character_width,
                character_ascent,
                character_descent,
            ) = self._read("5B")

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