From ce583ea460232de58f46cb9aea0c082c8794895e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 24 Oct 2023 17:38:49 +0530 Subject: [PATCH] Render Private Use Unicode symbols using two cells if the second cell contains a non-breaking space as well as a normal space There is some software out there that uses nbsp as a separator, presumably as some kind of hack. https://github.com/ibhagwan/fzf-lua/issues/916 --- docs/changelog.rst | 2 ++ docs/faq.rst | 6 +++--- kitty/fonts.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index d66cda34a..d49e930d4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -76,6 +76,8 @@ Detailed list of changes - When pasting, if the text contains terminal control codes ask the user for permission. See :opt:`paste_actions` for details. Thanks to David Leadbeater for discovering this. +- Render Private Use Unicode symbols using two cells if the second cell contains a non-breaking space as well as a normal space + 0.30.1 [2023-10-05] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/faq.rst b/docs/faq.rst index 20557ebea..fddcb6f31 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -19,9 +19,9 @@ use Unicode characters from the private use area to represent symbols. Often these symbols are wide and should be rendered in two cells. However, since private use area symbols all have their width set to one in the Unicode standard, |kitty| renders them either smaller or truncated. The exception is if -these characters are followed by a space or empty cell in which case kitty -makes use of the extra cell to render them in two cells. This behavior can be -turned off for specific symbols using :opt:`narrow_symbols`. +these characters are followed by a space or non-breaking space in which case +kitty makes use of the extra cell to render them in two cells. This behavior +can be turned off for specific symbols using :opt:`narrow_symbols`. Using a color theme with a background color does not work well in vim? diff --git a/kitty/fonts.c b/kitty/fonts.c index 2295ecce7..cb3822e22 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -534,6 +534,7 @@ START_ALLOW_CASE_RANGE switch(cpu_cell->ch) { case 0: case ' ': + case 0xa0: // nbsp case '\t': case IMAGE_PLACEHOLDER_CHAR: return BLANK_FONT; @@ -1325,7 +1326,7 @@ render_line(FONTS_DATA_HANDLE fg_, Line *line, index_type lnum, Cursor *cursor, unsigned int num_spaces = 0; while ( i + num_spaces + 1 < line->xnum - && line->cpu_cells[i+num_spaces+1].ch == ' ' + && (line->cpu_cells[i+num_spaces+1].ch == ' ' || line->cpu_cells[i+num_spaces+1].ch == 0xa0) // space or nbsp && num_spaces < MAX_NUM_EXTRA_GLYPHS_PUA && num_spaces + 1 < desired_cells ) {