From 046d4310aa9cabe9f4dcffb1c380f3b624bacaa9 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 5 Apr 2021 18:35:16 -0500 Subject: [PATCH 1/2] change simpletest script to work with CPython and CircuitPython --- examples/bitmap_font_simpletest.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/bitmap_font_simpletest.py b/examples/bitmap_font_simpletest.py index 5288271..61ac733 100644 --- a/examples/bitmap_font_simpletest.py +++ b/examples/bitmap_font_simpletest.py @@ -1,18 +1,20 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT -# Call this with the font file as the command line argument. +""" +This example loads a font and uses it to print an +ASCII art representation of the given string specimen +""" -import os -import sys - -# Add paths so this runs in CPython in-place. -sys.path.append(os.path.join(sys.path[0], "..")) from adafruit_bitmap_font import bitmap_font # pylint: disable=wrong-import-position -sys.path.append(os.path.join(sys.path[0], "../test")) -font = bitmap_font.load_font(sys.argv[1]) -specimen = "Adafruit CircuitPython" if len(sys.argv) == 2 else sys.argv[2] +# you can change this to a different bdf or pcf font file +font_file = "fonts/LeagueSpartan-Bold-16.bdf" + +# you can change the string that will get printed here +specimen = "<3 Blinka" + +font = bitmap_font.load_font(font_file) _, height, _, dy = font.get_bounding_box() font.load_glyphs(specimen) From 49f8a807e0c4abd36d778c1850d156902e42770e Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 5 Apr 2021 20:45:20 -0500 Subject: [PATCH 2/2] change variable name to message --- examples/bitmap_font_simpletest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/bitmap_font_simpletest.py b/examples/bitmap_font_simpletest.py index 61ac733..693890e 100644 --- a/examples/bitmap_font_simpletest.py +++ b/examples/bitmap_font_simpletest.py @@ -12,15 +12,15 @@ font_file = "fonts/LeagueSpartan-Bold-16.bdf" # you can change the string that will get printed here -specimen = "<3 Blinka" +message = "<3 Blinka" font = bitmap_font.load_font(font_file) _, height, _, dy = font.get_bounding_box() -font.load_glyphs(specimen) +font.load_glyphs(message) for y in range(height): - for c in specimen: + for c in message: glyph = font.get_glyph(ord(c)) if not glyph: continue