Skip to content

Instantly share code, notes, and snippets.

@bardware

bardware/ttf2webfont.sh

Last active Aug 29, 2015
Embed
What would you like to do?
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