From e12a9f3caf71cd8d96c7d81314d1888156f37a54 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 1 Jun 2022 12:00:53 +0530 Subject: [PATCH] Iosevka: Fix incorrect rendering when there is a combining char that does not group with its neighbors Fixes #5153 --- docs/changelog.rst | 3 +++ kitty/fonts.c | 12 +++++++++--- kitty_tests/fonts.py | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index ef9aa9d1f..aaadfd28e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -53,6 +53,9 @@ Detailed list of changes - Themes kitten: Add a tab to show user defined custom color themes separately (:pull:`5150`) +- Iosevka: Fix incorrect rendering when there is a combining char that does not + group with its neighbors (:iss:`5153`) + 0.25.1 [2022-05-26] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/fonts.c b/kitty/fonts.c index d066688b5..454e353d4 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -928,8 +928,14 @@ group_iosevka(Font *font, hb_font_t *hbf) { const LigatureType current = ligature_types[G(glyph_idx)]; const LigatureType after = is_last_glyph ? LIGATURE_UNKNOWN : ligature_types[G(glyph_idx + 1)]; bool end_current_group = false; - if (current_group->num_glyphs && is_iosevka_lig_ender(before, current, after)) { - end_current_group = true; + if (current_group->num_glyphs) { + if (is_iosevka_lig_ender(before, current, after)) end_current_group = true; + else { + if (!current_group->num_cells && !current_group->has_special_glyph) { + if (is_iosevka_lig_starter(before, current, after)) current_group->has_special_glyph = true; + else end_current_group = true; + } + } } if (!current_group->num_glyphs++) { if (is_iosevka_lig_starter(before, current, after)) current_group->has_special_glyph = true; @@ -954,7 +960,7 @@ group_iosevka(Font *font, hb_font_t *hbf) { } current_group->num_cells += num_cells_consumed; } - if (end_current_group) G(group_idx)++; + if (end_current_group && current_group->num_cells) G(group_idx)++; G(glyph_idx)++; } } diff --git a/kitty_tests/fonts.py b/kitty_tests/fonts.py index 613de3e24..089ce7df4 100644 --- a/kitty_tests/fonts.py +++ b/kitty_tests/fonts.py @@ -110,6 +110,7 @@ class Rendering(BaseTest): self.ae(g('===--<>=='), [(3, 3), (2, 2), (2, 2), (2, 2)]) self.ae(g('==!=<>==<><><>'), [(4, 4), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)]) self.ae(g('-' * 18), [(18, 18)]) + self.ae(g('a>\u2060