From 18ce091bfa9130065e38f460a9e916ef54879b46 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Feb 2022 06:36:54 +0530 Subject: [PATCH] Fix symbol/PUA glyphs loaded via symbol_map instead of as fallbacks not using following spaces to render larger versions Fixes #4670 --- docs/changelog.rst | 2 ++ kitty/fonts.c | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 05da4d596..c808f84d1 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -123,6 +123,8 @@ Detailed list of changes - Fix :opt:`touch_scroll_multiplier` also taking effect in terminal programs such as vim that handle mouse events themselves (:iss:`4680`) +- Fix symbol/PUA glyphs loaded via :opt:`symbol_map` instead of as fallbacks not using following spaces to render larger versions (:iss:`4670`) + 0.24.2 [2022-02-03] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/fonts.c b/kitty/fonts.c index b692af854..3207e891f 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -492,8 +492,8 @@ in_symbol_maps(FontGroup *fg, char_type ch) { // - BOX_FONT // - an index in the fonts list static ssize_t -font_for_cell(FontGroup *fg, CPUCell *cpu_cell, GPUCell *gpu_cell, bool *is_fallback_font, bool *is_emoji_presentation) { - *is_fallback_font = false; +font_for_cell(FontGroup *fg, CPUCell *cpu_cell, GPUCell *gpu_cell, bool *is_main_font, bool *is_emoji_presentation) { + *is_main_font = false; *is_emoji_presentation = false; START_ALLOW_CASE_RANGE ssize_t ans; @@ -510,6 +510,7 @@ START_ALLOW_CASE_RANGE case 0x1fba0 ... 0x1fbae: return BOX_FONT; default: + *is_emoji_presentation = has_emoji_presentation(cpu_cell, gpu_cell); ans = in_symbol_maps(fg, cpu_cell->ch); if (ans > -1) return ans; switch(gpu_cell->attrs.bold | (gpu_cell->attrs.italic << 1)) { @@ -523,9 +524,7 @@ START_ALLOW_CASE_RANGE ans = fg->bi_font_idx; break; } if (ans < 0) ans = fg->medium_font_idx; - *is_emoji_presentation = has_emoji_presentation(cpu_cell, gpu_cell); - if (!*is_emoji_presentation && has_cell_text(fg->fonts + ans, cpu_cell)) return ans; - *is_fallback_font = true; + if (!*is_emoji_presentation && has_cell_text(fg->fonts + ans, cpu_cell)) { *is_main_font = true; return ans; } return fallback_font(fg, cpu_cell, gpu_cell); } END_ALLOW_CASE_RANGE @@ -1237,12 +1236,12 @@ render_line(FONTS_DATA_HANDLE fg_, Line *line, index_type lnum, Cursor *cursor, if (prev_width == 2) { prev_width = 0; continue; } CPUCell *cpu_cell = line->cpu_cells + i; GPUCell *gpu_cell = line->gpu_cells + i; - bool is_fallback_font, is_emoji_presentation; - ssize_t cell_font_idx = font_for_cell(fg, cpu_cell, gpu_cell, &is_fallback_font, &is_emoji_presentation); + bool is_main_font, is_emoji_presentation; + ssize_t cell_font_idx = font_for_cell(fg, cpu_cell, gpu_cell, &is_main_font, &is_emoji_presentation); if ( cell_font_idx != MISSING_FONT && - ((is_fallback_font && !is_emoji_presentation && is_symbol(cpu_cell->ch)) || (cell_font_idx != BOX_FONT && (is_private_use(cpu_cell->ch))) || is_non_emoji_dingbat(cpu_cell->ch)) + ((!is_main_font && !is_emoji_presentation && is_symbol(cpu_cell->ch)) || (cell_font_idx != BOX_FONT && (is_private_use(cpu_cell->ch))) || is_non_emoji_dingbat(cpu_cell->ch)) ) { unsigned int desired_cells = 1; if (cell_font_idx > 0) {