14
0
mirror of https://github.com/belluzj/fantasque-sans.git synced 2024-12-22 15:31:31 +01:00

automate font generation

This commit is contained in:
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 Normal file
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)

40
validate-generate.sh Executable file
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