gen.py: remove block end, which cannot be determined easily

It depends on the grid height and I don't want to go parse that.
This commit is contained in:
Lephenixnoir 2021-06-27 16:54:29 +02:00
parent a4e935cfd8
commit 0a27a85b13
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 6 additions and 18 deletions

24
gen.py
View File

@ -41,53 +41,41 @@ def char_image(c):
index = 4 * char_index(c)
return chars.crop((index, 0, index + 3, 5))
def separator(start, end, width):
def separator(start, width):
img = PIL.Image.new("RGB", (width, 9), color=WHITE)
for j in range(3, 6):
for i in range(1, width//2 - 30):
for i in range(1, width//2 - 15):
if not ((i + j) & 1):
img.putpixel((i, j), BLACK)
for i in range(width//2 + 30, width-1):
for i in range(width//2 + 15, width-1):
if not ((i + j) & 1):
img.putpixel((i, j), BLACK)
x = width//2 - 29
x = width//2 - 11
for c in "U+{:04X}".format(start):
img.paste(char_image(c), (x, 2))
x += 4
for i in range(width//2 - 2, width//2 + 2):
img.putpixel((i, 4), BLACK)
x = width//2 + 6
for c in "U+{:04X}".format(end):
img.paste(char_image(c), (x, 2))
x += 4
return img
class Block:
def __init__(self, path):
basename = os.path.basename(path)
match = re.search(r'U\+([0-9A-Za-z]{4})', basename)
self.block_start = None
self.block_end = None
self.img = PIL.Image.open(path)
if match is not None:
self.block_start = int(match[1], 16)
self.block_end = self.block_start + 16 * (self.img.height // 9) - 1
print('{} U+{:04X} - U+{:04X}'.format(basename, self.block_start,
self.block_end))
print('{} U+{:04X}'.format(basename, self.block_start))
else:
print(f'{basename} not a block')
def header(self, width):
if self.block_start is not None:
return separator(self.block_start, self.block_end, width)
return separator(self.block_start, width)
else:
return empty_separator(width)

BIN
uf5x7.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

BIN
uf8x9.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 19 KiB