From e8441ce69709b4421d24c88c32178d4e257b97b8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Dec 2017 11:42:35 +0530 Subject: [PATCH] Ensure double underline is gapped even when underline thickness is less than three pixels --- kitty/fonts/render.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kitty/fonts/render.py b/kitty/fonts/render.py index 095740f64..66bbd47c4 100644 --- a/kitty/fonts/render.py +++ b/kitty/fonts/render.py @@ -79,8 +79,19 @@ def add_line(buf, cell_width, position, thickness, cell_height): def add_dline(buf, cell_width, position, thickness, cell_height): - bottom = min(position - thickness, cell_height - 1) - top = min(position, cell_height - 1) + a = min(position - thickness, cell_height - 1) + b = min(position, cell_height - 1) + top, bottom = min(a, b), max(a, b) + deficit = 2 - (bottom - top) + if deficit > 0: + if bottom + deficit < cell_height: + bottom += deficit + elif bottom < cell_height - 1: + bottom += 1 + if deficit > 1: + top -= deficit - 1 + else: + top -= deficit for y in {top, bottom}: ctypes.memset(ctypes.addressof(buf) + (cell_width * y), 255, cell_width)