Skip to content

Fixed glyph positions flipping by one pixel when atlas slot assignments changed.#1508

Merged
shlzxjp merged 3 commits into
mainfrom
bugfix/hparty_glyph_align
Jul 22, 2026
Merged

Fixed glyph positions flipping by one pixel when atlas slot assignments changed.#1508
shlzxjp merged 3 commits into
mainfrom
bugfix/hparty_glyph_align

Conversation

@Hparty

@Hparty Hparty commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

问题:字形图集渲染的像素对齐直接对平移分量做 std::round。平移量 = 真实设备位置 - 图集槽位坐标,当真实位置为半整数时,std::round 半值远离零的特性会使取整方向随槽位正负翻转,导致同一个字形仅因被分配到图集不同槽位(取决于渲染历史)而偏移 1px。

修改:ComputeGlyphRenderMatrix 改为先对槽位无关的设备锚点坐标(matrix * atlasLocation)取整,再减去精确的矩阵线性项回写到平移分量,渲染时与矩阵自身的缩放项精确抵消,锚点精确落在整数像素上。非复杂分支的 y 方向同样消除了对 atlasLocation.y 的取整依赖,并保留整行共享基线加逐字形偏移分别取整的原有设计;复杂与非复杂两个分支的数学形式已统一。

基准:6 个截图测试的基准版本已在 version.json 中更新(TextAlignTest x3、TextRenderTest、LayerTest、VectorLayerTest)。

@shlzxjp
shlzxjp merged commit 8d2e61f into main Jul 22, 2026
14 checks passed
@shlzxjp
shlzxjp deleted the bugfix/hparty_glyph_align branch July 22, 2026 06:08
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.

2 participants