为文本模式的字符新增集成测试:给定 Unicode 码位范围(首段 0–255,后续逐步扩大), 钉死每个字符在文本模式下解析到的逻辑字体与物理字体,并能识别出无法渲染 (落到 error 字体)的字符。
TeXmacs/tests/1166.scm— GUI 集成测试(xmake r 1166)devel/1166.md— 本文档
src/Edit/Editor/edit_typeset.hpp/edit_typeset.cpp— 新增physical_font_for_string:在当前文档环境(文本模式)下排版给定字符串, 返回叶子物理字体的res_name(无法渲染时为error-前缀)src/Scheme/Glue/glue_editor.lua— 注册 scheme 绑定physical-font-for-string
- 逻辑字体:由当前环境变量给出(
font/font-family/font-series/font-shape),scheme 侧用现有get-env读取,无需新 bridge。 - 物理字体:逻辑字体经
find_font/ smart font 按字符覆盖度解析出的实际 字体(如ec:ecrm10@600、unicode:NotoSerif-Regular10@600)。字符无字体 覆盖时落到 error 字体,res_name以error-开头。 - bridge 复用
print_snippet的临时文档排版路径(new_document+typeset_as_box+get_leaf_font),量的是真实排版结果而非内部缓存。 - 测试以码位区间参数化,期望表按区间分段维护,便于后续逐步扩大覆盖范围。
xmake b stem
xmake r 1166 # headless 冒烟
MOGAN_TEST_GUI=1 xmake r 1166 # 真实 GUI,执行断言链- What:新增文本模式字符字体解析集成测试(码位 0–255),及配套
physical-font-for-stringbridge。 - Why:钉死逻辑字体→物理字体的解析契约,识别无字体覆盖落到 error 字体的字符,为后续扩大 Unicode 覆盖范围提供回归基线。
- How:
edit_typeset_rep::physical_font_for_string复用print_snippet的 临时文档排版路径(new_document+typeset_as_box),递归下钻到 TEXT_BOX 叶子取字体;叶子挂的是 smart font,再经新增的虚函数font_rep::get_subfont(smart_font_rep用advance解析到实际 子字体)得到物理字体res_name;无覆盖时经 SUBFONT_ERROR 得到error-前缀名。editor_rep新增纯虚physical_font_for_string(glue 经get_current_editor()->调用,走 editor_rep 虚表)。- 测试数据:0–255 中 200 码位 →
ec:ecrm10@600,55 码位 →unicode:cmunrm10@600(128–160 及部分 Latin-1 符号),181 (µ) →gr:grmn1000@600;三类字体均随仓库分发,跨机器稳定。
- 涉及文件:
src/Edit/Editor/edit_typeset.hpp/edit_typeset.cpp(bridge +find_leaf_font辅助)src/Edit/editor.hpp(纯虚声明)src/Graphics/Fonts/font.hpp/font.cpp(get_subfont默认实现)src/Graphics/Fonts/smart_font.hpp/smart_font.cpp(get_subfont覆写)src/Scheme/Glue/glue_editor.lua(scheme 绑定)TeXmacs/tests/1166.scm(集成测试,headless/GUI 均同步执行断言)
- 验证:
xmake r 1166与MOGAN_TEST_GUI=1 xmake r 1166均 262 correct / 0 failed。