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

+96
View File
@@ -0,0 +1,96 @@
Fusion Pixel Font
https://github.com/TakWolf/fusion-pixel-font
Copyright (c) 2022, TakWolf (https://takwolf.com).
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
+8
View File
@@ -40,6 +40,14 @@ static func build_battle_ui(root: Control, db) -> Dictionary:
var settlement_fx := SettlementFxView.new()
root.add_child(settlement_fx)
# CJK 字体随包(2026-09-27 用户拍板 Fusion Pixel OFL):Control 侧默认主题字体走 project.godot
# gui/theme/custom_font;SubViewport 两世界不继承 Control 主题——显式注入挂点接线(C6 挂点链)。
# 缺位守卫(load_font 返回 null = 引擎回退字体,与旧 Button 渲染同源,不炸)。
var ui_font: Font = UiKit.load_font(UiKit.FONT_UI)
if ui_font != null:
stage.set_world_font(ui_font)
board_zone.board_view.set_world_font(ui_font)
# GP/钥石余额位已随 2026-09-26 信息归属拍板退役(中/大循环资源迁出战斗屏——
# GP 去向 = 关卡画面+战斗结算画面、钥石去向 = 结算画面+营地,呈现归对应 UX spec 批次)
return {
+11
View File
@@ -106,6 +106,17 @@ static func load_tex(path: String) -> Texture2D:
return null
# CJK 随包字体(2026-09-27 用户拍板 Fusion Pixel OFL——CJK 覆盖+授权干净;命名遵 art-bible §8.3
# 全小写 snake_case 域前缀)。守卫装载同 load_tex 纪律:缺位返回 null(引擎回退字体接手,不炸)。
const FONT_UI := "res://assets/fonts/ui_font_fusion_pixel_zh_hans.ttf"
static func load_font(path: String) -> Font:
if ResourceLoader.exists(path):
var res: Resource = load(path)
return res as Font
return null
# ── StyleBox 工厂 ──
# margin = (左, 上, 右, 下);border_w = 0 即无边框(根底/遮罩用)
static func panel_flat(bg: Color, border: Color, corner: int = 0, border_w: int = 1, margin: Vector4 = Vector4.ZERO) -> StyleBoxFlat:
+4
View File
@@ -26,6 +26,10 @@ window/size/viewport_height=800
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"
[gui]
theme/custom_font="res://assets/fonts/ui_font_fusion_pixel_zh_hans.ttf"
[rendering]
renderer/rendering_method="gl_compatibility"
+1
View File
@@ -33,6 +33,7 @@ func _suites() -> Array:
{"path": "res://tests/unit/battle_settlement/damage_math_test.gd", "expect": 0},
{"path": "res://tests/unit/battle_settlement/damage_controller_test.gd", "expect": 0},
{"path": "res://tests/unit/contracts/system_contracts_test.gd", "expect": 0},
{"path": "res://tests/unit/presentation/ui_font_asset_test.gd", "expect": 0},
]
@@ -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