Skip to content

Commit

Permalink
Fix rendering of scaled emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Dec 10, 2024
1 parent bc2f25e commit 4a9ef44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions kitty/fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ensure_canvas_can_fit(FontGroup *fg, unsigned cells, unsigned scale) {
}
fg->canvas.current_cells = cells;
fg->canvas.current_scale = scale;
if (fg->canvas.buf) memset(fg->canvas.buf, 0, cs(fg->canvas.current_cells, fg->canvas.alloced_scale));
if (fg->canvas.buf) memset(fg->canvas.buf, 0, cs(cells, scale));
#undef cs
}

Expand Down Expand Up @@ -490,8 +490,7 @@ face_has_codepoint(const void* face, char_type cp) {

static bool
has_emoji_presentation(const CPUCell *c, const ListOfChars *lc) {
if (!c->is_multicell || c->x || c->y || !lc->count) return false;
return is_emoji(lc->chars[0]) && (lc->count == 1 || lc->chars[1] != VS15);
return c->is_multicell && lc->count && is_emoji(lc->chars[0]) && (lc->count == 1 || lc->chars[1] != VS15);
}

bool
Expand Down
15 changes: 9 additions & 6 deletions kitty_tests/multicell.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ def assert_cursor_at(x, y):
ac(x, 0, is_multicell=True, width=2, scale=2, subscale_n=3, x=x, y=0, text='', natural_width=False)
for x in range(0, 4):
ac(x, 1, is_multicell=True, width=2, scale=2, subscale_n=3, x=x, y=1, text='', natural_width=False)
def comb(x, y):
s.reset()
multicell(s, 'a', scale=2)
s.cursor.x, s.cursor.y = x, y
s.draw('\u0301')
assert_cursor_at(x, y)
ac(0, 0, text='a' if y else 'a\u0301', is_multicell=True)
for y in range(2):
for x in range(1, 3):
s.reset()
multicell(s, 'a', scale=2)
s.cursor.x, s.cursor.y = x, y
s.draw('\u0301')
assert_cursor_at(x, y)
ac(0, 0, text='a' if y else 'a\u0301', is_multicell=True)
comb(x, y)
comb(0, 1)

# Test wrapping
s.reset()
Expand Down

0 comments on commit 4a9ef44

Please sign in to comment.