From 5c591d5355f600080b6f179cf65863e1836be49d Mon Sep 17 00:00:00 2001 From: zhaolei Date: Sun, 26 Apr 2026 15:13:29 +0800 Subject: [PATCH] Add tests for glyph_matches_dot_liga_final_component --- kitty/fonts.c | 34 +--------------------------------- kitty_tests/fonts.py | 4 ++++ 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/kitty/fonts.c b/kitty/fonts.c index 4a7d9b549..f3ead2f6b 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -1489,35 +1489,6 @@ ligature_type_for_glyph(hb_font_t *hbf, glyph_index glyph_id, SpacerStrategy str return ligature_type_from_glyph_name(glyph_name, strategy); } -static bool -dot_liga_final_component(const char *glyph_name, char *output, size_t output_sz) { - static const char suffix[] = ".liga"; - static const size_t suffix_len = sizeof(suffix) - 1; - size_t len = strlen(glyph_name); - if (len <= suffix_len || strcmp(glyph_name + len - suffix_len, suffix) != 0) return false; - len -= suffix_len; - const char *start = glyph_name; - for (const char *p = glyph_name; p < glyph_name + len; p++) { - if (*p == '_') start = p + 1; - } - const size_t component_len = (size_t)(glyph_name + len - start); - if (!component_len || component_len + 1 >= output_sz) return false; - memcpy(output, start, component_len); - output[component_len] = 0; - return true; -} - -static bool -glyph_matches_dot_liga_final_component(hb_font_t *hbf, glyph_index dot_liga_glyph_id, glyph_index current_glyph_id) { - // For .liga + placeholder + final glyph cases - char dot_liga_name[256], current_name[256], final_component[256]; - dot_liga_name[sizeof(dot_liga_name)-1] = 0; current_name[sizeof(current_name)-1] = 0; - hb_font_glyph_to_string(hbf, dot_liga_glyph_id, dot_liga_name, sizeof(dot_liga_name) - 1); - if (!dot_liga_final_component(dot_liga_name, final_component, sizeof(final_component))) return false; - hb_font_glyph_to_string(hbf, current_glyph_id, current_name, sizeof(current_name) - 1); - return strcmp(final_component, current_name) == 0; -} - #define L INFINITE_LIGATURE_START #define M INFINITE_LIGATURE_MIDDLE #define R INFINITE_LIGATURE_END @@ -1662,10 +1633,7 @@ group_normal(Font *font, hb_font_t *hbf, const TextCache *tc, ListOfChars *lc) { else if (font->spacer_strategy == SPACERS_BEFORE) add_to_current_group = G(prev_was_empty); else add_to_current_group = is_empty; } else { - add_to_current_group = !G(prev_was_special) || !current_group->num_cells || ( - G(prev_was_empty) && current_group->has_special_glyph && - glyph_matches_dot_liga_final_component(hbf, G(info)[current_group->first_glyph_idx].codepoint, glyph_id) - ); + add_to_current_group = !G(prev_was_special) || !current_group->num_cells; } } #if 0 diff --git a/kitty_tests/fonts.py b/kitty_tests/fonts.py index 84eaf76c6..6bd65c2c8 100644 --- a/kitty_tests/fonts.py +++ b/kitty_tests/fonts.py @@ -411,6 +411,10 @@ class Rendering(FontBaseTest): self.assertNotEqual(colon_glyph, ss(':', font='FiraCode-Medium.otf')[0][2]) self.ae(colon_glyph, 1031) self.ae(groups('9:30', font='FiraCode-Medium.otf'), [(1, 1), (1, 1), (1, 1), (1, 1)]) + self.ae(groups('#_(', font='FiraCode-Medium.otf'), [(3, 3)]) + self.ae(groups('a#_(b', font='FiraCode-Medium.otf'), [(1, 1), (3, 3), (1, 1)]) + self.ae(groups('<*>>', font='FiraCode-Medium.otf'), [(3, 3), (1, 1)]) + self.ae(groups('a<*>>b', font='FiraCode-Medium.otf'), [(1, 1), (3, 3), (1, 1), (1, 1)]) self.ae(groups('|\U0001F601|\U0001F64f|\U0001F63a|'), [(1, 1), (2, 1), (1, 1), (2, 1), (1, 1), (2, 1), (1, 1)]) self.ae(groups('He\u0347\u0305llo\u0337,', font='LiberationMono-Regular.ttf'),