[PR #13833] AtlasEngine: Round cell sizes to nearest instead of up #29781

Open
opened 2026-01-31 09:36:51 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/13833

State: closed
Merged: Yes


After some deliberation I noticed that rounding the glyph advance up to yield
the cell width is at least just as wrong as rounding it. This is because
we draw glyphs centered, meaning that (at least in theory) anti-aliased
pixels might clip outside of the layout box on both sides of the glyph
adding not 1 but 2 extra pixels to the glyph size. Instead of just ceilf
we would have had to use ceilf(advanceWidth / 2) * 2 to account for that.

This commit simplifies our issue by just going with what other applications do:
Round all sizes (cell width and height) to the nearest pixel size.

Closes #13812

Validation Steps Performed

  • Set a breakpoint on scaling Required == true in AtlasEngine::_drawGlyph
  • Test an assortment of Cascadia Mono, Consolas, MS Gothic, Lucida Console
    at various font sizes (6, 7, 8, 10, 12, 24, ...)
  • Ensure breakpoint isn't hit ✅
    This tells us that no glyph resizing was necessary
**Original Pull Request:** https://github.com/microsoft/terminal/pull/13833 **State:** closed **Merged:** Yes --- After some deliberation I noticed that rounding the glyph advance up to yield the cell width is at least just as wrong as rounding it. This is because we draw glyphs centered, meaning that (at least in theory) anti-aliased pixels might clip outside of the layout box on _both_ sides of the glyph adding not 1 but 2 extra pixels to the glyph size. Instead of just `ceilf` we would have had to use `ceilf(advanceWidth / 2) * 2` to account for that. This commit simplifies our issue by just going with what other applications do: Round all sizes (cell width and height) to the nearest pixel size. Closes #13812 ## Validation Steps Performed * Set a breakpoint on `scaling Required == true` in `AtlasEngine::_drawGlyph` * Test an assortment of Cascadia Mono, Consolas, MS Gothic, Lucida Console at various font sizes (6, 7, 8, 10, 12, 24, ...) * Ensure breakpoint isn't hit ✅ This tells us that no glyph resizing was necessary
claunia added the pull-request label 2026-01-31 09:36:51 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29781