From 734c3199f03b573c601d8826f8d14b61c11565cf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 15 Feb 2020 21:55:17 +0530 Subject: [PATCH] Fix rendering of combining characters with fonts that have glyphs for precomposed characters but not decomposed versions Fix #2365 --- docs/changelog.rst | 3 +++ kitty/fonts.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 0c884a9a8..780497d92 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -33,6 +33,9 @@ To update |kitty|, :doc:`follow the instructions `. - macOS: Fix menubar title not updating on OS Window focus change (:iss:`2350`) +- Fix rendering of combining characters with fonts that have glyphs for + precomposed characters but not decomposed versions (:iss:`2365`) + 0.16.0 [2020-01-28] -------------------- diff --git a/kitty/fonts.c b/kitty/fonts.c index 5609e131c..7bc7b91a7 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -474,10 +474,21 @@ has_emoji_presentation(CPUCell *cpu_cell, GPUCell *gpu_cell) { static inline bool has_cell_text(Font *self, CPUCell *cell) { if (!face_has_codepoint(self->face, cell->ch)) return false; + char_type combining_chars[arraysz(cell->cc_idx)]; + unsigned num_cc = 0; for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) { - combining_type cc_idx = cell->cc_idx[i]; - if (cc_idx == VS15 || cc_idx == VS16) continue; - if (!face_has_codepoint(self->face, codepoint_for_mark(cc_idx))) return false; + if (cell->cc_idx[i] == VS15 || cell->cc_idx[i] == VS16) continue; + combining_chars[num_cc++] = codepoint_for_mark(cell->cc_idx[i]); + } + if (num_cc == 0) return true; + if (num_cc == 1) { + if (face_has_codepoint(self->face, combining_chars[0])) return true; + char_type ch = 0; + if (hb_unicode_compose(hb_unicode_funcs_get_default(), ch, combining_chars[0], &ch) && face_has_codepoint(self->face, ch)) return true; + return false; + } + for (unsigned i = 0; i < num_cc; i++) { + if (!face_has_codepoint(self->face, combining_chars[i])) return false; } return true; }