Skip to content

Latest commit

 

History

History
70 lines (58 loc) · 3.38 KB

File metadata and controls

70 lines (58 loc) · 3.38 KB

[1166] 文本模式字符的逻辑字体与物理字体集成测试

1 任务描述

为文本模式的字符新增集成测试:给定 Unicode 码位范围(首段 0–255,后续逐步扩大), 钉死每个字符在文本模式下解析到的逻辑字体与物理字体,并能识别出无法渲染 (落到 error 字体)的字符。

2 任务相关的代码文件

新增

  • 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

3 设计说明

  • 逻辑字体:由当前环境变量给出(font / font-family / font-series / font-shape),scheme 侧用现有 get-env 读取,无需新 bridge。
  • 物理字体:逻辑字体经 find_font / smart font 按字符覆盖度解析出的实际 字体(如 ec:ecrm10@600unicode:NotoSerif-Regular10@600)。字符无字体 覆盖时落到 error 字体,res_nameerror- 开头。
  • bridge 复用 print_snippet 的临时文档排版路径(new_document + typeset_as_box + get_leaf_font),量的是真实排版结果而非内部缓存。
  • 测试以码位区间参数化,期望表按区间分段维护,便于后续逐步扩大覆盖范围。

4 如何测试

xmake b stem
xmake r 1166                     # headless 冒烟
MOGAN_TEST_GUI=1 xmake r 1166    # 真实 GUI,执行断言链

5 改动记录

2026-08-04

  • What:新增文本模式字符字体解析集成测试(码位 0–255),及配套 physical-font-for-string bridge。
  • 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_subfontsmart_font_repadvance 解析到实际 子字体)得到物理字体 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.cppget_subfont 默认实现)
    • src/Graphics/Fonts/smart_font.hpp / smart_font.cppget_subfont 覆写)
    • src/Scheme/Glue/glue_editor.lua(scheme 绑定)
    • TeXmacs/tests/1166.scm(集成测试,headless/GUI 均同步执行断言)
  • 验证xmake r 1166MOGAN_TEST_GUI=1 xmake r 1166 均 262 correct / 0 failed。