Skip to content
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

adding forkawesome example #42

Merged
merged 2 commits into from
Apr 3, 2021
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
39 changes: 39 additions & 0 deletions examples/bitmap_font_label_forkawesome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: 2021 Tim Cocks
# SPDX-License-Identifier: MIT

"""
This example uses addfruit_display_text.label to display fork awesome
icons.

More info here: https://emergent.unpythonic.net/01606790241
"""

import board
from forkawesome_icons import microchip, python, terminal
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

font_file = "fonts/forkawesome-42.pcf"

# Set text, font, and color
text = "{} {} {}".format(terminal, python, microchip)
font = bitmap_font.load_font(font_file)
color = 0xFF00FF

# Create the tet label
text_area = label.Label(font, text=text, color=color)

# Set the location
text_area.anchor_point = (0.5, 0.5)
text_area.anchored_position = (display.width // 2, display.height // 2)

# Show it
display.show(text_area)

while True:
pass
Binary file added examples/fonts/forkawesome-42.pcf
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/fonts/forkawesome-42.pcf.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2018, Fork Awesome (https://forkawesome.github.io), with Reserved Font Name Fork Awesome.

# SPDX-License-Identifier: OFL-1.1-RFN
Loading