Skip to content

Commit 1cb188d

Browse files
committed
Add native support for LVGL binary fonts on disk
This allows the terminal to use a font from the disk at /fonts/terminal.lvfontbin for languages that need more characters than we want to ship. TileGrid now support 16bit indices as well. Font files for use with it are generated by the GitHub actions here: https://github.com/adafruit/circuitpython-font-generator
1 parent ca063ae commit 1cb188d

File tree

31 files changed

+1734
-144
lines changed

31 files changed

+1734
-144
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,8 @@ TAGS
9797
# clangd cache
9898
##############
9999
.cache
100+
101+
**/CLAUDE.local.md
102+
103+
# windsurf rules
104+
.windsurfrules

docs/environment.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,18 @@ This feature is not enabled on boards that the CIRCUITPY_OS_GETENV (os CIRCUIPTY
189189
flag has been set to 0. Currently this is primarily boards with limited flash including some
190190
of the Atmel_samd boards based on the SAMD21/M0 microprocessor.
191191

192+
CIRCUITPY_TERMINAL_FONT
193+
~~~~~~~~~~~~~~~~~~~~~~~
194+
Specifies a custom font file path to use for the terminalio console instead of the default
195+
``/fonts/terminal.lvfontbin``. This allows users to create and use custom fonts for the
196+
CircuitPython console.
197+
198+
This feature requires both CIRCUITPY_OS_GETENV and CIRCUITPY_LVFONTIO to be enabled.
199+
200+
Example:
201+
202+
.. code-block::
203+
204+
CIRCUITPY_TERMINAL_FONT="/fonts/myfont.lvfontbin"
205+
192206
`boards that the terminalio core module is available on <https://docs.circuitpython.org/en/latest/shared-bindings/terminalio/>`_

locale/circuitpython.pot

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ msgstr ""
10511051
msgid "File exists"
10521052
msgstr ""
10531053

1054-
#: shared-module/os/getenv.c
1054+
#: shared-module/lvfontio/OnDiskFont.c shared-module/os/getenv.c
10551055
msgid "File not found"
10561056
msgstr ""
10571057

@@ -1247,6 +1247,7 @@ msgstr ""
12471247
#: shared-bindings/digitalio/DigitalInOut.c
12481248
#: shared-bindings/epaperdisplay/EPaperDisplay.c shared-bindings/pwmio/PWMOut.c
12491249
#: shared-module/aurora_epaper/aurora_framebuffer.c
1250+
#: shared-module/lvfontio/OnDiskFont.c
12501251
msgid "Invalid %q"
12511252
msgstr ""
12521253

@@ -1975,6 +1976,7 @@ msgstr ""
19751976
#: shared-bindings/displayio/TileGrid.c
19761977
#: shared-bindings/memorymonitor/AllocationSize.c
19771978
#: shared-bindings/pulseio/PulseIn.c
1979+
#: shared-bindings/tilepalettemapper/TilePaletteMapper.c
19781980
msgid "Slices not supported"
19791981
msgstr ""
19801982

@@ -2042,7 +2044,9 @@ msgstr ""
20422044
msgid "Tile height must exactly divide bitmap height"
20432045
msgstr ""
20442046

2045-
#: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c
2047+
#: shared-bindings/displayio/TileGrid.c
2048+
#: shared-bindings/tilepalettemapper/TilePaletteMapper.c
2049+
#: shared-module/displayio/TileGrid.c
20462050
msgid "Tile index out of bounds"
20472051
msgstr ""
20482052

@@ -4277,7 +4281,9 @@ msgstr ""
42774281
msgid "unreadable attribute"
42784282
msgstr ""
42794283

4280-
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
4284+
#: shared-bindings/displayio/TileGrid.c shared-bindings/terminalio/Terminal.c
4285+
#: shared-bindings/tilepalettemapper/TilePaletteMapper.c
4286+
#: shared-bindings/vectorio/VectorShape.c
42814287
msgid "unsupported %q type"
42824288
msgstr ""
42834289

ports/raspberrypi/common-hal/picodvi/__init__.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ static bool picodvi_autoconstruct_enabled(mp_int_t *default_width, mp_int_t *def
7474
if ((established_timings & 0x80) != 0 &&
7575
preferred_width % 1920 == 0 &&
7676
preferred_height % 1080 == 0) {
77-
*default_width = 720 / 2;
78-
*default_height = 400 / 2;
77+
*default_width = 720;
78+
*default_height = 400;
7979
} else {
80-
*default_width = 640 / 2;
81-
*default_height = 480 / 2;
80+
*default_width = 640;
81+
*default_height = 480;
8282
}
8383
}
8484
}
@@ -95,15 +95,15 @@ void picodvi_autoconstruct(void) {
9595
return;
9696
}
9797

98-
mp_int_t default_width = 320;
99-
mp_int_t default_height = 240;
98+
mp_int_t default_width = 640;
99+
mp_int_t default_height = 480;
100100
if (!picodvi_autoconstruct_enabled(&default_width, &default_height)) {
101101
return;
102102
}
103103

104104
mp_int_t width = default_width;
105105
mp_int_t height = 0;
106-
mp_int_t color_depth = 16;
106+
mp_int_t color_depth = 8;
107107
mp_int_t rotation = 0;
108108

109109
(void)common_hal_os_getenv_int("CIRCUITPY_DISPLAY_WIDTH", &width);
@@ -113,6 +113,9 @@ void picodvi_autoconstruct(void) {
113113

114114
if (height == 0) {
115115
switch (width) {
116+
case 720:
117+
height = 400;
118+
break;
116119
case 640:
117120
height = 480;
118121
break;
@@ -134,7 +137,7 @@ void picodvi_autoconstruct(void) {
134137
// invalid configuration, set back to default
135138
width = default_width;
136139
height = default_height;
137-
color_depth = 16;
140+
color_depth = 8;
138141
}
139142

140143
// construct framebuffer and display

ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jpegio = false
5858
keypad = false
5959
keypad_demux = false
6060
locale = false
61+
lvfontio = false
6162
math = false
6263
max3421e = false
6364
mdns = false

0 commit comments

Comments
 (0)