Skip to content

Emit glyph padding in rendered-font pixels so it follows text scale - #754

Merged
dakra merged 1 commit into
mainfrom
fix/min-width-text-scale
Oct 23, 2026
Merged

dakra merged 1 commit into
mainfrom
fix/min-width-text-scale

Conversation

@dakra

@dakra dakra commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Fixes #752.

A bare number in a min-width display spec is measured in the frame's canonical column width, which buffer face remapping (text-scale-mode, buffer-face-mode) does not change. Padded fallback glyphs therefore ended up narrower or wider than their cells whenever the buffer's text scale was not 1, shifting the text after them.

The renderer now emits the slot width in pixels of the rendered font, (min-width ((PIXELS))), the same value the glyph scale is already clamped against. The pixel form has gone through calc_pixel_width_or_height since min-width was added in Emacs 29.1, so no version guard is needed. TTY frames are unaffected because glyph adjustment only runs with a window-system font object.

Verified live in a GUI Emacs (Menlo 12) by measuring the rendered width of padded glyphs with window-text-pixel-size:

text scale cell px frame col px glyph new spec old spec bare glyph
5 18 7 ⌚ (2 cells) 36 24 24
5 18 7 ⟷ (1 cell) 18 14 14
2 10 7 ⌚ (2 cells) 20 15 15
-1 6 7 ⟷ (1 cell) 6 7 4
-3 4 7 ⌚ (2 cells) 8 14 5

The old spec under-pads above scale 1 and over-pads below it; the new spec fills the slot at every scale.

Tests: existing glyph assertions now expect the pixel form, plus a new test that renders with a remapped default font twice as wide and asserts the padding follows it.

A bare number in a min-width display spec is measured in the frame's
canonical column width, which buffer face remapping (text-scale-mode,
buffer-face-mode) does not change.  Padded fallback glyphs therefore
ended up narrower or wider than their cells whenever the buffer's text
scale was not 1, shifting the text after them.

Emit the slot width in pixels of the rendered font instead, the same
value the glyph scale is already clamped against.

Closes #752.
@dakra
dakra merged commit 706be5d into main Oct 23, 2026
33 checks passed
@dakra
dakra deleted the fix/min-width-text-scale branch October 23, 2026 06:01

This branch was previously deployed

1 inactive deployment
github-pages — 706be5d8 Deployed Oct 23, 2026 by dakra via deploy #228
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.

min-width glyph padding ignores buffer text scale

1 participant