[ui] Linux egui 未剥离 fc-match 可变字体集合的高 16 位实例索引导致启动崩溃
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start in openless-all/app/linux-egui/src/ui/theme.rs, especially fontconfig_match() and the handling of %{index} before it reaches egui::FontData. Check how the parsed index is used for seen deduplication and the regular_face / medium_face comparison, then look for the linux-egui unit tests. Done means composite indices such as 262146 are normalized consistently and a regression test verifies the font-loading path no longer panics.
由索引模型根据 Issue 内容生成。
描述
现象
- 触发条件:在预装 Google Noto Sans CJK 可变字体集合(
NotoSansCJK-VF.ttc,如 Fedora 44 等现代 Linux 发行版默认配置)的系统上安装并启动OpenLess-Linux-egui-2.0.2-Beta.4-150-x86_64.rpm(标签v2.0.2-Beta.4-tauri,上游beta提交c002b56c38d81bcd5044ddb22597a4e78ff2a88d)。 - 当前表现:主进程拉起 UI 窗口子进程后,UI 子进程在解析
"openless-cjk"字体时触发epaintpanic(退出码101),窗口无法打开并导致宿主进程退出。 - 证据:
- 真机运行日志(Fedora 44 KDE Plasma Wayland):
openless[218836]: [INFO] openless_linux_egui::linux_app::window: [ui-host] spawned UI window process pid=218858 socket=/run/user/1000/openless-ui.sock openless[218858]: thread 'main' (218858) panicked at epaint-0.37.0/src/text/family.rs:51:21: openless[218858]: Error parsing "openless-cjk" TTF/OTF font file: Invalid index 262146 for font collection openless[218836]: [ERROR] openless_linux_egui::linux_app: OpenLess host failed: UI window process failed: exit status: 101 - 本机
fc-match实测输出:
在 Fontconfig / FreeType 中,针对可变字体集合(Variable Font TTC),$ fc-match -f "%{file}|%{index}\n" ":lang=zh-cn" /usr/share/fonts/google-noto-sans-cjk-vf-fonts/NotoSansCJK-VF.ttc|262146FC_INDEX(%{index})采用高 16 位存放命名可变实例索引(Named Instance Index)、低 16 位存放 TTC 字面索引(Face Index):262146 == 0x00040002 == (4 << 16) | 2(即第 4 号可变实例、TTC 内第 2 号字面 Noto Sans CJK SC)。 - 源码定位:
https://github.com/Open-Less/openless/blob/c002b56c38d81bcd5044ddb22597a4e78ff2a88d/openless-all/app/linux-egui/src/ui/theme.rs#L88-L100
fontconfig_match()将%{index}原样解析为u32(262146)并直接传入egui::FontData { index, .. },而epaint/ab_glyph/ttf-parser仅接受 TTC 集合内的 16 位字面索引(index & 0xFFFF),传入含高 16 位实例号的复合值会直接越界 panic。
- 真机运行日志(Fedora 44 KDE Plasma Wayland):
影响
- 所有默认使用
NotoSansCJK-VF.ttc(或任何其他可变字体集合.ttc)的 Linux 发行版(如 Fedora 等)用户,启动 OpenLess 时 UI 进程必定 100% 崩溃退出,应用完全无法打开。
建议接受标准
-
openless-all/app/linux-egui/src/ui/theme.rs在解析fc-match返回的%{index}时剥离高 16 位可变字体实例索引(例如使用index & 0xFFFF提取 TTC face index),不再将0x00040002(262146)等复合值原样传给egui::FontData。 - 对
seen去重与regular_face/medium_face比较逻辑同步使用规范化后的 TTC face index(或明确处理可变字体同一 face index 下的去重语义)。 - 在
linux-egui单元测试中增加针对fc-match返回复合FC_INDEX(如262146/0x00040002)的解析与字体加载回归测试,确保不再触发epaint越界 panic。
TODO / 不确定项
egui当前不支持可变字体字重轴(源码注释已说明),当regular_face与medium_face指向同一可变.ttc文件的同一 face index(仅高 16 位实例索引不同)时,剥离高 16 位后两者(path, index)相同,将按既有设计跳过重复注册MEDIUM_FACE。
- 主要语言
- Rust
- 星标
- 3.7k
- 派生
- 349
- 平均合并
- 1 天 13 小时
- 30 天内合并 PR
- 98
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Open-Less/openless 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
[windows] 录音快捷键还不支持设置为ScrllLock键可能已有人在做 @HKLHaoBin 于 14 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 75/100
Open-Less/openless#1241 · 5 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
area:ui bug P2
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
查看 Open-Less/openless 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
RustCrypto/utils#1597 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
max-sixty/worktrunk#4727 · 7 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复
-
follow-up
难度 2/5 1-3 小时 新手友好度 73/100
carrick-sh/carrick#1859 ·
维护者通常 1 天内回复