mono_fonts.py

../_images/mono_fonts.png

Test for write_font_converter.py and bitmap method

 1"""
 2mono_fonts.py
 3=============
 4
 5.. figure:: /_static/mono_fonts.png
 6  :align: center
 7
 8  Test for write_font_converter.py and bitmap method
 9
10"""
11
12import time
13import gc9a01
14import tft_config
15
16import inconsolata_16 as font_16
17import inconsolata_32 as font_32
18import inconsolata_64 as font_64
19
20
21def main():
22    fast = False
23
24    def display_font(font):
25        tft.fill(gc9a01.BLUE)
26        column = 0
27        row = 0
28        for char in font.MAP:
29            tft.bitmap(font, column, row, font.MAP.index(char))
30            column += font.WIDTH
31            if column >= tft.width() - font.WIDTH:
32                row += font.HEIGHT
33                column = 0
34
35                if row > tft.height() - font.HEIGHT:
36                    row = 0
37
38            if not fast:
39                time.sleep(0.05)
40
41    tft = tft_config.config(tft_config.TALL)
42
43    tft.init()
44
45    while True:
46        for font in [font_16, font_32, font_64]:
47            display_font(font)
48
49        fast = not fast
50
51
52main()