Special case rendering of the few remaining Powerline box drawing chars
Fixes #3535
This commit is contained in:
parent
62656b24eb
commit
f32ad617a2
@ -38,6 +38,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
- Fix reading :option:`kitty --session` from ``STDIN`` not working when the
|
- Fix reading :option:`kitty --session` from ``STDIN`` not working when the
|
||||||
:option:`kitty --detach` option is used (:iss:`3523`)
|
:option:`kitty --detach` option is used (:iss:`3523`)
|
||||||
|
|
||||||
|
- Special case rendering of the few remaining Powerline box drawing chars
|
||||||
|
(:iss:`3535`)
|
||||||
|
|
||||||
|
|
||||||
0.20.1 [2021-04-19]
|
0.20.1 [2021-04-19]
|
||||||
----------------------
|
----------------------
|
||||||
|
|||||||
@ -602,13 +602,8 @@ START_ALLOW_CASE_RANGE
|
|||||||
return BLANK_FONT;
|
return BLANK_FONT;
|
||||||
case 0x2500 ... 0x2573:
|
case 0x2500 ... 0x2573:
|
||||||
case 0x2574 ... 0x259f:
|
case 0x2574 ... 0x259f:
|
||||||
case 0xe0b0 ... 0xe0b4:
|
|
||||||
case 0x2800 ... 0x28ff:
|
case 0x2800 ... 0x28ff:
|
||||||
case 0xe0b6:
|
case 0xe0b0 ... 0xe0bf: // powerline box drawing
|
||||||
case 0xe0b8: //
|
|
||||||
case 0xe0ba: //
|
|
||||||
case 0xe0bc: //
|
|
||||||
case 0xe0be: //
|
|
||||||
case 0x1fb00 ... 0x1fb8b: // symbols for legacy computing
|
case 0x1fb00 ... 0x1fb8b: // symbols for legacy computing
|
||||||
case 0x1fba0 ... 0x1fbae:
|
case 0x1fba0 ... 0x1fbae:
|
||||||
return BOX_FONT;
|
return BOX_FONT;
|
||||||
|
|||||||
@ -165,13 +165,14 @@ def downsample(src: BufType, dest: BufType, dest_width: int, dest_height: int, f
|
|||||||
dest[offset + x] = min(255, dest[offset + x] + average_intensity_in_src(x, y))
|
dest[offset + x] = min(255, dest[offset + x] + average_intensity_in_src(x, y))
|
||||||
|
|
||||||
|
|
||||||
|
class SSByteArray(bytearray):
|
||||||
|
supersample_factor = 1
|
||||||
|
|
||||||
|
|
||||||
def supersampled(supersample_factor: int = 4) -> Callable:
|
def supersampled(supersample_factor: int = 4) -> Callable:
|
||||||
# Anti-alias the drawing performed by the wrapped function by
|
# Anti-alias the drawing performed by the wrapped function by
|
||||||
# using supersampling
|
# using supersampling
|
||||||
|
|
||||||
class SSByteArray(bytearray):
|
|
||||||
supersample_factor = 1
|
|
||||||
|
|
||||||
def create_wrapper(f: Callable) -> Callable:
|
def create_wrapper(f: Callable) -> Callable:
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def supersampled_wrapper(buf: BufType, width: int, height: int, *args: Any, **kw: Any) -> None:
|
def supersampled_wrapper(buf: BufType, width: int, height: int, *args: Any, **kw: Any) -> None:
|
||||||
@ -495,6 +496,29 @@ def rounded_corner(buf: BufType, width: int, height: int, level: int = 1, which:
|
|||||||
draw_parametrized_curve(buf, width, height, level, xfunc, yfunc)
|
draw_parametrized_curve(buf, width, height, level, xfunc, yfunc)
|
||||||
|
|
||||||
|
|
||||||
|
@supersampled()
|
||||||
|
def rounded_separator(buf: BufType, width: int, height: int, level: int = 1, left: bool = True) -> None:
|
||||||
|
supersample_factor = getattr(buf, 'supersample_factor')
|
||||||
|
gap = thickness(level) * supersample_factor
|
||||||
|
c1x = find_bezier_for_D(width - gap, height)
|
||||||
|
start = (0, 0)
|
||||||
|
end = (0, height - 1)
|
||||||
|
c1 = c1x, start[1]
|
||||||
|
c2 = c1x, end[1]
|
||||||
|
bezier_x, bezier_y = cubic_bezier(start, end, c1, c2)
|
||||||
|
if left:
|
||||||
|
draw_parametrized_curve(buf, width, height, level, bezier_x, bezier_y)
|
||||||
|
else:
|
||||||
|
mbuf = SSByteArray(width * height)
|
||||||
|
mbuf.supersample_factor = supersample_factor
|
||||||
|
draw_parametrized_curve(mbuf, width, height, level, bezier_x, bezier_y)
|
||||||
|
for y in range(height):
|
||||||
|
offset = y * width
|
||||||
|
for src_x in range(width):
|
||||||
|
dest_x = width - 1 - src_x
|
||||||
|
buf[offset + dest_x] = mbuf[offset + src_x]
|
||||||
|
|
||||||
|
|
||||||
def half_dhline(buf: BufType, width: int, height: int, level: int = 1, which: str = 'left', only: Optional[str] = None) -> Tuple[int, int]:
|
def half_dhline(buf: BufType, width: int, height: int, level: int = 1, which: str = 'left', only: Optional[str] = None) -> Tuple[int, int]:
|
||||||
x1, x2 = (0, width // 2) if which == 'left' else (width // 2, width)
|
x1, x2 = (0, width // 2) if which == 'left' else (width // 2, width)
|
||||||
gap = thickness(level + 1, horizontal=False)
|
gap = thickness(level + 1, horizontal=False)
|
||||||
@ -792,15 +816,21 @@ box_chars: Dict[str, List[Callable]] = {
|
|||||||
'╾': [p(half_hline, level=3), p(half_hline, which='right')],
|
'╾': [p(half_hline, level=3), p(half_hline, which='right')],
|
||||||
'╿': [p(half_vline, level=3), p(half_vline, which='bottom')],
|
'╿': [p(half_vline, level=3), p(half_vline, which='bottom')],
|
||||||
'': [triangle],
|
'': [triangle],
|
||||||
'': [p(triangle, left=False)],
|
|
||||||
'': [D],
|
|
||||||
'': [p(D, left=False)],
|
|
||||||
'': [p(half_cross_line, which='tl'), p(half_cross_line, which='bl')],
|
'': [p(half_cross_line, which='tl'), p(half_cross_line, which='bl')],
|
||||||
|
'': [p(triangle, left=False)],
|
||||||
'': [p(half_cross_line, which='tr'), p(half_cross_line, which='br')],
|
'': [p(half_cross_line, which='tr'), p(half_cross_line, which='br')],
|
||||||
|
'': [D],
|
||||||
|
'': [rounded_separator],
|
||||||
|
'': [p(D, left=False)],
|
||||||
|
'': [p(rounded_separator, left=False)],
|
||||||
'': [p(corner_triangle, corner='bottom-left')],
|
'': [p(corner_triangle, corner='bottom-left')],
|
||||||
|
'': [cross_line],
|
||||||
'': [p(corner_triangle, corner='bottom-right')],
|
'': [p(corner_triangle, corner='bottom-right')],
|
||||||
|
'': [p(cross_line, left=False)],
|
||||||
'': [p(corner_triangle, corner='top-left')],
|
'': [p(corner_triangle, corner='top-left')],
|
||||||
|
'': [p(cross_line, left=False)],
|
||||||
'': [p(corner_triangle, corner='top-right')],
|
'': [p(corner_triangle, corner='top-right')],
|
||||||
|
'': [cross_line],
|
||||||
'═': [dhline],
|
'═': [dhline],
|
||||||
'║': [dvline],
|
'║': [dvline],
|
||||||
|
|
||||||
@ -1037,7 +1067,7 @@ def test_char(ch: str, sz: int = 48) -> None:
|
|||||||
set_send_sprite_to_gpu(None)
|
set_send_sprite_to_gpu(None)
|
||||||
|
|
||||||
|
|
||||||
def test_drawing(sz: int = 48, family: str = 'monospace') -> None:
|
def test_drawing(sz: int = 48, family: str = 'monospace', start: int = 0x2500, num_rows: int = 10, num_cols: int = 16) -> None:
|
||||||
from .render import display_bitmap, setup_for_testing
|
from .render import display_bitmap, setup_for_testing
|
||||||
from kitty.fast_data_types import concat_cells, set_send_sprite_to_gpu
|
from kitty.fast_data_types import concat_cells, set_send_sprite_to_gpu
|
||||||
|
|
||||||
@ -1055,14 +1085,14 @@ def test_drawing(sz: int = 48, family: str = 'monospace') -> None:
|
|||||||
return cell
|
return cell
|
||||||
return space
|
return space
|
||||||
|
|
||||||
pos = 0x2500
|
pos = start
|
||||||
rows = []
|
rows = []
|
||||||
space_row = join_cells(repeat(space, 32))
|
space_row = join_cells(repeat(space, 32))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for r in range(10):
|
for r in range(num_rows):
|
||||||
row = []
|
row = []
|
||||||
for i in range(16):
|
for i in range(num_cols):
|
||||||
row.append(render_chr(chr(pos)))
|
row.append(render_chr(chr(pos)))
|
||||||
row.append(space)
|
row.append(space)
|
||||||
pos += 1
|
pos += 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user