automate font generation

prop
Jany Belluz 2013-11-27 21:47:39 +01:00
parent 06adb7eefa
commit 757342a72c
3 changed files with 65 additions and 5 deletions

25
Makefile 100644
View File

@ -0,0 +1,25 @@
BASENAMES=$(patsubst Sources/%.sfd,%,$(wildcard Sources/*.sfd))
TTF_FILES=$(patsubst %,%.ttf,$(BASENAMES))
TTF_HINTED_FILES=$(patsubst %,%-autohint.ttf,$(BASENAMES))
OTF_FILES=$(patsubst %,OTF/%.otf,$(BASENAMES))
all: zip
OTF/%.otf %.ttf: Sources/%.sfd
./validate-generate.sh $*
%-autohint.ttf: %.ttf
# TODO determine perfect parameters
ttfautohint $< $@
.PHONY: install clean zip
install: $(TTF_FILES)
cp $^ ~/.fonts/
fc-cache -f
zip: $(TTF_FILES) $(TTF_HINTED_FILES) $(OTF_FILES)
zip CosmicSansNeueMono.zip OFL.txt README.md $^
clean:
rm $(TTF_FILES) $(TTF_HINTED_FILES) $(OTF_FILES)

View File

@ -0,0 +1,40 @@
#!/bin/bash
basename=$1
ttf="${basename}.ttf"
otf="OTF/${basename}.otf"
echo -e "\e[1;37mGenerating ${basename}... \e[0m"
if [ -f "$ttf" ]; then
rm "$ttf"
fi
if [ -f "$otf" ]; then
rm "$otf"
fi
fontforge -lang=py -script - <<EOF
import fontforge;
font = fontforge.open("Sources/${basename}.sfd");
bitmask = font.validate();
if bitmask != 0:
exit(42);
font.generate("${basename}.ttf");
font.generate("OTF/${basename}.otf");
EOF
error=$?
if [ "x$error" != "x0" ]; then
echo -e "\e[1;31mError in ${basename}.\e[0m"
if [ "x$error" = "x42" ]; then
echo "Font ${basename}.sfd is not valid"
fi
else
echo -e "\e[1;32m${basename} OK.\e[0m"
fi
exit $error

5
zip.sh
View File

@ -1,5 +0,0 @@
#!/bin/sh
zip CosmicSansNeueMono.zip OFL.txt README.md CosmicSansNeueMono.ttf CosmicSansNeueMonoBold.ttf OTF/CosmicSansNeueMonoBold.otf OTF/CosmicSansNeueMono.otf Sources/CosmicSansNeueMono.sfd Sources/CosmicSansNeueMonoBold.sfd