Last active
August 29, 2015 14:07
-
-
Save bardware/bc075434a2d4913cde9d to your computer and use it in GitHub Desktop.
Convert a TTF font into WOFF, SVG and EOT format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://gist.github.com/rc1/5346303 | |
# Convert a TTF font into WOFF, SVG and EOT format. | |
# @source: http://stackoverflow.com/a/2467452/179015 | |
# @usage: ttf2webfont.sh FontName | |
woffFont="$1.woff" | |
svgFont_tmp="$1_tmp.svg" | |
svgFont="$1.svg" | |
ttfFont="$1.ttf" | |
eotFont="$1.eot" | |
# sudo aptitude install fontforge | |
fontforge -lang=ff -c ' | |
Open("'$ttfFont'"); | |
Generate("'$woffFont'"); | |
RemoveAllKerns(); | |
Generate("'$svgFont_tmp'"); | |
Quit(0)' | |
# ttf2eot compiled myself | |
# Source: https://code.google.com/p/ttf2eot/ | |
# Patch: https://code.google.com/p/ttf2eot/issues/detail?id=29 | |
~/src/ttf2eot-0.0.2-2/ttf2eot $ttfFont > $eotFont | |
if [[ -f $svgFont_tmp ]] | |
then | |
# cleans and shrinks svg file | |
# sudo aptitude install python-scour | |
python /usr/share/pyshared/scour.py --indent=none --remove-metadata --quiet -i $svgFont_tmp -o $svgFont | |
rm $svgFont_tmp | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment