14
0
mirror of https://github.com/belluzj/fantasque-sans.git synced 2024-12-22 23:41:30 +01:00
fantasque-sans/validate-generate.sh

59 lines
1.5 KiB
Bash
Raw Normal View History

2013-11-27 21:47:39 +01:00
#!/bin/bash
2013-12-22 13:49:16 +01:00
# Generate font files with FontForge, and a CSS declaration for this font.
2013-11-27 21:47:39 +01:00
basename=$1
ttf="${basename}.ttf"
otf="OTF/${basename}.otf"
texFamily="cm" # arbitrary two letters out of the font's name
2013-12-22 13:49:16 +01:00
texCut="r" # Regular
if [[ "${basename,,}" == *bold* ]]; then
texCut="b" # Bold
2013-11-27 21:47:39 +01:00
fi
echo -e "\e[1;37mGenerating ${basename}... \e[0m"
2013-11-27 21:47:39 +01:00
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");
2013-12-22 13:49:16 +01:00
font.generate("Webfonts/${basename}.svg");
# TeX stuff
font.encoding = "AdobeStandard";
font.generate("TeX/f${texFamily}${texCut}8a.pfb",
flags=("afm", "tfm", "pfm"));
2013-11-27 21:47:39 +01:00
EOF
2013-12-22 13:49:16 +01:00
cat > Webfonts/${basename}-decl.css <<EOF
@font-face {
font-family: '${basename}';
src: url('${basename}.eot'); /* IE 9 Compatibility Mode */
src: url('${basename}.eot?#iefix') format('embedded-opentype'), /* IE < 9 */
url('${basename}.woff') format('woff'), /* Firefox >= 3.6, any other modern browser */
url('${basename}.ttf') format('truetype'), /* Safari, Android, iOS */
url('${basename}.svg#${basename}') format('svg'); /* Chrome < 4, Legacy iOS */
}
EOF
2013-11-27 21:47:39 +01:00
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