Made a ton prettier, still need to regenerate examples

This commit is contained in:
Niles Rogoff 2016-10-12 16:59:40 -04:00
parent f61106d82a
commit e04e7eb688
66 changed files with 42 additions and 41 deletions

View File

@ -2,4 +2,3 @@ all:
rm -rf out||:
mkdir out
python3 test.py
rm /tmp/*.ttf||:

View File

@ -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);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

42
generate.py Normal file
View File

@ -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
View File

@ -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