This commit is contained in:
Kovid Goyal 2023-05-10 09:56:59 +05:30
commit 6a2edfa847
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 30 deletions

View File

@ -543,6 +543,7 @@ START_ALLOW_CASE_RANGE
case 0xe0b0 ... 0xe0bf: // powerline box drawing case 0xe0b0 ... 0xe0bf: // powerline box drawing
case 0x1fb00 ... 0x1fb8b: // symbols for legacy computing case 0x1fb00 ... 0x1fb8b: // symbols for legacy computing
case 0x1fba0 ... 0x1fbae: case 0x1fba0 ... 0x1fbae:
case 0x1fb90: // inverse medium shade
return BOX_FONT; return BOX_FONT;
default: default:
*is_emoji_presentation = has_emoji_presentation(cpu_cell, gpu_cell); *is_emoji_presentation = has_emoji_presentation(cpu_cell, gpu_cell);
@ -585,6 +586,9 @@ START_ALLOW_CASE_RANGE
return 0x151 + ch - 0x1fba0; return 0x151 + ch - 0x1fba0;
case 0x2800 ... 0x28ff: case 0x2800 ... 0x28ff:
return 0x160 + ch - 0x2800; return 0x160 + ch - 0x2800;
case 0x1fb90:
// Allocated to allow for 0x1fb8c ... 0x1fb94 eventually
return 0x25f + ch - 0x1fb8c;
default: default:
return 0xffff; return 0xffff;
} }

View File

@ -617,37 +617,18 @@ def shade(buf: BufType, width: int, height: int, light: bool = False, invert: bo
square_sz = max(1, width // 12) square_sz = max(1, width // 12)
number_of_rows = height // square_sz number_of_rows = height // square_sz
number_of_cols = width // square_sz number_of_cols = width // square_sz
nums = tuple(range(square_sz)) nums = range(square_sz)
dest = bytearray(width * height) if invert else buf
for r in range(number_of_rows): for r in range(number_of_rows):
is_odd = r % 2 != 0 for c in range(number_of_cols):
if is_odd: if invert ^ ((r % 2 != c % 2) or (light and r % 2 == 1)):
continue continue
fill_even = r % 4 == 0 for yr in nums:
for yr in nums: y = r * square_sz + yr
y = r * square_sz + yr offset = width * y
if y >= height: for xc in nums:
break x = c * square_sz + xc
off = width * y buf[offset + x] = 255
for c in range(number_of_cols):
if light:
fill = (c % 4) == (0 if fill_even else 2)
else:
fill = (c % 2 == 0) == fill_even
if fill:
for xc in nums:
x = (c * square_sz) + xc
if x >= width:
break
dest[off + x] = 255
if invert:
for y in range(height):
off = width * y
for x in range(width):
q = off + x
buf[q] = 255 - dest[q]
def quad(buf: BufType, width: int, height: int, x: int = 0, y: int = 0) -> None: def quad(buf: BufType, width: int, height: int, x: int = 0, y: int = 0) -> None:
@ -883,7 +864,8 @@ box_chars: Dict[str, List[Callable[[BufType, int, int], Any]]] = {
'': [p(eight_block, which=(4, 5, 6, 7))], '': [p(eight_block, which=(4, 5, 6, 7))],
'': [p(shade, light=True)], '': [p(shade, light=True)],
'': [shade], '': [shade],
'': [p(shade, invert=True)], '': [p(shade, light=True, invert=True)],
'🮐': [p(shade, invert=True)],
'': [p(eight_bar, horizontal=True)], '': [p(eight_bar, horizontal=True)],
'': [p(eight_bar, which=7)], '': [p(eight_bar, which=7)],
'': [p(quad, y=1)], '': [p(quad, y=1)],