Skip to content

Commit 7feddf5

Browse files
committed
Split out example and lint
1 parent ab11a45 commit 7feddf5

File tree

5 files changed

+36
-39
lines changed

5 files changed

+36
-39
lines changed

README.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ This is easily achieved by downloading
2828

2929
Installing from PyPI
3030
--------------------
31-
.. note:: This library is not available on PyPI yet. Install documentation is included
32-
as a standard element. Stay tuned for PyPI availability!
33-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
34-
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
3531
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
3632
PyPI <https://pypi.org/project/adafruit-circuitpython-bitmap_font/>`_. To install for current user:
3733

@@ -57,7 +53,13 @@ To install in a virtual environment in your current project:
5753
Usage Example
5854
=============
5955

60-
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
56+
.. code-block::python
57+
58+
from adafruit_bitmap_font import bitmap_font
59+
from displayio import Bitmap
60+
font = bitmap_font.load_font("scientifica-11.bdf", Bitmap)
61+
print(font.get_glyph(ord("A")))
62+
6163
6264
Contributing
6365
============

adafruit_bitmap_font/bitmap_font.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,3 @@ def load_font(filename, bitmap=None):
6161
import ttf
6262
return ttf.TTF(font_file)
6363
return None
64-
65-
if __name__ == "__main__":
66-
#pylint: disable=invalid-name
67-
import os
68-
import sys
69-
sys.path.append(os.path.join(sys.path[0], "test"))
70-
font = load_font(sys.argv[1])
71-
72-
_, height, _, dy = font.get_bounding_box()
73-
for y in range(height):
74-
for c in "Adafruit CircuitPython":
75-
glyph = font.get_glyph(ord(c))
76-
if not glyph:
77-
continue
78-
glyph_y = y + (glyph.height - (height + dy)) + glyph.dy
79-
pixels = []
80-
if 0 <= glyph_y < glyph.height:
81-
for i in range(glyph.width):
82-
value = glyph.bitmap[i, glyph_y]
83-
pixel = " "
84-
if value > 0:
85-
pixel = "#"
86-
pixels.append(pixel)
87-
else:
88-
pixels = ""
89-
print("".join(pixels) + " " * (glyph.shift_x - len(pixels)), end="")
90-
print()

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Uncomment the below if you use native CircuitPython modules such as
2121
# digitalio, micropython and busio. List the modules you use. Without it, the
2222
# autodoc module docs will fail to generate with a warning.
23-
# autodoc_mock_imports = ["digitalio", "busio"]
23+
autodoc_mock_imports = ["displayio"]
2424

2525

2626
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

docs/index.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,9 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
27-
the toctree above for use later.
28-
2926
.. toctree::
3027
:caption: Related Products
3128

32-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
33-
the toctree above for use later.
34-
3529
.. toctree::
3630
:caption: Other Links
3731

examples/bitmap_font_simpletest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Call this with the font file as the command line argument.
2+
3+
import os
4+
import sys
5+
6+
from adafruit_bitmap_font import bitmap_font
7+
sys.path.append(os.path.join(sys.path[0], "test"))
8+
font = bitmap_font.load_font(sys.argv[1])
9+
10+
_, height, _, dy = font.get_bounding_box()
11+
for y in range(height):
12+
for c in "Adafruit CircuitPython":
13+
glyph = font.get_glyph(ord(c))
14+
if not glyph:
15+
continue
16+
glyph_y = y + (glyph.height - (height + dy)) + glyph.dy
17+
pixels = []
18+
if 0 <= glyph_y < glyph.height:
19+
for i in range(glyph.width):
20+
value = glyph.bitmap[i, glyph_y]
21+
pixel = " "
22+
if value > 0:
23+
pixel = "#"
24+
pixels.append(pixel)
25+
else:
26+
pixels = ""
27+
print("".join(pixels) + " " * (glyph.shift_x - len(pixels)), end="")
28+
print()

0 commit comments

Comments
 (0)