Skip to content

Instantly share code, notes, and snippets.

@bardware
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bardware/bc075434a2d4913cde9d to your computer and use it in GitHub Desktop.
Save bardware/bc075434a2d4913cde9d to your computer and use it in GitHub Desktop.
Convert a TTF font into WOFF, SVG and EOT format.
#!/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