fontio
– Core font related data structures
Note
This module is intended only for low-level usage. For working with fonts in CircuitPython see the adafruit_bitmap_font library. For information on creating custom fonts for use in CircuitPython, see this Learn guide
Available on these boards
- class fontio.FontProtocol
Bases:
typing_extensions.Protocol
A protocol shared by
BuiltinFont
and classes inadafruit_bitmap_font
- class fontio.BuiltinFont
A font built into CircuitPython
Creation not supported. Available fonts are defined when CircuitPython is built. See the Adafruit_CircuitPython_Bitmap_Font library for dynamically loaded fonts.
- bitmap: displayio.Bitmap
Bitmap containing all font glyphs starting with ASCII and followed by unicode. Use
get_glyph
in most cases. This is useful for use withdisplayio.TileGrid
andterminalio.Terminal
.
- get_bounding_box() Tuple[int, int]
Returns the maximum bounds of all glyphs in the font in a tuple of two values: width, height.
- get_glyph(codepoint: int) Glyph
Returns a
fontio.Glyph
for the given codepoint or None if no glyph is available.
- class fontio.Glyph(bitmap: displayio.Bitmap, tile_index: int, width: int, height: int, dx: int, dy: int, shift_x: int, shift_y: int)
Storage of glyph info
Named tuple used to capture a single glyph and its attributes.
- Parameters:
bitmap – the bitmap including the glyph
tile_index – the tile index within the bitmap
width – the width of the glyph’s bitmap
height – the height of the glyph’s bitmap
dx – x adjustment to the bitmap’s position
dy – y adjustment to the bitmap’s position
shift_x – the x difference to the next glyph
shift_y – the y difference to the next glyph