The ttf file is also included in case you need to generate other sizes.
The font uses character codes starting at 0xf000, so using regular characters like "012" or "abc" won't show anything. Instead, to find the code of a character, visit the forkawesome website, click the icon you want, and look for the Unicode (f322 for the fa-python icon). Then, in your CircuitPython code, create a label with the text "\uf322" or chr(0xf322) and the FontAwesome font to show it:
from adafruit_bitmap_font.bitmap_font import load_font from adafruit_display_text.label import Label from displayio import Group font = load_font("/forkawesome-36.pcf") text = chr(0xf322) group = Group() label = Label(font=font, text=text, background_color=0x111111) label.anchor_point = (0, 0) label.anchored_position = (0,0) group.append(label) board.DISPLAY.show(group) while True: pass
You can also use the attachment icons.py as a reference for the character codes. The python identifiers are the same as the font's "id", except that "-" is replaced with "_","500px" is renamed to "fivehundredpx", and several names that are Python built in functions or reserved words have an underscore appended (file_, filter_, list_, map_, print_, try_).
Files currently attached to this page:
Entry first conceived on 1 December 2020, 2:37 UTC, last modified on 28 December 2020, 22:06 UTC
Website Copyright © 2004-2021 Jeff Epler