Add Chinese text rendering support

Extend the bitmap font pipeline with the Chinese Joker glyph subset and encode supported UTF-8 text for Tonc TTE. Move the affine map clear of the expanded font, add a compile-time VRAM overlap guard, and cover every custom glyph with host tests.
This commit is contained in:
2026-07-19 11:35:14 +08:00
parent 7a5a4a1276
commit c7ef3c0047
13 changed files with 583 additions and 15 deletions
+10 -5
View File
@@ -5,7 +5,6 @@ import argparse
CHAR_WIDTH = 8
CHAR_HEIGHT = 8
NUM_VERT_CHARS = 6
NUM_HORZ_CHARS = 16
WORD_SIZE = 32
@@ -48,8 +47,14 @@ img = img.convert("P")
img = img.convert('1')
img = ImageOps.invert(img)
if img.width != NUM_HORZ_CHARS * CHAR_WIDTH or img.height % CHAR_HEIGHT != 0:
raise ValueError("font image must be 128px wide and a multiple of 8px high")
num_vert_chars = img.height // CHAR_HEIGHT
num_chars = num_vert_chars * NUM_HORZ_CHARS
glyphs = []
for char_y in range(NUM_VERT_CHARS):
for char_y in range(num_vert_chars):
for char_x in range(NUM_HORZ_CHARS):
# Get the 8x8 crop area at our current character in the image
pix_x = char_x * CHAR_WIDTH
@@ -86,7 +91,7 @@ with open(out_path, "w") as out:
.global gbalatro_sys8Font
gbalatro_sys8Font:
.word gbalatro_sys8Glyphs, 0, 0
.hword 32, 96
.hword 32, %d
.byte 8, 8
.byte 8, 8
.hword 8
@@ -94,9 +99,9 @@ gbalatro_sys8Font:
.section .rodata
.align 2
.global gbalatro_sys8Glyphs @ 768 bytes (192 unsigned ints)
.global gbalatro_sys8Glyphs
gbalatro_sys8Glyphs:
""")
""" % num_chars)
for i, glyph in enumerate(glyphs):
if first: