fix(domain): natural_size 对 CJK 宽字符按整 em 计宽——修混排文本截字#208
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
真机复现(#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(混排宽 > 旧均一估算)真机终验:同一文本重渲后完整显示(见 issue 线程)。
Fixes #195(度量补全)