Skip to content

Adding pcf font files to example scripts. Few other fixes #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Introduction
:target: https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font/actions/
:alt: Build Status

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

Dependencies
Expand Down Expand Up @@ -53,14 +53,23 @@ To install in a virtual environment in your current project:
Usage Example
=============

.. code-block::python
.. code-block:: python

from adafruit_bitmap_font import bitmap_font
from displayio import Bitmap
font = bitmap_font.load_font("scientifica-11.bdf", Bitmap)
font = bitmap_font.load_font("fonts/Arial-16.bdf", Bitmap)
print(font.get_glyph(ord("A")))


Creating Fonts
==============

See `this learn guide <https://learn.adafruit.com/custom-fonts-for-pyportal-circuitpython-display>`_ for more information about building custom fornt files

The command line tool :code:`otf2bdf` can be used make bdf files for use with this library.

The command line tool :code:`bdftopcf` can be used make pcf files for use with this library.

Contributing
============

Expand Down
13 changes: 11 additions & 2 deletions examples/bitmap_font_displayio_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
import displayio
from adafruit_bitmap_font import bitmap_font

font = bitmap_font.load_font("fonts/Arial-16.bdf")
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY

# try uncommenting different font files if you like
font_file = "fonts/Arial-16.bdf"
# font_file = "fonts/yasashi24.pcf"

font = bitmap_font.load_font(font_file)

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

Expand Down Expand Up @@ -59,7 +68,7 @@
group.append(tile_grid)

# Add the Group to the Display
board.DISPLAY.show(group)
display.show(group)

while True:
pass
6 changes: 5 additions & 1 deletion examples/bitmap_font_label_magtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
# wait until we can refresh the display
time.sleep(display.time_to_refresh)

# try uncommenting different font files if you like
font_file = "fonts/Arial-16.bdf"
# font_file = "fonts/yasashi24.pcf"

# Set text, font, and color
text = "HELLO WORLD\nbitmap_font example"
font = bitmap_font.load_font("fonts/Arial-16.bdf")
font = bitmap_font.load_font(font_file)
color = 0xFFFFFF
background_color = 0x999999

Expand Down
9 changes: 8 additions & 1 deletion examples/bitmap_font_label_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font

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

# try uncommenting different font files if you like
font_file = "fonts/Arial-16.bdf"
# font_file = "fonts/yasashi24.pcf"

# Set text, font, and color
text = "HELLO WORLD"
font = bitmap_font.load_font("fonts/Arial-16.bdf")
font = bitmap_font.load_font(font_file)
color = 0xFF00FF

# Create the tet label
Expand Down