mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-01-19 03:12:07 +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:
parent
b456bd8713
commit
b6e78d8c06
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# version: 0.8.0
|
# version: 0.9.0
|
||||||
|
|
||||||
# Check for Fontforge
|
# Check for Fontforge
|
||||||
type fontforge >/dev/null 2>&1 || {
|
type fontforge >/dev/null 2>&1 || {
|
||||||
@ -15,7 +15,11 @@ res1=$(date +%s)
|
|||||||
source_fonts_dir="${PWD}/unpatched-sample-fonts"
|
source_fonts_dir="${PWD}/unpatched-sample-fonts"
|
||||||
patched_fonts_dir="${PWD}/patched-fonts"
|
patched_fonts_dir="${PWD}/patched-fonts"
|
||||||
like_pattern=''
|
like_pattern=''
|
||||||
organizing_sub_dir=""
|
complete_variation_count=0
|
||||||
|
total_variation_count=0
|
||||||
|
total_count=0
|
||||||
|
last_parent_dir=""
|
||||||
|
|
||||||
|
|
||||||
if [ $# -eq 1 ]
|
if [ $# -eq 1 ]
|
||||||
then
|
then
|
||||||
@ -36,33 +40,21 @@ echo "Total source fonts found: ${#source_fonts[*]}"
|
|||||||
|
|
||||||
function patch_font {
|
function patch_font {
|
||||||
local f=$1; shift
|
local f=$1; shift
|
||||||
local organizing_sub_dir=$1; shift
|
|
||||||
# take everything before the last slash (/) to start building the full path
|
# take everything before the last slash (/) to start building the full path
|
||||||
local patched_font_dir="${f%/*}/"
|
local patched_font_dir="${f%/*}/"
|
||||||
printf "\n---------------\n"
|
printf "\n---------------\n\n"
|
||||||
local patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
|
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
|
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"
|
[[ -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_parent_dir=$( cd "$( dirname "$f" )" && cd ".." && pwd)
|
||||||
config_dir=$( cd "$( dirname "$f" )" && pwd)
|
config_dir=$( cd "$( dirname "$f" )" && pwd)
|
||||||
|
|
||||||
|
echo "config parent dir is $config_parent_dir"
|
||||||
|
|
||||||
# source the font config file if exists:
|
# source the font config file if exists:
|
||||||
if [ -f "$config_dir/config.cfg" ]
|
if [ -f "$config_dir/config.cfg" ]
|
||||||
then
|
then
|
||||||
@ -75,61 +67,59 @@ do
|
|||||||
if [ $config_has_powerline ]
|
if [ $config_has_powerline ]
|
||||||
then
|
then
|
||||||
powerline=""
|
powerline=""
|
||||||
|
combinations=$(printf "./font-patcher ${f##*/} %s\n" {' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
|
||||||
else
|
else
|
||||||
powerline="--powerline"
|
powerline="--powerline"
|
||||||
|
combinations=$("./font-patcher ${f##*/} %s\n" {' --powerline',}{' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
|
||||||
fi
|
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
|
complete_variation_count=$((complete_variation_count+3))
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome &
|
combination_count=$(printf "$combinations" | wc -l)
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --powerlineextra &
|
|
||||||
|
|
||||||
# octicons variations:
|
# generate the readmes:
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --octicons &
|
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --octicons --powerlineextra &
|
|
||||||
|
|
||||||
# font linux variations:
|
# if first time with this font then re-build parent dir readme, else skip:
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux &
|
if [[ $config_parent_dir != $last_parent_dir ]];
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux --powerlineextra &
|
then
|
||||||
|
echo "Re-generate parent directory readme"
|
||||||
|
generate_readme "$patched_font_dir/.."
|
||||||
|
fi
|
||||||
|
|
||||||
# pomicon variations:
|
generate_readme $patched_font_dir
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --pomicons &
|
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --pomicons --powerlineextra &
|
|
||||||
|
|
||||||
# fontawesome + octicons variations:
|
last_parent_dir=$config_parent_dir
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --octicons &
|
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --octicons --powerlineextra &
|
|
||||||
|
|
||||||
# fontawesome + pomicons variations:
|
total_variation_count=$((combination_count))
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --pomicons &
|
total_count=$((complete_variation_count+combination_count))
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --pomicons --powerlineextra &
|
|
||||||
|
|
||||||
# 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:
|
# Re-generate all the readmes
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux --pomicons &
|
# $1 = fontdir path
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontlinux --pomicons --powerlineextra &
|
function generate_readme {
|
||||||
|
patched_font_dir=$1
|
||||||
|
combinations_filename="$patched_font_dir/readme.md"
|
||||||
|
|
||||||
# octicons + pomicons variations:
|
cat $patched_font_dir/font-info.md > $combinations_filename
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --octicons --pomicons &
|
cat $PWD/source/readme-per-directory-variations.md >> $combinations_filename
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --octicons --pomicons --powerlineextra &
|
|
||||||
|
|
||||||
# octicons + fontlinux variations:
|
printf "\`\`\`sh" >> $combinations_filename
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --octicons --fontlinux &
|
printf "\n# $combination_count Possible Combinations:\n" >> $combinations_filename
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --octicons --fontlinux --powerlineextra &
|
printf "\n" >> $combinations_filename
|
||||||
|
printf "$combinations" >> $combinations_filename
|
||||||
# fontawesome + octicons + pomicons variations:
|
printf "\n" >> $combinations_filename
|
||||||
patch_font_batch "$f" "additional-variations/" $powerline --fontawesome --octicons --pomicons &
|
printf "\`\`\`" >> $combinations_filename
|
||||||
|
}
|
||||||
# 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 &
|
|
||||||
|
|
||||||
|
# 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)
|
# un-comment to test this script (patch 1 font)
|
||||||
#break
|
#break
|
||||||
@ -151,3 +141,6 @@ ds=$(echo "$dt3-60*$dm" | bc)
|
|||||||
printf "Total runtime: %d:%02d:%02d:%02d\n" $dd $dh $dm $ds
|
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 "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"
|
||||||
|
@ -1,37 +1,67 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# version: 0.8.0
|
# version: 0.9.0
|
||||||
# Iterates over all patched fonts directories
|
# Iterates over all patched fonts directories
|
||||||
# converts all non markdown readmes to markdown (e.g. txt, rst) using pandoc
|
# converts all non markdown readmes to markdown (e.g., txt, rst) using pandoc
|
||||||
# adds information on minimal, alternative, and complete font variations
|
# 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 ./DejaVuSansMono -type d | # uncomment to test 1 font
|
||||||
find -type d | # uncomment to do ALL fonts
|
find -type d | # uncomment to do ALL fonts
|
||||||
while read filename
|
while read filename
|
||||||
do
|
do
|
||||||
echo "$filename" # ... or any other command using $filename
|
|
||||||
RST=( $(find $filename -type f -iname 'readme.rst' -exec basename {} \;) )
|
#echo "filename $filename"
|
||||||
TXT=( $(find $filename -type f -iname 'readme.txt' -exec basename {} \;) )
|
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 $RST
|
echo $RST
|
||||||
echo "end"
|
echo "end"
|
||||||
|
#exit
|
||||||
|
|
||||||
|
# clear output file (needed for multiple runs or updates):
|
||||||
|
> $outputlocation
|
||||||
|
|
||||||
if [ $RST ];
|
if [ $RST ];
|
||||||
then
|
then
|
||||||
|
echo "pwd/filename $PWD/$filename"
|
||||||
echo "found RST"
|
echo "found RST"
|
||||||
pandoc "$filename/$RST" --from=rst --to=markdown --output=$filename/README.md
|
pandoc "$PWD/$searchdir/$RST" --from=rst --to=markdown --output=$outputlocation
|
||||||
echo "pandoc $filename/$RST --from=rst --to=markdown --output=$filename/README.md"
|
#echo "pandoc $PWD/$filename/$RST --from=rst --to=markdown --output=$outputlocation"
|
||||||
echo "pwd $PWD"
|
#echo "pwd $PWD"
|
||||||
cat $PWD/../source/readme-per-directory-addendum.md >> $filename/README.md
|
cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation
|
||||||
elif [ $TXT ];
|
elif [ $TXT ];
|
||||||
then
|
then
|
||||||
|
echo "pwd/filename $PWD/$searchdir"
|
||||||
echo "found TXT"
|
echo "found TXT"
|
||||||
echo "nothing to do for conversion, just copy as markdown"
|
echo "nothing to do for conversion, just copy as markdown"
|
||||||
cp $filename/$TXT $filename/README.md
|
cp $PWD/$searchdir/$TXT $outputlocation
|
||||||
echo "pwd $PWD"
|
#echo "pwd $PWD"
|
||||||
cat $PWD/../source/readme-per-directory-addendum.md >> $filename/README.md
|
cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation
|
||||||
else
|
else
|
||||||
|
echo "pwd/filename $PWD/$searchdir"
|
||||||
|
# else doesnt copy parent dir. somehow do this...
|
||||||
echo "did not find RST nor TXT"
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user