From 576a269648d4b8004502db2899670f73e02c46a8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 10 Feb 2024 10:13:46 +0530 Subject: [PATCH] Special case rendering of some more box drawing characters using shades from the block of symbols for legacy computing Fixes #7110 --- docs/changelog.rst | 2 ++ kitty/fonts.c | 11 ++++------- kitty/fonts/box_drawing.py | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 14c22b9c1..b537377dd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -68,6 +68,8 @@ Detailed list of changes - macOS: Fix an abort when changing OS window chrome for a full screen window via remote control or the themes kitten (:iss:`7106`) +- Special case rendering of some more box drawing characters using shades from the block of symbols for legacy computing (:iss:`7110`) + 0.32.1 [2024-01-26] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/fonts.c b/kitty/fonts.c index 7ca2146e7..d2441c0b4 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -577,8 +577,7 @@ START_ALLOW_CASE_RANGE case 0x2574 ... 0x259f: case 0x2800 ... 0x28ff: case 0xe0b0 ... 0xe0bf: // powerline box drawing - case 0x1fb00 ... 0x1fb97: // symbols for legacy computing - case 0x1fba0 ... 0x1fbae: + case 0x1fb00 ... 0x1fbae: // symbols for legacy computing return BOX_FONT; default: *is_emoji_presentation = has_emoji_presentation(cpu_cell, gpu_cell); @@ -615,12 +614,10 @@ START_ALLOW_CASE_RANGE return ch - 0x2500; // IDs from 0x00 to 0x9f case 0xe0b0 ... 0xe0d4: return 0xa0 + ch - 0xe0b0; // IDs from 0xa0 to 0xc4 - case 0x1fb00 ... 0x1fb97: - return 0xc5 + ch - 0x1fb00; // IDs from 0xc5 to 0x15c - case 0x1fba0 ... 0x1fbae: - return 0x15d + ch - 0x1fba0; // IDs from 0x15d to 0x16b + case 0x1fb00 ... 0x1fbae: + return 0xc5 + ch - 0x1fb00; // IDs from 0xc5 to 0x173 case 0x2800 ... 0x28ff: - return 0x16c + ch - 0x2800; + return 0x174 + ch - 0x2800; default: return 0xffff; } diff --git a/kitty/fonts/box_drawing.py b/kitty/fonts/box_drawing.py index 642e5fca8..1ab9a5b1b 100644 --- a/kitty/fonts/box_drawing.py +++ b/kitty/fonts/box_drawing.py @@ -663,6 +663,18 @@ def shade( buf[off + c] = 255 +def mask( + mask_func: Callable[[BufType, int, int], None], buf: BufType, width: int, height: int, +) -> None: + m = bytearray(width * height) + mask_func(m, width, height) + for y in range(height): + offset = y * width + for x in range(width): + p = offset + x + buf[p] = int(255.0 * (buf[p] / 255.0 * m[p] / 255.0)) + + def quad(buf: BufType, width: int, height: int, x: int = 0, y: int = 0) -> None: num_cols = width // 2 left = x * num_cols @@ -910,6 +922,10 @@ box_chars: Dict[str, List[Callable[[BufType, int, int], Any]]] = { '๐Ÿฎ•': [p(shade, xnum=4, ynum=4)], '๐Ÿฎ–': [p(shade, xnum=4, ynum=4, invert=True)], '๐Ÿฎ—': [p(shade, xnum=1, ynum=4, invert=True)], + '๐Ÿฎœ': [shade, p(mask, p(corner_triangle, corner='top-left'))], + '๐Ÿฎ': [shade, p(mask, p(corner_triangle, corner='top-right'))], + '๐Ÿฎž': [shade, p(mask, p(corner_triangle, corner='bottom-right'))], + '๐ŸฎŸ': [shade, p(mask, p(corner_triangle, corner='bottom-left'))], 'โ–”': [p(eight_bar, horizontal=True)], 'โ–•': [p(eight_bar, which=7)], @@ -981,9 +997,11 @@ box_chars: Dict[str, List[Callable[[BufType, int, int], Any]]] = { '๐Ÿญช': [p(half_triangle, which='right', inverted=True)], '๐Ÿญซ': [p(half_triangle, which='bottom', inverted=True)], '๐Ÿญฌ': [half_triangle], + '๐Ÿฎ›': [half_triangle, p(half_triangle, which='right')], '๐Ÿญญ': [p(half_triangle, which='top')], '๐Ÿญฎ': [p(half_triangle, which='right')], '๐Ÿญฏ': [p(half_triangle, which='bottom')], + '๐Ÿฎš': [p(half_triangle, which='bottom'), p(half_triangle, which='top')], '๐Ÿญผ': [eight_bar, p(eight_bar, which=7, horizontal=True)], '๐Ÿญฝ': [eight_bar, p(eight_bar, horizontal=True)],