Skip to content

Commit d96e66f

Browse files
authored
Merge pull request #33 from FoamyGuy/pcf_examples
Adding pcf font files to example scripts. Few other fixes
2 parents da4fa0b + 97c0318 commit d96e66f

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

README.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Introduction
1313
:target: https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font/actions/
1414
:alt: Build Status
1515

16-
Loads bitmap fonts into CircuitPython's displayio. BDF files are well supported. PCF and TTF
16+
Loads bitmap fonts into CircuitPython's displayio. BDF and PCF files are well supported. TTF
1717
support is not yet complete.
1818

1919
Dependencies
@@ -53,14 +53,23 @@ To install in a virtual environment in your current project:
5353
Usage Example
5454
=============
5555

56-
.. code-block::python
56+
.. code-block:: python
5757
5858
from adafruit_bitmap_font import bitmap_font
5959
from displayio import Bitmap
60-
font = bitmap_font.load_font("scientifica-11.bdf", Bitmap)
60+
font = bitmap_font.load_font("fonts/Arial-16.bdf", Bitmap)
6161
print(font.get_glyph(ord("A")))
6262
6363
64+
Creating Fonts
65+
==============
66+
67+
See `this learn guide <https://learn.adafruit.com/custom-fonts-for-pyportal-circuitpython-display>`_ for more information about building custom fornt files
68+
69+
The command line tool :code:`otf2bdf` can be used make bdf files for use with this library.
70+
71+
The command line tool :code:`bdftopcf` can be used make pcf files for use with this library.
72+
6473
Contributing
6574
============
6675

examples/bitmap_font_displayio_simpletest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@
1111
import displayio
1212
from adafruit_bitmap_font import bitmap_font
1313

14-
font = bitmap_font.load_font("fonts/Arial-16.bdf")
14+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
15+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
16+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
17+
display = board.DISPLAY
18+
19+
# try uncommenting different font files if you like
20+
font_file = "fonts/Arial-16.bdf"
21+
# font_file = "fonts/yasashi24.pcf"
22+
23+
font = bitmap_font.load_font(font_file)
1524

1625
bitmap = displayio.Bitmap(320, 240, 2)
1726

@@ -59,7 +68,7 @@
5968
group.append(tile_grid)
6069

6170
# Add the Group to the Display
62-
board.DISPLAY.show(group)
71+
display.show(group)
6372

6473
while True:
6574
pass

examples/bitmap_font_label_magtag.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515
# wait until we can refresh the display
1616
time.sleep(display.time_to_refresh)
1717

18+
# try uncommenting different font files if you like
19+
font_file = "fonts/Arial-16.bdf"
20+
# font_file = "fonts/yasashi24.pcf"
21+
1822
# Set text, font, and color
1923
text = "HELLO WORLD\nbitmap_font example"
20-
font = bitmap_font.load_font("fonts/Arial-16.bdf")
24+
font = bitmap_font.load_font(font_file)
2125
color = 0xFFFFFF
2226
background_color = 0x999999
2327

examples/bitmap_font_label_simpletest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@
77
from adafruit_display_text import label
88
from adafruit_bitmap_font import bitmap_font
99

10+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
11+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
12+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
1013
display = board.DISPLAY
1114

15+
# try uncommenting different font files if you like
16+
font_file = "fonts/Arial-16.bdf"
17+
# font_file = "fonts/yasashi24.pcf"
18+
1219
# Set text, font, and color
1320
text = "HELLO WORLD"
14-
font = bitmap_font.load_font("fonts/Arial-16.bdf")
21+
font = bitmap_font.load_font(font_file)
1522
color = 0xFF00FF
1623

1724
# Create the tet label

0 commit comments

Comments
 (0)