mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
...
This commit is contained in:
@@ -1479,10 +1479,25 @@ def test_chars(chars: str = '╌', sz: int = 128) -> None:
|
|||||||
rgb_data = concat_cells(width, height, False, (nb,))
|
rgb_data = concat_cells(width, height, False, (nb,))
|
||||||
display_bitmap(rgb_data, width, height)
|
display_bitmap(rgb_data, width, height)
|
||||||
print()
|
print()
|
||||||
|
if bytes(nb) != bytes(buf):
|
||||||
|
print_first_few_differing_bytes(buf, nb, width, height)
|
||||||
|
raise SystemExit('Native did not match python rendering')
|
||||||
finally:
|
finally:
|
||||||
set_send_sprite_to_gpu(None)
|
set_send_sprite_to_gpu(None)
|
||||||
|
|
||||||
|
|
||||||
|
def print_first_few_differing_bytes(expected: bytes, actual: bytes, width: int, height: int, count: int = 5) -> None:
|
||||||
|
if expected != actual:
|
||||||
|
for y in range(height):
|
||||||
|
for x in range(width):
|
||||||
|
if expected[y*width + x] != actual[y*width + x]:
|
||||||
|
print(f'differing byte at {x=} {y=}. Expected: {expected[y*width + x]} Actual: {actual[y*width + x]}')
|
||||||
|
count -= 1
|
||||||
|
if not count:
|
||||||
|
break
|
||||||
|
if not count:
|
||||||
|
break
|
||||||
|
|
||||||
def port_chars() -> None:
|
def port_chars() -> None:
|
||||||
from kitty.fast_data_types import concat_cells
|
from kitty.fast_data_types import concat_cells
|
||||||
from kitty.fast_data_types import render_box_char as native_render_box_char
|
from kitty.fast_data_types import render_box_char as native_render_box_char
|
||||||
@@ -1501,16 +1516,7 @@ def port_chars() -> None:
|
|||||||
nb = native_render_box_char(ord(ch), width, height)
|
nb = native_render_box_char(ord(ch), width, height)
|
||||||
if bytes(buf) != nb:
|
if bytes(buf) != nb:
|
||||||
print(f'Failed to match for char: {ch=} ({hex(ord(ch))}) at {width=} {height=}')
|
print(f'Failed to match for char: {ch=} ({hex(ord(ch))}) at {width=} {height=}')
|
||||||
count = 0
|
print_first_few_differing_bytes(buf, nb, width, height)
|
||||||
for y in range(height):
|
|
||||||
for x in range(width):
|
|
||||||
if buf[y*width + x] != nb[y*width + x]:
|
|
||||||
print(f'differing byte at {x=} {y=}. Expected: {buf[y*width + x]} Actual: {nb[y*width + x]}')
|
|
||||||
count += 1
|
|
||||||
if count > 5:
|
|
||||||
break
|
|
||||||
if count > 5:
|
|
||||||
break
|
|
||||||
rgb_data = join_cells(buf)
|
rgb_data = join_cells(buf)
|
||||||
display_bitmap(rgb_data, width, height)
|
display_bitmap(rgb_data, width, height)
|
||||||
print()
|
print()
|
||||||
|
|||||||
Reference in New Issue
Block a user