aboutsummaryrefslogtreecommitdiff
path: root/circuitpython/tools/bitmap_font/adafruit_bitmap_font/glyph_cache.py
blob: 383596ba8fc7bc0128c6ad2fd686308a550a6755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gc

class GlyphCache:
    def __init__(self):
        self._glyphs = {}

    def get_glyph(self, code_point):
        if code_point in self._glyphs:
            return self._glyphs[code_point]

        s = set()
        s.add(code_point)
        self._glyphs[code_point] = None
        self.load_glyphs(s)
        gc.collect()
        return self._glyphs[code_point]