From 4234a9d9633512bc500e2669f39f7b3e73df9a22 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 4 Nov 2017 16:12:32 +0530 Subject: [PATCH] Sigh apparently unsafe break is not enough --- kitty/fonts.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kitty/fonts.c b/kitty/fonts.c index 37a5200f1..c42be1d6f 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -448,16 +448,17 @@ next_group(unsigned int *num_group_cells, unsigned int *num_group_glyphs, Cell * do { // If the glyph has no advance, then it is a combining char if (positions[*num_group_glyphs].x_advance != 0) *num_group_cells += ((cells[*num_group_cells].attrs & WIDTH_MASK) == 2) ? 2 : 1; + uint32_t cluster = info[*num_group_glyphs].cluster; // check if the next glyph can be broken at - *num_group_glyphs += 1; - unsafe_to_break = *num_group_glyphs < num_glyphs && info[*num_group_glyphs].mask & HB_GLYPH_FLAG_UNSAFE_TO_BREAK; +#define IS_COMBINING_GLYPH ((unsafe_to_break = info[*num_group_glyphs].mask & HB_GLYPH_FLAG_UNSAFE_TO_BREAK || info[*num_group_glyphs].cluster == cluster)) // Soak up all combining char glyphs - if (unsafe_to_break) { - while (*num_group_glyphs < num_glyphs && positions[*num_group_glyphs].x_advance == 0 && info[*num_group_glyphs].mask & HB_GLYPH_FLAG_UNSAFE_TO_BREAK) *num_group_glyphs += 1; - } + do { + *num_group_glyphs += 1; + } while (*num_group_glyphs < num_glyphs && IS_COMBINING_GLYPH && positions[*num_group_glyphs].x_advance == 0); } while (unsafe_to_break && *num_group_cells < num_cells && *num_group_glyphs < MIN(num_glyphs, 6)); +#undef IS_COMBINING_GLYPH *num_group_cells = MAX(1, MIN(*num_group_cells, num_cells)); *num_group_glyphs = MAX(1, MIN(*num_group_glyphs, num_glyphs)); }