Update font image generator to python3, scale images by 3x, regenerate images (#15)

* Update mkfontimage to python3

* Updated font images

* make the images prettier (& the top image bigger)

* fix resampling
This commit is contained in:
Jeff Epler 2022-01-23 09:43:14 -06:00 committed by GitHub
parent 474f7896b3
commit 999c909b6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 11 deletions

View file

@ -41,14 +41,14 @@ charset%.bin: charset%.o charset.cfg
.PHONY: update-font-images .PHONY: update-font-images
update-font-images: charset.bin charset2.bin charset3.bin charset4.bin mkfontimg.py update-font-images: charset.bin charset2.bin charset3.bin charset4.bin mkfontimg.py
python mkfontimg.py -l charset.bin img/t1.png python3 mkfontimg.py -l charset.bin img/t1.png
python mkfontimg.py charset.bin img/g1.png python3 mkfontimg.py charset.bin img/g1.png
python mkfontimg.py -l charset2.bin img/t2.png python3 mkfontimg.py -l charset2.bin img/t2.png
python mkfontimg.py charset2.bin img/g2.png python3 mkfontimg.py charset2.bin img/g2.png
python mkfontimg.py -l charset3.bin img/t3.png python3 mkfontimg.py -l charset3.bin img/t3.png
python mkfontimg.py charset3.bin img/g3.png python3 mkfontimg.py charset3.bin img/g3.png
python mkfontimg.py -l charset4.bin img/t4.png python3 mkfontimg.py -l charset4.bin img/t4.png
python mkfontimg.py charset4.bin img/g4.png python3 mkfontimg.py charset4.bin img/g4.png
.INTERMEDIATE: 80columns.bin .INTERMEDIATE: 80columns.bin
80columns.bin: 80columns.o charset.o 80columns.cfg 80columns.bin: 80columns.o charset.o 80columns.cfg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 857 B

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 932 B

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 940 B

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 886 B

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 904 B

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 970 B

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
import sys import sys
import struct
import PIL.Image as Image import PIL.Image as Image
text = """\ text = """\
@ -22,9 +23,12 @@ def toscreencode(ch):
if '`' <= ch <= '~': return cc - 96 if '`' <= ch <= '~': return cc - 96
return cc return cc
charset = map(ord, open(sys.argv[1]).read()) charset = open(sys.argv[1], "rb").read()
FG = 0xFFDE7886
BG = 0xFFAA3A48
def putcat(img, r, c, code, lowercase): def putcat(img, r, c, code, lowercase):
inverse = code & 128 inverse = code & 128
code = code % 128 code = code % 128
@ -33,10 +37,19 @@ def putcat(img, r, c, code, lowercase):
data = charset[idx+y+lowercase*1024] data = charset[idx+y+lowercase*1024]
if not inverse: data = ~data if not inverse: data = ~data
for x in range(4): for x in range(4):
img.putpixel((4*c+x,8*r+y), data & (1<<(3-x))) if ~data & (1<<(3-x)):
img.putpixel((8+4*c+x,8+8*r+y), FG)
img = Image.frombytes('1', (188,64), '\xff' * 188*64) BG_buf = struct.pack('<I', BG)
img = Image.frombytes('RGBA', (16+188,16+64), BG_buf * (16+188)*(16+64))
for i in range(8):
for x in range(img.width):
img.putpixel((x, i), FG)
img.putpixel((x, img.height-i-1), FG)
for y in range(img.height):
img.putpixel((i, y), FG)
img.putpixel((img.width-i-1, y), FG)
r=c=0 r=c=0
for ch in text: for ch in text:
if ch == '\n': if ch == '\n':
@ -52,4 +65,5 @@ for r in range(8):
for c in range(16): for c in range(16):
putcat(img, r, c+31, r*16+c, lowercase) putcat(img, r, c+31, r*16+c, lowercase)
img = img.resize((img.size[0]*3, img.size[1]*3), resample=Image.NEAREST)
img.save(sys.argv[2]) img.save(sys.argv[2])