Visitar URL original
Add Build TTF script · feathericons/feather@e972bad · GitHub
Skip to content

Commit e972bad

Browse files
committed
Add Build TTF script
1 parent 8263ca9 commit e972bad

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

‎bin/build-ttf.sh‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# Taken from https://github.com/feathericons/feather/pull/608/files
4+
5+
# This script uses:
6+
# - Inkscape to convert every icon from strokes to paths
7+
# - Fontcustom to convert all svg icons to TTF font
8+
# - GNU Parallel to speedup process
9+
# - Xvfb (X11 virtual frame buffer) to prevent show Inkscape window for
10+
# every icon. Its not necessary, but highly recommended
11+
# First parameter is the output directory based on workdir wich should be ./../
12+
# ex.: (...)/bin/build-ttf.sh dist/font will generate TTF in (...)/dist/font
13+
# Some times, this script logs some Glib or Inkscape related errors to console.
14+
# Its normal, simple ignore
15+
16+
WORKDIR="$(cd "$(dirname "$0")/../" && pwd)"
17+
OUTDIR=$1
18+
if [[ -z $OUTDIR ]]; then
19+
printf "Please, inform output directory as first argument\n"
20+
exit 1
21+
fi
22+
OUTDIR="$WORKDIR/$OUTDIR"
23+
24+
rm -rf $OUTDIR && mkdir -p $OUTDIR
25+
26+
if [[ -z $XVFB ]]; then
27+
OS=`uname -s`
28+
if [[ $OS == "Darwin" ]]; then
29+
XVFB="/usr/X11/bin/Xvfb"
30+
elif [[ $OS == "Linux" ]]; then
31+
XVFB=`which Xvfb`
32+
fi
33+
fi
34+
35+
TEMPDIR=`mktemp -d -t feather.XXXXXXXXXX`
36+
CMD="parallel --bar inkscape -f {}\
37+
--verb=EditSelectAll\
38+
--verb=StrokeToPath\
39+
--verb=FileSave\
40+
--verb=FileQuit\
41+
::: $TEMPDIR/*.svg"
42+
43+
cp "$WORKDIR"/icons/* "$TEMPDIR"
44+
printf "TTF font will be generated on $OUTDIR using temp folder $TEMPDIR\n"
45+
if [[ -x $XVFB ]]; then
46+
$XVFB :2019 -screen 0 640x480x24 -nolisten tcp >> /dev/null 2>&1 &
47+
XVFBPID=$!
48+
DISPLAY=:2019 $CMD && kill -SIGTERM $XVFBPID
49+
else
50+
$CMD
51+
fi
52+
fontcustom compile $TEMPDIR -n Feather -o "$OUTDIR" -F -h
53+
rm -rf $TEMPDIR

0 commit comments

Comments
 (0)