2015-08-11 00:33:21 +02:00
|
|
|
#!/bin/bash
|
2015-11-14 23:50:16 +02:00
|
|
|
# version: 0.6.0
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# Check for Fontforge
|
|
|
|
type fontforge >/dev/null 2>&1 || {
|
|
|
|
echo >&2 "FontForge must be installed before running this script."
|
|
|
|
echo >&2 "Please see installation instructions at"
|
|
|
|
echo >&2 "http://designwithfontforge.com/en-US/Installing_Fontforge.html"
|
|
|
|
exit 1
|
|
|
|
}
|
2015-08-11 00:33:21 +02:00
|
|
|
|
|
|
|
# Set source and target directories
|
|
|
|
source_fonts_dir="${PWD}/unpatched-sample-fonts"
|
|
|
|
patched_fonts_dir="${PWD}/patched-fonts"
|
|
|
|
like_pattern=''
|
2015-11-14 23:49:18 +02:00
|
|
|
organizing_sub_dir=""
|
2015-08-11 00:33:21 +02:00
|
|
|
|
|
|
|
if [ $# -eq 1 ]
|
|
|
|
then
|
|
|
|
like_pattern=$1
|
|
|
|
echo "Parameter given, limiting search and patch to pattern '$like_pattern' given"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# correct way to output find results into an array (when files have space chars, etc)
|
|
|
|
# source: http://stackoverflow.com/questions/8213328/bash-script-find-output-to-array
|
|
|
|
source_fonts=()
|
|
|
|
while IFS= read -d $'\0' -r file ; do
|
|
|
|
source_fonts=("${source_fonts[@]}" "$file")
|
2015-09-02 22:14:55 +02:00
|
|
|
done < <(find "$source_fonts_dir" -name "$like_pattern*.[o,t]tf" -type f -print0)
|
2015-08-11 00:33:21 +02:00
|
|
|
|
|
|
|
# print total number of source fonts found
|
|
|
|
echo "Total source fonts found: ${#source_fonts[*]}"
|
|
|
|
|
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
function patch_font {
|
|
|
|
local f=$1; shift
|
|
|
|
fontforge -script ./font-patcher "$@" "$f"
|
|
|
|
printf "\n---------------\n"
|
|
|
|
local newly_created_font=$(find . -maxdepth 1 -name '*.[o,t]tf')
|
2015-09-19 16:56:38 +02:00
|
|
|
echo "Newly created font: $newly_created_font"
|
2015-09-02 22:14:55 +02:00
|
|
|
local patched_font_dir="${f%/*}/"
|
2015-11-14 23:49:18 +02:00
|
|
|
echo "patched font dir is $patched_font_dir"
|
2015-09-02 22:14:55 +02:00
|
|
|
local patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
|
2015-11-14 23:49:18 +02:00
|
|
|
echo "patched font dir is $patched_font_dir"
|
|
|
|
local patched_font_dir+=$organizing_sub_dir
|
|
|
|
echo "patched font dir is $patched_font_dir"
|
2015-09-02 22:14:55 +02:00
|
|
|
[[ -d "$patched_font_dir" ]] || mkdir -p "$patched_font_dir"
|
2015-09-19 16:56:38 +02:00
|
|
|
mkdir -p $patched_font_dir
|
2015-09-02 22:14:55 +02:00
|
|
|
mv "$newly_created_font" "$patched_font_dir"
|
2015-09-19 16:56:38 +02:00
|
|
|
echo "Moved newly created font to: $patched_font_dir"
|
2015-09-02 22:14:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function patch_font_batch {
|
|
|
|
patch_font "$@" -q
|
|
|
|
patch_font "$@" -q -s
|
|
|
|
patch_font "$@" -q -w
|
|
|
|
patch_font "$@" -q -s -w
|
|
|
|
}
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-19 02:30:35 +02:00
|
|
|
#cd temp-generated-fonts/
|
|
|
|
|
2015-08-11 00:33:21 +02:00
|
|
|
# Use for loop iterate through source fonts
|
|
|
|
# $f stores current value
|
|
|
|
for f in "${source_fonts[@]}"
|
|
|
|
do
|
2015-09-02 22:21:13 +02:00
|
|
|
echo "$f"
|
2015-11-14 23:49:18 +02:00
|
|
|
if [[ "$f" =~ Hack ]] || [[ "$f" =~ SourceCodePro ]]
|
2015-09-02 22:21:13 +02:00
|
|
|
then
|
|
|
|
powerline=""
|
|
|
|
else
|
|
|
|
powerline="--powerline"
|
|
|
|
fi
|
|
|
|
|
2015-11-14 23:49:18 +02:00
|
|
|
organizing_sub_dir="minimal/"
|
|
|
|
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-11-14 23:49:18 +02:00
|
|
|
organizing_sub_dir="additional-variations/"
|
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# font awesome variations
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline --fontawesome
|
2015-11-14 23:49:18 +02:00
|
|
|
patch_font_batch "$f" $powerline --fontawesome --powerlineextra
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# octicons variations:
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline --octicons
|
2015-11-14 23:49:18 +02:00
|
|
|
patch_font_batch "$f" $powerline --octicons --powerlineextra
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# pomicon variations:
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline --pomicons
|
2015-11-14 23:49:18 +02:00
|
|
|
patch_font_batch "$f" $powerline --pomicons --powerlineextra
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# fontawesome + octicons variations:
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline --fontawesome --octicons
|
2015-11-14 23:49:18 +02:00
|
|
|
patch_font_batch "$f" $powerline --fontawesome --octicons --powerlineextra
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# fontawesome + pomicons variations:
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline --fontawesome --pomicons
|
2015-11-14 23:49:18 +02:00
|
|
|
patch_font_batch "$f" $powerline --fontawesome --pomicons --powerlineextra
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# octicons + pomicons variations:
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline --octicons --pomicons
|
2015-11-14 23:49:18 +02:00
|
|
|
patch_font_batch "$f" $powerline --octicons --pomicons --powerlineextra
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# fontawesome + octicons + pomicons variations:
|
2015-09-02 22:21:13 +02:00
|
|
|
patch_font_batch "$f" $powerline --fontawesome --octicons --pomicons
|
2015-08-11 00:33:21 +02:00
|
|
|
|
2015-11-14 23:49:18 +02:00
|
|
|
organizing_sub_dir="complete/"
|
|
|
|
|
|
|
|
# fontawesome + octicons + pomicons + powerlineextra variations:
|
|
|
|
patch_font_batch "$f" $powerline --fontawesome --octicons --pomicons --powerlineextra
|
|
|
|
|
2015-09-02 22:14:55 +02:00
|
|
|
# un-comment to test this script (patch 1 font)
|
|
|
|
#break
|
2015-08-11 00:33:21 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
echo "All unpatched fonts re-patched to their respective sub-directories in $patched_fonts_dir"
|