mirror of
https://github.com/belluzj/fantasque-sans.git
synced 2024-12-22 23:41:30 +01:00
automate font generation
This commit is contained in:
parent
06adb7eefa
commit
757342a72c
25
Makefile
Normal file
25
Makefile
Normal 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
40
validate-generate.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user