#!/usr/bin/env bash # Generate font files with FontForge, and a CSS declaration for this font. if ! type fontforge &> /dev/null; then echo "ERROR: Missing dependency: fontforge" 1>&2; exit 1; fi basename=$1 ttf="${basename}.ttf" otf="OTF/${basename}.otf" echo -e "\e[1;37mGenerating ${basename}... \e[0m" output=$(fontforge -lang=py -script - < Webfonts/${basename}-decl.css <= 3.6, any other modern browser */ url('${basename}.ttf') format('truetype'), /* Safari, Android, iOS */ url('${basename}.svg#${fontname}') format('svg'); /* Chrome < 4, Legacy iOS */ font-weight: ${fontweight}; font-style: ${fontstyle}; } EOF 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