fix emoji glyph placement on the terminal grid#1564
Open
shiena wants to merge 1 commit into
Open
Conversation
f8f53e2 to
7479f7c
Compare
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.
7479f7c to
d3b5729
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed #1563
grid_emit::ensure_glyph_by_idnow 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 inheritsis_emojifrom the mapped font's color-table flag instead of hardcodingfalse, so config-pinned emoji families (e.g.Segoe UI Emojivia[[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.