diff --git a/docs/changelog.rst b/docs/changelog.rst index fa8a79f4d..ed4e0e67e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,13 @@ Changelog |kitty| is a feature full, cross-platform, *fast*, GPU based terminal emulator. To update |kitty|, :doc:`follow the instructions `. +0.19.3 [future] +------------------- + +- Distribute extra pixels among all eight-blocks rather than adding them + all to the last block (:iss:`3097`) + + 0.19.2 [2020-11-13] ------------------- diff --git a/kitty/fonts/box_drawing.py b/kitty/fonts/box_drawing.py index 05182f3d8..00cdbd30a 100644 --- a/kitty/fonts/box_drawing.py +++ b/kitty/fonts/box_drawing.py @@ -663,17 +663,32 @@ def smooth_mosaic( buf[offset + x] = 255 +def eight_range(size: int, which: int) -> range: + thickness = max(1, size // 8) + block = thickness * 8 + if block == size: + return range(thickness * which, thickness * (which + 1)) + if block > size: + start = min(which * thickness, size - thickness) + return range(start, start + thickness) + extra = size - block + thicknesses = list(repeat(thickness, 8)) + for i in (3, 4, 2, 5, 6, 1, 7, 0): + if not extra: + break + extra -= 1 + thicknesses[i] += 1 + pos = sum(thicknesses[:which]) + return range(pos, pos + thicknesses[which]) + + def eight_bar(buf: BufType, width: int, height: int, level: int = 1, which: int = 0, horizontal: bool = False) -> None: if horizontal: x_range = range(0, width) - thickness = max(1, height // 8) - y_start = min(which * thickness, height - 2) - y_range = range(y_start, height if which == 7 else min(y_start + thickness, height)) + y_range = eight_range(height, which) else: y_range = range(0, height) - thickness = max(1, width // 8) - x_start = min(which * thickness, width - 2) - x_range = range(x_start, width if which == 7 else min(x_start + thickness, width)) + x_range = eight_range(width, which) for y in y_range: offset = y * width for x in x_range: