Skip to content

fix emoji glyph placement on the terminal grid#1564

Open
shiena wants to merge 1 commit into
raphamorim:mainfrom
shiena:fix-emoji-centering
Open

fix emoji glyph placement on the terminal grid#1564
shiena wants to merge 1 commit into
raphamorim:mainfrom
shiena:fix-emoji-centering

Conversation

@shiena
Copy link
Copy Markdown
Contributor

@shiena shiena commented Apr 27, 2026

Fixed #1563

  • grid_emit::ensure_glyph_by_id now rasterizes color-emoji glyphs at a cell-derived size (min(2*cell_w, cell_h)) and centers the bitmap inside the 2-cell slot, instead of using the text point size and the primary font's baseline math (which mixes coordinate systems with the emoji font's own bbox).
  • find_best_font_match{,_strict} now inherits is_emoji from the mapped font's color-table flag instead of hardcoding false, so config-pinned emoji families (e.g. Segoe UI Emoji via [[fonts.symbol-map]]) reach the emoji rendering path.

The atlas is bucketed by the cell-derived size, so emoji glyphs cache the same way they always did and the per-frame hot path is unchanged.
Only the first rasterization of each emoji is marginally larger.

スクリーンショット 2026-04-27 094728

@shiena shiena force-pushed the fix-emoji-centering branch 12 times, most recently from f8f53e2 to 7479f7c Compare May 3, 2026 08:25
Emoji rendered slightly upper-right of its 2-cell slot because
`grid_emit::ensure_glyph_by_id` rasterized at the text point size and
placed the bitmap on the primary font's baseline (`cell_h - ascent +
top`), using bearings from the emoji font's own coordinate system. The
two metric systems don't compose, so the offset was unavoidable for
any non-trivial emoji font.

Also fixes a related bug in `find_best_font_match{,_strict}`: the
symbol-map fast path hardcoded `is_emoji = false`, so config-pinned
emoji families (e.g. `Segoe UI Emoji` via `[fonts.symbol-map]`)
bypassed the emoji rasterization path entirely. Now inherits
`is_emoji` from the mapped font's color-table detection.

For emoji `ensure_glyph_by_id` now:
- rasterizes at `min(2*cell_w, cell_h)` so the bitmap fills its 2-cell
  slot regardless of the text font size,
- buckets the atlas key by that cell-derived size so it doesn't alias
  text rasterizations during resize,
- centers the bitmap horizontally in `2*cell_w` and vertically in
  `cell_h` (matches the symbol-centering rationale in changelog 42 for
  PUA constraint glyphs).

Hot path is unchanged — atlas lookups still hit on the first call per
emoji glyph and stay cached.
@shiena shiena force-pushed the fix-emoji-centering branch from 7479f7c to d3b5729 Compare May 4, 2026 03:02
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.

Emoji glyphs render off-center in their 2-cell grid slot

1 participant