1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-12-31 21:22:38 +02:00

Updates scripts drastically

* no longer generate patched fonts for every variation (not worth doing by default)
* generates better readme info
* provides counts for patch variations and total patches
* generates example commands that a user can use to generate variations on their own
This commit is contained in:
Ryan L McIntyre 2016-10-29 00:59:32 -04:00
parent b456bd8713
commit b6e78d8c06
2 changed files with 98 additions and 75 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
# version: 0.8.0
# version: 0.9.0
# Check for Fontforge
type fontforge >/dev/null 2>&1 || {
@ -15,7 +15,11 @@ res1=$(date +%s)
source_fonts_dir="${PWD}/unpatched-sample-fonts"
patched_fonts_dir="${PWD}/patched-fonts"
like_pattern=''
organizing_sub_dir=""
complete_variation_count=0
total_variation_count=0
total_count=0
last_parent_dir=""
if [ $# -eq 1 ]
then
@ -36,33 +40,21 @@ echo "Total source fonts found: ${#source_fonts[*]}"
function patch_font {
local f=$1; shift
local organizing_sub_dir=$1; shift
# take everything before the last slash (/) to start building the full path
local patched_font_dir="${f%/*}/"
printf "\n---------------\n"
printf "\n---------------\n\n"
local patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
echo "patched font dir is $patched_font_dir"
#echo "patched font dir is $patched_font_dir"
local patched_font_dir+=$organizing_sub_dir
echo "patched font dir is $patched_font_dir"
#echo "patched font dir is $patched_font_dir"
[[ -d "$patched_font_dir" ]] || mkdir -p "$patched_font_dir"
fontforge -quiet -script ./font-patcher "$@" "$f" --outputdir $patched_font_dir 2>/dev/null
}
#fontforge -quiet -script ./font-patcher "$@" "$f" --outputdir $patched_font_dir 2>/dev/null
function patch_font_batch {
patch_font "$@" -q
patch_font "$@" -q -s
patch_font "$@" -q -w
patch_font "$@" -q -s -w
}
# Use for loop iterate through source fonts
# $f stores current value
for f in "${source_fonts[@]}"
do
echo "$f"
config_parent_dir=$( cd "$( dirname "$f" )" && cd ".." && pwd)
config_dir=$( cd "$( dirname "$f" )" && pwd)
echo "config parent dir is $config_parent_dir"
# source the font config file if exists:
if [ -f "$config_dir/config.cfg" ]
then
@ -75,61 +67,59 @@ do
if [ $config_has_powerline ]
then
powerline=""
combinations=$(printf "./font-patcher ${f##*/} %s\n" {' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
else
powerline="--powerline"
combinations=$("./font-patcher ${f##*/} %s\n" {' --powerline',}{' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
fi
patch_font_batch "$f" "minimal/" $powerline &
fontforge -quiet -script ./font-patcher "$f" -q -s $powerline --complete --outputdir $patched_font_dir"complete/" 2>/dev/null
fontforge -quiet -script ./font-patcher "$f" -q -w $powerline --complete --outputdir $patched_font_dir"complete/" 2>/dev/null
fontforge -quiet -script ./font-patcher "$f" -q -s -w $powerline --complete --outputdir $patched_font_dir"complete/" 2>/dev/null
# font awesome variations
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome &
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --powerlineextra &
complete_variation_count=$((complete_variation_count+3))
combination_count=$(printf "$combinations" | wc -l)
# octicons variations:
patch_font_batch "$f" "additional-variations/" $powerline --octicons &
patch_font_batch "$f" "additional-variations/" $powerline --octicons --powerlineextra &
# generate the readmes:
# font linux variations:
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux &
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux --powerlineextra &
# if first time with this font then re-build parent dir readme, else skip:
if [[ $config_parent_dir != $last_parent_dir ]];
then
echo "Re-generate parent directory readme"
generate_readme "$patched_font_dir/.."
fi
# pomicon variations:
patch_font_batch "$f" "additional-variations/" $powerline --pomicons &
patch_font_batch "$f" "additional-variations/" $powerline --pomicons --powerlineextra &
generate_readme $patched_font_dir
# fontawesome + octicons variations:
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --octicons &
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --octicons --powerlineextra &
last_parent_dir=$config_parent_dir
# fontawesome + pomicons variations:
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --pomicons &
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --pomicons --powerlineextra &
total_variation_count=$((combination_count))
total_count=$((complete_variation_count+combination_count))
# fontawesome + fontlinux variations:
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --fontlinux &
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --fontlinux --powerlineextra &
}
# fontlinux + pomicons variations:
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux --pomicons &
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux --pomicons --powerlineextra &
# Re-generate all the readmes
# $1 = fontdir path
function generate_readme {
patched_font_dir=$1
combinations_filename="$patched_font_dir/readme.md"
# octicons + pomicons variations:
patch_font_batch "$f" "additional-variations/" $powerline --octicons --pomicons &
patch_font_batch "$f" "additional-variations/" $powerline --octicons --pomicons --powerlineextra &
cat $patched_font_dir/font-info.md > $combinations_filename
cat $PWD/source/readme-per-directory-variations.md >> $combinations_filename
# octicons + fontlinux variations:
patch_font_batch "$f" "additional-variations/" $powerline --octicons --fontlinux &
patch_font_batch "$f" "additional-variations/" $powerline --octicons --fontlinux --powerlineextra &
# fontawesome + octicons + pomicons variations:
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --octicons --pomicons &
# fontawesome + octicons + pomicons + fontlinux variations:
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --octicons --pomicons --fontlinux &
# fontawesome + octicons + pomicons + powerlineextra variations (aka Complete):
patch_font_batch "$f" "complete/" $powerline --fontawesome --octicons --pomicons --powerlineextra --fontlinux &
printf "\`\`\`sh" >> $combinations_filename
printf "\n# $combination_count Possible Combinations:\n" >> $combinations_filename
printf "\n" >> $combinations_filename
printf "$combinations" >> $combinations_filename
printf "\n" >> $combinations_filename
printf "\`\`\`" >> $combinations_filename
}
# Use for loop iterate through source fonts
# $f stores current value
for f in "${source_fonts[@]}"
do
patch_font "$f" &
# un-comment to test this script (patch 1 font)
#break
@ -151,3 +141,6 @@ ds=$(echo "$dt3-60*$dm" | bc)
printf "Total runtime: %d:%02d:%02d:%02d\n" $dd $dh $dm $ds
echo "All unpatched fonts re-patched to their respective sub-directories in $patched_fonts_dir"
echo "The total number of 'variation' patched fonts created was $total_variation_count"
echo "The total number of 'complete' patched fonts created was $complete_variation_count"
echo "The total number of patched fonts created was $total_count"

View File

@ -1,37 +1,67 @@
#!/bin/bash
# version: 0.8.0
# version: 0.9.0
# Iterates over all patched fonts directories
# converts all non markdown readmes to markdown (e.g. txt, rst) using pandoc
# adds information on minimal, alternative, and complete font variations
# converts all non markdown readmes to markdown (e.g., txt, rst) using pandoc
# adds information on additional-variations and complete font variations
cd patched-fonts/
infofilename="font-info.md"
cd unpatched-sample-fonts/
#find ./DejaVuSansMono -type d | # uncomment to test 1 font
find -type d | # uncomment to do ALL fonts
while read filename
do
echo "$filename" # ... or any other command using $filename
RST=( $(find $filename -type f -iname 'readme.rst' -exec basename {} \;) )
TXT=( $(find $filename -type f -iname 'readme.txt' -exec basename {} \;) )
#echo "filename $filename"
dirname=`dirname $filename`
basename=`basename $filename`
echo "dirname $dirname"
echo "basename $basename"
searchdir=$filename
# limit looking for the readme files in the parent dir not the child dirs:
if [[ $dirname != "." ]];
then
echo "look up a lvl"
searchdir=$dirname
fi
RST=( $(find $searchdir -type f -iname 'readme.rst' -exec basename {} \;) )
TXT=( $(find $searchdir -type f -iname 'readme.txt' -exec basename {} \;) )
outputdir=$PWD/../patched-fonts/$filename/
outputlocation=$outputdir/$infofilename
[[ -d "$outputdir" ]] || mkdir -p "$outputdir"
echo "RST:"
echo $RST
echo "end"
#exit
# clear output file (needed for multiple runs or updates):
> $outputlocation
if [ $RST ];
then
echo "pwd/filename $PWD/$filename"
echo "found RST"
pandoc "$filename/$RST" --from=rst --to=markdown --output=$filename/README.md
echo "pandoc $filename/$RST --from=rst --to=markdown --output=$filename/README.md"
echo "pwd $PWD"
cat $PWD/../source/readme-per-directory-addendum.md >> $filename/README.md
pandoc "$PWD/$searchdir/$RST" --from=rst --to=markdown --output=$outputlocation
#echo "pandoc $PWD/$filename/$RST --from=rst --to=markdown --output=$outputlocation"
#echo "pwd $PWD"
cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation
elif [ $TXT ];
then
echo "pwd/filename $PWD/$searchdir"
echo "found TXT"
echo "nothing to do for conversion, just copy as markdown"
cp $filename/$TXT $filename/README.md
echo "pwd $PWD"
cat $PWD/../source/readme-per-directory-addendum.md >> $filename/README.md
cp $PWD/$searchdir/$TXT $outputlocation
#echo "pwd $PWD"
cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation
else
echo "pwd/filename $PWD/$searchdir"
# else doesnt copy parent dir. somehow do this...
echo "did not find RST nor TXT"
cat $PWD/../source/readme-per-directory-addendum.md >> $filename/README.md
cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation
fi
done