feat(ui): T3 CJK 字体随包落码——Fusion Pixel OFL zh_hans 入包接线(2026-09-27 用户拍板)

- 资产: game/assets/fonts/ui_font_fusion_pixel_zh_hans.ttf + OFL-fusion-pixel.txt 授权随包(授权干净定案);命名遵 art-bible §8.3 snake_case 域前缀
- project.godot gui/theme/custom_font=全 Control 默认主题字体单点
- SubViewport 两世界不继承 Control 主题: ui_assembler 装配点经 UiKit.load_font 守卫装载注入 set_world_font(C6 挂点链首次接线,缺位=null 回退引擎字体不炸)
- 单元断言: tests/unit/presentation/ui_font_asset_test.gd(装载非空/中文字形 has_char/采样宽度>0)入 run_all manifest(8 套件)
- 轻闸: 冒烟 557/0+ui_probe(hp='攻击 2 ' 中文渲染断言不减)+ui_input_probe+ui_click_probe 全绿
This commit is contained in:
DKChan committed 2026-09-28 03:13:54 +08:00
1 parent 7c9320b98e
commit a0ed48fa88
8 files changed
+165

No files matched your search

@@ -0,0 +1,44 @@
# tests/unit/presentation/ui_font_asset_test.gd — CJK 随包字体资产契约测试(T3 字体卡)
# 运行:godot --headless --path game --script res://tests/unit/presentation/ui_font_asset_test.gd
# 契约源:2026-09-27 用户拍板 Fusion Pixel OFL(CJK 覆盖+授权干净)+ battle.md C6 headless 判据
#(注入字体非空 + 中文字形 has_char + 采样文本宽度 > 0——实际光栅观感归真人目检)。
# 路径常量从 UiKit 单点读取(字体路径改动 = 断言随动,禁测试侧复制字面量路径)。
# 前置:fresh checkout 需先 --editor --quit 刷导入缓存(.ttf 经导入管线成 FontFile——全素材同纪律)。
extends SceneTree
const UiKitScript := preload("res://presentation/views/ui_kit.gd")
var _failures := 0
var _checks := 0
func _init() -> void:
var path: String = UiKitScript.FONT_UI
var f: Font = UiKitScript.load_font(path)
_check("随包字体守卫装载非空(res://assets/fonts/ui_font_fusion_pixel_zh_hans.ttf)", f != null)
if f != null:
_check("中文字形在集(攻/雷/旗/封)", f.has_char("攻".unicode_at(0)) and f.has_char("雷".unicode_at(0)) \
and f.has_char("旗".unicode_at(0)) and f.has_char("封".unicode_at(0)))
_check("ASCII/数字字形在集(A/0/%)", f.has_char("A".unicode_at(0)) and f.has_char("0".unicode_at(0)) and f.has_char("%".unicode_at(0)))
var sz := 18
var w_cn: float = f.get_string_size("战斗胜利", HORIZONTAL_ALIGNMENT_LEFT, -1, sz).x
var w_label: float = f.get_string_size("攻击 2", HORIZONTAL_ALIGNMENT_LEFT, -1, sz).x
_check("中文采样文本宽度 > 0(C6 headless 判据)", w_cn > 0.0 and w_label > 0.0)
# 注:不设「私用区 has_char=false」负探针——fusion pixel 实测覆盖 PUA 码位,负向覆盖非契约面(宁缺勿错)
else:
_check("字体缺失时后续断言跳过(缺位=回归,此行仅占位计数)", false)
if _failures > 0:
push_error("[ui_font_asset_test] %d/%d 项失败" % [_failures, _checks])
quit(1)
return
print("[ui_font_asset_test] all green (%d checks)" % _checks)
quit(0)
func _check(desc: String, ok: bool) -> void:
_checks += 1
if ok:
print(" [PASS] " + desc)
else:
_failures += 1
push_error(" [FAIL] " + desc)
@@ -0,0 +1 @@
uid://dtfch2gldub31