From a935c80adc68460f0df72169264cc84bb20f5839 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 1 Sep 2020 18:25:58 +0530 Subject: [PATCH] Use box drawing for sextants See the Symbols for Legacy Computing section in the Unicode standard https://www.unicode.org/charts/PDF/U1FB00.pdf --- docs/changelog.rst | 3 +++ kitty/fonts.c | 5 ++++- kitty/fonts/box_drawing.py | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 0adc63016..b73c7a9fa 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -37,6 +37,9 @@ To update |kitty|, :doc:`follow the instructions `. - Fix unfocused windows in which a bell occurs not changing their border color to red until a relayout +- Implement special rendering for various characters from the set of "Symbols + for Legacy Computing" from the Unicode 13 standard + 0.18.3 [2020-08-11] ------------------- diff --git a/kitty/fonts.c b/kitty/fonts.c index 1ac4ae901..5a772444c 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -600,6 +600,7 @@ START_ALLOW_CASE_RANGE case 0xe0ba: //  case 0xe0bc: //  case 0xe0be: //  + case 0x1fb00 ... 0x1fb3b: // sextants return BOX_FONT; default: ans = in_symbol_maps(fg, cpu_cell->ch); @@ -637,8 +638,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 ... 0x1fb3b: + return 0xc5 + ch - 0x1fb00; default: - return 0xff; + return 0xffff; } END_ALLOW_CASE_RANGE } diff --git a/kitty/fonts/box_drawing.py b/kitty/fonts/box_drawing.py index 3ae400e81..7d6c4c097 100644 --- a/kitty/fonts/box_drawing.py +++ b/kitty/fonts/box_drawing.py @@ -582,6 +582,35 @@ def quad(buf: BufType, width: int, height: int, x: int = 0, y: int = 0) -> None: buf[off + c] = 255 +def sextant(buf: BufType, width: int, height: int, level: int = 1, which: int = 0) -> None: + + def draw_sextant(row: int = 0, col: int = 0) -> None: + if row == 0: + y_start, y_end = 0, height // 3 + elif row == 1: + y_start, y_end = height // 3, 2 * height // 3 + else: + y_start, y_end = 2 * height // 3, height + if col == 0: + x_start, x_end = 0, width // 2 + else: + x_start, x_end = width // 2, width + for r in range(y_start, y_end): + off = r * width + for c in range(x_start, x_end): + buf[c + off] = 255 + + def add_row(q: int, r: int) -> None: + if q & 1: + draw_sextant(r) + if q & 2: + draw_sextant(r, col=1) + + add_row(which % 4, 0) + add_row(which // 4, 1) + add_row(which // 16, 2) + + box_chars: Dict[str, List[Callable]] = { '─': [hline], '━': [p(hline, level=3)], @@ -710,6 +739,14 @@ def quad(buf: BufType, width: int, height: int, x: int = 0, y: int = 0) -> None: box_chars[ch] = [p(cast(Callable, func_), which=ch)] +c = 0x1fb00 +for i in range(1, 63): + if i in (20, 40): + continue + box_chars[chr(c)] = [p(sextant, which=i)] + c += 1 + + def render_box_char(ch: str, buf: BufType, width: int, height: int, dpi: float = 96.0) -> BufType: global _dpi _dpi = dpi