Skip to content

fix(domain): natural_size 对 CJK 宽字符按整 em 计宽——修混排文本截字#208

Merged
appergb merged 1 commit into
betafrom
fix/195-cjk-advance
Jul 6, 2026
Merged

fix(domain): natural_size 对 CJK 宽字符按整 em 计宽——修混排文本截字#208
appergb merged 1 commit into
betafrom
fix/195-cjk-advance

Conversation

@appergb

@appergb appergb commented Jul 6, 2026

Copy link
Copy Markdown
Owner

真机复现(#195 auto-fit 合入后的终验中发现)

add_texts 内容 "终验 FINAL CHECK"(fontSize 80)→ 渲染只出 "终验 FINAL","CHECK" 丢失。

根因

auto-fit box 紧贴 TextLayout::natural_size 的估算宽,而该估算把所有字符按拉丁 0.6 系数计宽;CJK 字形实际 ~1.0em。混排行估算偏窄 → cosmic-text 实际排版超出 box 宽 → 尾部换行到第二行 → 单行高的 box 把第二行裁掉。

修复

per-char advance:East Asian Wide/Fullwidth 区段(CJK 表意/假名/谚文/全角标点)按 1.0em,其余保持 0.6。偏宽是安全方向——box 略宽只是留白居中,偏窄则截字。

测试

  • wide_chars_measure_a_full_em(纯 CJK = n×em;纯拉丁不变)
  • mixed_cjk_latin_line_width_covers_both_scripts(混排宽 > 旧均一估算)
  • workspace 全测试绿、clippy -D warnings 零告警

真机终验:同一文本重渲后完整显示(见 issue 线程)。

Fixes #195(度量补全)

…ze (#195)

The auto-fit text box hugged natural_size's estimate, which priced every
char at the Latin 0.6 factor. CJK glyphs rasterize at ~1.0em, so a mixed
CJK/Latin line measured narrower than cosmic-text lays it out; the
rasterizer wrapped the overflow onto a second line and the single-line-tall
box clipped it (on-device: '终验 FINAL CHECK' rendered without 'CHECK').
Per-char advance now prices wide ranges (CJK ideographs, kana, hangul,
fullwidth forms) at 1.0em — erring wide is safe: a roomy box renders
centered, a tight one truncates.
@appergb appergb merged commit 6ce7aaf into beta Jul 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant