Made a ton prettier, still need to regenerate examples
1
Makefile
|
@ -2,4 +2,3 @@ all:
|
||||||
rm -rf out||:
|
rm -rf out||:
|
||||||
mkdir out
|
mkdir out
|
||||||
python3 test.py
|
python3 test.py
|
||||||
rm /tmp/*.ttf||:
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/usr/local/bin/fontforge
|
|
||||||
# Quick and dirty hack: converts a font to truetype (.ttf)
|
|
||||||
Print("Opening "+$1);
|
|
||||||
Open($1);
|
|
||||||
Print("Saving "+"/tmp/" + $2);
|
|
||||||
Generate("/tmp/" + $2);
|
|
||||||
Quit(0);
|
|
Before Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 169 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 108 KiB |
Before Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 167 KiB |
Before Width: | Height: | Size: 234 KiB |
Before Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 166 KiB |
Before Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 120 KiB |
Before Width: | Height: | Size: 238 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 103 KiB |
Before Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 236 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 234 KiB |
Before Width: | Height: | Size: 166 KiB |
Before Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 108 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 173 KiB |
Before Width: | Height: | Size: 96 KiB |
Before Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 82 KiB |
|
@ -0,0 +1,42 @@
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
import subprocess
|
||||||
|
def getFontName(font, extra = False):
|
||||||
|
result = font.split("/")[-2]
|
||||||
|
if result == "tmp":
|
||||||
|
return font.split("/")[-1]
|
||||||
|
if extra:
|
||||||
|
result += "-" + font.split("/")[-1]
|
||||||
|
return result
|
||||||
|
i=0
|
||||||
|
null = open("/dev/null", "w")
|
||||||
|
print(" ".join(["find", "/home/niles/Documents/fonts", "-type", "f", "-iregex", ".*\\.ttf|.*\\.otf"]))
|
||||||
|
fonts = subprocess.check_output(["find", "/home/niles/Documents/fonts", "-type", "f", "-iregex", ".*\\.\(ttf\|otf\)"]).decode("utf-8").split("\n")[:-1]
|
||||||
|
i = 0
|
||||||
|
for font in fonts:
|
||||||
|
i+=1
|
||||||
|
print("Generating " + str(i) + getFontName(font, True))
|
||||||
|
try:
|
||||||
|
txt = Image.new('RGBA', (2000, 2400), (211,141,95, 255))
|
||||||
|
#txt.putpixel((x, y), (255, 127, 42, 255))
|
||||||
|
d = ImageDraw.Draw(txt)
|
||||||
|
d.rectangle([(0, 1600), (2000, 2400)], (255, 127, 42, 255))
|
||||||
|
fnt = ImageFont.truetype(font, 200)
|
||||||
|
d.text((100,110), getFontName(font, True), font=fnt, fill=(0,0,0,255))
|
||||||
|
fnt = ImageFont.truetype(font, 300)
|
||||||
|
d.text((50,450), "Aa Ee Rr", font=fnt, fill=(0,0,0,255))
|
||||||
|
fnt = ImageFont.truetype(font, 300)
|
||||||
|
d.text((50,750), "Aa Ee Rr", font=fnt, fill=(0,0,0,255))
|
||||||
|
fnt = ImageFont.truetype(font, 800)
|
||||||
|
d.text((1500,300), "a", font=fnt, fill=(255,255,255,255))
|
||||||
|
fnt = ImageFont.truetype(font, 200)
|
||||||
|
d.text((100,1200), "The brown fox jumps over the lazy red dog or something", font=fnt, fill=(0,0,0,255))
|
||||||
|
fnt = ImageFont.truetype(font, 180)
|
||||||
|
d.text((100,1700), "abcdefghijklm", font=fnt, fill=(0,0,0,255))
|
||||||
|
d.text((100,1900), "nopqrstuvwxyz", font=fnt, fill=(0,0,0,255))
|
||||||
|
fnt = ImageFont.truetype(font, 250)
|
||||||
|
d.text((450,2100), "0123456789", font=fnt, fill=(255,255,255,255))
|
||||||
|
out = txt#Image.alpha_composite(base, txt)
|
||||||
|
out.save("out/" + str(i) + "-" + getFontName(font, True) + ".png")
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
print(traceback.format_exc())
|
33
test.py
|
@ -1,33 +0,0 @@
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
|
||||||
import subprocess
|
|
||||||
def getFontName(font, extra = False):
|
|
||||||
result = font.split("/")[-2]
|
|
||||||
if result == "tmp":
|
|
||||||
return font.split("/")[-1]
|
|
||||||
if extra:
|
|
||||||
result += "-" + font.split("/")[-1]
|
|
||||||
return result
|
|
||||||
i=0
|
|
||||||
null = open("/dev/null", "w")
|
|
||||||
fonts = subprocess.check_output(["find", "/home/niles/Downloads/fonts", "-type", "f", "-iname", "*.ttf"]).decode("utf-8").split("\n")[:-1]
|
|
||||||
for font in subprocess.check_output(["find", "/home/niles/Downloads/fonts", "-type", "f", "-iname", "*.otf"]).decode("utf-8").split("\n")[:-1]:
|
|
||||||
#prettyname = "-".join(font.split("/")[-2:]).replace(".otf", ".ttf")
|
|
||||||
prettyname = getFontName(font, True).replace(".otf", ".ttf")
|
|
||||||
print("Converting " + str(i) + " " + prettyname)
|
|
||||||
i += 1
|
|
||||||
subprocess.call(["fontforge", "-script", "convert_script.sh", font, prettyname], stderr=null, stdout=null)
|
|
||||||
fonts.append("/tmp/" + prettyname)
|
|
||||||
i = 0
|
|
||||||
for font in fonts:
|
|
||||||
i+=1
|
|
||||||
print("Generating " + str(i) + getFontName(font, True))
|
|
||||||
try:
|
|
||||||
txt = Image.new('RGBA', (2000, 400), (29,204,32, 255))
|
|
||||||
fnt = ImageFont.truetype(font, 150)
|
|
||||||
d = ImageDraw.Draw(txt)
|
|
||||||
d.text((10,10), getFontName(font, True), font=fnt, fill=(0,0,0,255))
|
|
||||||
d.text((10,10 + 150), "The brown fox jumps over the lazy red dog or something", font=fnt, fill=(0,0,0,255))
|
|
||||||
out = txt#Image.alpha_composite(base, txt)
|
|
||||||
out.save("out/" + str(i) + "-" + getFontName(font, True) + ".png")
|
|
||||||
except:
|
|
||||||
continue
|
|