[0111] 修复 TFM 字体 get_xpositions 字距计算错误#3334
Merged
Merged
Conversation
修复中文文档中连续多个 "I" 字符导致光标位置偏左的问题。 具体修复: 1. load_tfm.cpp: 修正 lig/kern 程序中 skip_byte 与 next_char 的检查顺序, 确保与 execute 函数一致 2. load_tfm.cpp: 修正 kerning 分支中 xpos 的存储逻辑,将字距从当前字符 的结束位置中分离,使 xpos[l] 与 get_extents(prefix(0,l)) 保持一致 3. smart_font_test.cpp: 新增 test_cursor_position_iii 单元测试 4. 清理注释掉的调试输出 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
yinyuscloor
approved these changes
May 13, 2026
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.
修复内容
修复中文文档中连续多个英文字母 "I" 导致光标位置偏左的问题。
根因
ec:ecrm10@600(European Computer Modern)字体对 "I"+"I" 存在字距调整(kerning)。tex_font_metric_rep::get_xpositions有两处错误:skip_byte >= 128再检查next_char匹配,导致 valid kerning 指令被跳过ADVANCE(kern)将字距加到了当前字符的结束位置,导致xpos[l]与get_extents(prefix(0,l))不一致修改
src/Plugins/Metafont/load_tfm.cpp:修正检查顺序,将字距从当前字符的 xpos 中分离tests/Graphics/Fonts/smart_font_test.cpp:新增test_cursor_position_iii测试测试
结果:9 passed, 0 failed。
🤖 Generated with Claude Code