make_font

Convert a TrueType font into a bitmap font module for the board.

uv run tools/make_font.py DejaVuSans-Bold.ttf 40 src/font_large.py

The generated module holds 1-bit glyphs in MONO_HLSB order (rows of (width + 7) // 8 bytes, most significant bit left), as text expects. Pixels at least half covered by the anti-aliased rendering are set.

Attributes

Functions

render_glyph(font, char, height)

Return (width, rows) where rows is the glyph bitmap in MONO_HLSB.

build_module(font_path, size[, charset, glyph_map, ...])

Generate the font module source.

main()

Run the command line tool.

Module Contents

make_font.FONT_DIR = '/usr/share/fonts/truetype/dejavu'
make_font.CHARSET = 'äöüÄÖÜß°²³µμ€–·„“”‚‘’…—→'
make_font.render_glyph(font, char, height)

Return (width, rows) where rows is the glyph bitmap in MONO_HLSB.

make_font.FONT_LICENSE = 'DejaVu Sans: Bitstream Vera license, DejaVu changes public domain (see THIRD_PARTY_NOTICES.md)'
make_font.build_module(font_path, size, charset=CHARSET, glyph_map=None, title=None, license_note=FONT_LICENSE)

Generate the font module source.

The glyphs are those of charset, or of glyph_map ({key: char}) when they are stored under names instead of their characters (icons).

make_font.main()

Run the command line tool.