mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
Change algorithm for y position of dashed/dotted underlines
Make the inner loop faster and ensure that the same logic for y-position and thickness is used as for the straight underline. Fixes #8074
This commit is contained in:
@@ -99,6 +99,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Graphics protocol: Fix delete by number not deleting newest image with the specified number (:iss:`8071`)
|
- Graphics protocol: Fix delete by number not deleting newest image with the specified number (:iss:`8071`)
|
||||||
|
|
||||||
|
- Fix dashed and dotted underlines not being drawn at the same y position as straight underlines at all font sizes (:iss:`8074`)
|
||||||
|
|
||||||
0.37.0 [2024-10-30]
|
0.37.0 [2024-10-30]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -281,19 +281,28 @@ def add_curl(buf: CBufType, cell_width: int, position: int, thickness: int, cell
|
|||||||
|
|
||||||
def add_dots(buf: CBufType, cell_width: int, position: int, thickness: int, cell_height: int) -> None:
|
def add_dots(buf: CBufType, cell_width: int, position: int, thickness: int, cell_height: int) -> None:
|
||||||
spacing, size = distribute_dots(cell_width, cell_width // (2 * thickness))
|
spacing, size = distribute_dots(cell_width, cell_width // (2 * thickness))
|
||||||
|
y = position - thickness // 2
|
||||||
y = 1 + position - thickness // 2
|
buf_addr = ctypes.addressof(buf)
|
||||||
for i in range(y, min(y + thickness, cell_height)):
|
while thickness > 0 and -1 < y < cell_height:
|
||||||
|
offset = buf_addr + cell_width * y
|
||||||
for j, s in enumerate(spacing):
|
for j, s in enumerate(spacing):
|
||||||
buf[cell_width * i + j * size + s: cell_width * i + (j + 1) * size + s] = [255] * size
|
ctypes.memset(offset + j * size + s, 255, size)
|
||||||
|
thickness -= 1
|
||||||
|
y += 1
|
||||||
|
|
||||||
|
|
||||||
def add_dashes(buf: CBufType, cell_width: int, position: int, thickness: int, cell_height: int) -> None:
|
def add_dashes(buf: CBufType, cell_width: int, position: int, thickness: int, cell_height: int) -> None:
|
||||||
halfspace_width = cell_width // 4
|
halfspace_width = cell_width // 4
|
||||||
y = 1 + position - thickness // 2
|
y = position - thickness // 2
|
||||||
for i in range(y, min(y + thickness, cell_height)):
|
dash_width = cell_width - 3 * halfspace_width
|
||||||
buf[cell_width * i:cell_width * i + (cell_width - 3 * halfspace_width)] = [255] * (cell_width - 3 * halfspace_width)
|
second_dash_start = 3 * halfspace_width
|
||||||
buf[cell_width * i + 3 * halfspace_width:cell_width * (i + 1)] = [255] * (cell_width - 3 * halfspace_width)
|
buf_addr = ctypes.addressof(buf)
|
||||||
|
while thickness > 0 and -1 < y < cell_height:
|
||||||
|
offset = buf_addr + cell_width * y
|
||||||
|
ctypes.memset(offset, 255, dash_width)
|
||||||
|
ctypes.memset(offset + second_dash_start, 255, dash_width)
|
||||||
|
thickness -= 1
|
||||||
|
y += 1
|
||||||
|
|
||||||
|
|
||||||
def render_special(
|
def render_special(
|
||||||
|
|||||||
Reference in New Issue
Block a user