Skip to content

Fix pixel-grid misalignment caused by shared vertex insetting#5

Open
Aerhhh wants to merge 1 commit intominecraft-library:masterfrom
Aerhhh:fix/remove-vertex-inset
Open

Fix pixel-grid misalignment caused by shared vertex insetting#5
Aerhhh wants to merge 1 commit intominecraft-library:masterfrom
Aerhhh:fix/remove-vertex-inset

Conversation

@Aerhhh
Copy link
Copy Markdown
Contributor

@Aerhhh Aerhhh commented Apr 15, 2026

Summary

  • Removes _inset_shared_vertices which nudged shared contour vertices by 1 font unit off the pixel grid
  • Restores all glyph coordinates to exact multiples of 128 font units (1 Minecraft pixel at UPM 1024 / 8ppem)

Problem

_inset_shared_vertices was introduced to suppress a FontForge wrong-direction false positive on glyphs where outer and hole contours share a vertex. It shifts those vertices by 1 font unit along the bisector of adjacent edges.

This moves outline coordinates off the pixel grid - for example (127, 769) instead of (128, 768). When font rasterizers (FreeType on Linux, Java2D, etc.) encounter these off-grid coordinates, they make different rounding decisions depending on the platform, producing inconsistent rendering artifacts on characters with multiple contours (A, M, H, S, K, and many others).

Before (off-grid coordinates for 'A'):

moveTo (127, 769)  -- should be (128, 768)
lineTo (513, 769)  -- should be (512, 768)
moveTo (129, 768)  -- should be (128, 768)
lineTo (511, 768)  -- should be (512, 768)

After (grid-aligned):

moveTo (128, 768)
lineTo (512, 768)
moveTo (128, 768)
lineTo (512, 768)

Rendering comparison (Python/Pillow at 16px)

Before - 'A' has asymmetric strokes:

.#######......
.########.....
###....###....
##.....###....

After - clean 2x pixel grid:

..######......
..######......
##......##....
##......##....

_inset_shared_vertices nudged shared contour vertices by 1 font unit
along the bisector of adjacent edges to suppress a FontForge
wrong-direction false positive. This moved outline coordinates off the
pixel grid (e.g. (127, 769) instead of (128, 768)), causing font
rasterizers (FreeType, Java2D) to produce platform-dependent rendering
artifacts on characters with multiple contours (A, M, H, S, K, etc.).

Removing the function restores all glyph coordinates to exact multiples
of 128 font units (1 Minecraft pixel at UPM 1024 / 8ppem), producing
clean pixel-perfect rendering at all integer multiples of the native
design size.
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