Skip to content

Commit b5fa275

Browse files
authored
Merge pull request #45 from FoamyGuy/simpletest_example
change simpletest script to work with CPython and CircuitPython
2 parents c7b343f + 49f8a80 commit b5fa275

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

examples/bitmap_font_simpletest.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4-
# Call this with the font file as the command line argument.
4+
"""
5+
This example loads a font and uses it to print an
6+
ASCII art representation of the given string specimen
7+
"""
58

6-
import os
7-
import sys
8-
9-
# Add paths so this runs in CPython in-place.
10-
sys.path.append(os.path.join(sys.path[0], ".."))
119
from adafruit_bitmap_font import bitmap_font # pylint: disable=wrong-import-position
1210

13-
sys.path.append(os.path.join(sys.path[0], "../test"))
14-
font = bitmap_font.load_font(sys.argv[1])
15-
specimen = "Adafruit CircuitPython" if len(sys.argv) == 2 else sys.argv[2]
11+
# you can change this to a different bdf or pcf font file
12+
font_file = "fonts/LeagueSpartan-Bold-16.bdf"
13+
14+
# you can change the string that will get printed here
15+
message = "<3 Blinka"
16+
17+
font = bitmap_font.load_font(font_file)
1618

1719
_, height, _, dy = font.get_bounding_box()
18-
font.load_glyphs(specimen)
20+
font.load_glyphs(message)
1921

2022
for y in range(height):
21-
for c in specimen:
23+
for c in message:
2224
glyph = font.get_glyph(ord(c))
2325
if not glyph:
2426
continue

0 commit comments

Comments
 (0)