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
+21
View File
@@ -0,0 +1,21 @@
/**
* @file chinese_text.h
* @brief UTF-8 conversion helpers for the extended TTE font.
*/
#ifndef CHINESE_TEXT_H
#define CHINESE_TEXT_H
#include <stddef.h>
/**
* @brief Map supported UTF-8 Chinese text to valid UTF-8 sequences for custom TTE glyphs.
*
* ASCII bytes, including TTE formatting tags, are copied unchanged. Unsupported Unicode
* characters are replaced with '?'. Custom glyph IDs are emitted as UTF-8 because Tonc TTE
* decodes every byte above 0x7F as part of a UTF-8 sequence.
*
* @return Number of encoded bytes, excluding the null terminator.
*/
size_t chinese_text_encode(const char* utf8, char* output, size_t output_size);
#endif // CHINESE_TEXT_H
+124
View File
@@ -0,0 +1,124 @@
// Ordered glyphs appended after ASCII code point 127 in gbalatro_sys8.png.
CHINESE_GLYPH(0x5C0F) // 小
CHINESE_GLYPH(0x4E11) // 丑
CHINESE_GLYPH(0x724C) // 牌
CHINESE_GLYPH(0x6C49) // 汉
CHINESE_GLYPH(0x5316) // 化
CHINESE_GLYPH(0x9884) // 预
CHINESE_GLYPH(0x89C8) // 览
CHINESE_GLYPH(0x534A) // 半
CHINESE_GLYPH(0x5F20) // 张
CHINESE_GLYPH(0x6050) // 恐
CHINESE_GLYPH(0x6016) // 怖
CHINESE_GLYPH(0x9762) // 面
CHINESE_GLYPH(0x5B54) // 孔
CHINESE_GLYPH(0x5982) // 如
CHINESE_GLYPH(0x679C) // 果
CHINESE_GLYPH(0x51FA) // 出
CHINESE_GLYPH(0x4E0D) // 不
CHINESE_GLYPH(0x8D85) // 超
CHINESE_GLYPH(0x8FC7) // 过
CHINESE_GLYPH(0x6253) // 打
CHINESE_GLYPH(0x7684) // 的
CHINESE_GLYPH(0x4EBA) // 人
CHINESE_GLYPH(0x5934) // 头
CHINESE_GLYPH(0x8BA1) // 计
CHINESE_GLYPH(0x5206) // 分
CHINESE_GLYPH(0x65F6) // 时
CHINESE_GLYPH(0x7ED9) // 给
CHINESE_GLYPH(0x4E88) // 予
CHINESE_GLYPH(0x500D) // 倍
CHINESE_GLYPH(0x7387) // 率
CHINESE_GLYPH(0x7B79) // 筹
CHINESE_GLYPH(0x7801) // 码
CHINESE_GLYPH(0x5DE6) // 左
CHINESE_GLYPH(0x53F3) // 右
CHINESE_GLYPH(0x5207) // 切
CHINESE_GLYPH(0x6362) // 换
CHINESE_GLYPH(0x52A8) // 动
CHINESE_GLYPH(0x753B) // 画
CHINESE_GLYPH(0x4E3B) // 主
CHINESE_GLYPH(0x83DC) // 菜
CHINESE_GLYPH(0x5355) // 单
CHINESE_GLYPH(0x4E00) // 一
CHINESE_GLYPH(0x4E09) // 三
CHINESE_GLYPH(0x4E0B) // 下
CHINESE_GLYPH(0x4E24) // 两
CHINESE_GLYPH(0x4E2A) // 个
CHINESE_GLYPH(0x4E2D) // 中
CHINESE_GLYPH(0x4E3A) // 为
CHINESE_GLYPH(0x4E8E) // 于
CHINESE_GLYPH(0x4F4D) // 位
CHINESE_GLYPH(0x4F4E) // 低
CHINESE_GLYPH(0x4F59) // 余
CHINESE_GLYPH(0x4F8B) // 例
CHINESE_GLYPH(0x4FA7) // 侧
CHINESE_GLYPH(0x5076) // 偶
CHINESE_GLYPH(0x518D) // 再
CHINESE_GLYPH(0x51E0) // 几
CHINESE_GLYPH(0x5230) // 到
CHINESE_GLYPH(0x5236) // 制
CHINESE_GLYPH(0x524D) // 前
CHINESE_GLYPH(0x5269) // 剩
CHINESE_GLYPH(0x529B) // 力
CHINESE_GLYPH(0x52A0) // 加
CHINESE_GLYPH(0x5305) // 包
CHINESE_GLYPH(0x53D1) // 发
CHINESE_GLYPH(0x53EF) // 可
CHINESE_GLYPH(0x5408) // 合
CHINESE_GLYPH(0x540C) // 同
CHINESE_GLYPH(0x540E) // 后
CHINESE_GLYPH(0x542B) // 含
CHINESE_GLYPH(0x548C) // 和
CHINESE_GLYPH(0x56DB) // 四
CHINESE_GLYPH(0x56DE) // 回
CHINESE_GLYPH(0x5747) // 均
CHINESE_GLYPH(0x590D) // 复
CHINESE_GLYPH(0x5916) // 外
CHINESE_GLYPH(0x5947) // 奇
CHINESE_GLYPH(0x5B50) // 子
CHINESE_GLYPH(0x5BF9) // 对
CHINESE_GLYPH(0x5C06) // 将
CHINESE_GLYPH(0x5F03) // 弃
CHINESE_GLYPH(0x5F53) // 当
CHINESE_GLYPH(0x6210) // 成
CHINESE_GLYPH(0x6216) // 或
CHINESE_GLYPH(0x6240) // 所
CHINESE_GLYPH(0x624B) // 手
CHINESE_GLYPH(0x62E5) // 拥
CHINESE_GLYPH(0x62EC) // 括
CHINESE_GLYPH(0x63A5) // 接
CHINESE_GLYPH(0x6570) // 数
CHINESE_GLYPH(0x65B9) // 方
CHINESE_GLYPH(0x65E0) // 无
CHINESE_GLYPH(0x6700) // 最
CHINESE_GLYPH(0x6709) // 有
CHINESE_GLYPH(0x672C) // 本
CHINESE_GLYPH(0x673A) // 机
CHINESE_GLYPH(0x6761) // 条
CHINESE_GLYPH(0x6765) // 来
CHINESE_GLYPH(0x6843) // 桃
CHINESE_GLYPH(0x6885) // 梅
CHINESE_GLYPH(0x69FD) // 槽
CHINESE_GLYPH(0x6B21) // 次
CHINESE_GLYPH(0x6BCF) // 每
CHINESE_GLYPH(0x70B9) // 点
CHINESE_GLYPH(0x7247) // 片
CHINESE_GLYPH(0x7528) // 用
CHINESE_GLYPH(0x7531) // 由
CHINESE_GLYPH(0x7A7A) // 空
CHINESE_GLYPH(0x7B2C) // 第
CHINESE_GLYPH(0x7EA2) // 红
CHINESE_GLYPH(0x7EC4) // 组
CHINESE_GLYPH(0x80FD) // 能
CHINESE_GLYPH(0x8272) // 色
CHINESE_GLYPH(0x82B1) // 花
CHINESE_GLYPH(0x89C6) // 视
CHINESE_GLYPH(0x89E6) // 触
CHINESE_GLYPH(0x95F4) // 间
CHINESE_GLYPH(0x968F) // 随
CHINESE_GLYPH(0x9694) // 隔
CHINESE_GLYPH(0x987A) // 顺
CHINESE_GLYPH(0x989D) // 额
CHINESE_GLYPH(0x9ED1) // 黑
CHINESE_GLYPH(0x3001) // 、
+9 -9
View File
@@ -1,9 +1,9 @@
#ifndef GBALATRO_SYS8_FONT_H
#define GBALATRO_SYS8_FONT_H
#include <tonc.h>
extern const TFont gbalatro_sys8Font;
extern const unsigned int gbalatro_sys8Glyphs[192];
#endif
#ifndef GBALATRO_SYS8_H
#define GBALATRO_SYS8_H
#include <tonc.h>
extern const TFont gbalatro_sys8Font;
extern const unsigned int gbalatro_sys8Glyphs[];
#endif
+1 -1
View File
@@ -32,7 +32,7 @@
#define MAIN_BG_CBB 1
#define TTE_SBB 30
#define TTE_CBB 0
#define AFFINE_BG_SBB 2
#define AFFINE_BG_SBB 4
#define AFFINE_BG_CBB 2
#define PAL_ROW_LEN 16
#define NUM_PALETTES 16