Files

46 lines
1.6 KiB
Bash

#!/bin/bash
python3 - <<'EOF'
from PIL import Image, ImageDraw, ImageFont
text = 'Kaspersky Rescue Disk 18'
orig = Image.open('/mnt/f/efi/Paravis/Boot/xor/Main1.bmp').convert('RGB').crop((44, 476, 316, 506))
cands = [
('Segoe UI Semibold', '/mnt/c/Windows/Fonts/seguisb.ttf', 23),
('Segoe UI Bold', '/mnt/c/Windows/Fonts/segoeuib.ttf', 22),
('Segoe UI', '/mnt/c/Windows/Fonts/segoeui.ttf', 23),
('Arial Bold', '/mnt/c/Windows/Fonts/arialbd.ttf', 21),
('Tahoma Bold', '/mnt/c/Windows/Fonts/tahomabd.ttf', 21),
('Verdana Bold', '/mnt/c/Windows/Fonts/verdanab.ttf', 20),
('Calibri Bold', '/mnt/c/Windows/Fonts/calibrib.ttf', 23),
('Trebuchet Bold', '/mnt/c/Windows/Fonts/trebucbd.ttf', 22),
('Franklin Gothic', '/mnt/c/Windows/Fonts/framd.ttf', 22),
('PhagsPa Bold', '/mnt/c/Windows/Fonts/phagspab.ttf', 22),
]
rows = [('ORIGINAL', orig)]
for name, path, size in cands:
try:
f = ImageFont.truetype(path, size)
except Exception as e:
print('skip', name, e); continue
img = Image.new('RGB', (272, 30), (233, 233, 233))
d = ImageDraw.Draw(img)
d.text((6, 2), text, font=f, fill=(41, 55, 84))
rows.append((name, img))
scale = 3
W = 272 * scale
H = sum(r[1].height * scale + 6 for r in rows) + 10
out = Image.new('RGB', (W, H), (255, 255, 255))
y = 5
d2 = ImageDraw.Draw(out)
for name, im in rows:
im2 = im.resize((im.width*scale, im.height*scale), Image.LANCZOS)
out.paste(im2, (0, y))
d2.text((W-190, y+2), name, fill=(0, 0, 0))
y += im2.height + 6
out.save('/path/to/pf/KRD/font-candidates.png')
print('saved')
EOF