mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-01-25 03:32:02 +02:00
gotta-patch-em-all: Add options to simplify patcher testing
[why] When working on the font-patcher the developer needs to test the changes on a number of fonts. This is usually a manual call of `font-patcher` and afterwards a 'diff' of the newly created font with the 'old' font in the patched-fonts/ directory with fontforge (which has a font-compare option). If you run gotta-patch-em-all normally the newly generated font will replace the existing font and git will ALWAYS show it as different. The reason is that at least the timestamp in the generated font has changed. Far more easy would be if the new gotta-patch-em-all run could keep the previous timestamps, in that way one can immediately see that the old and new fonts are bitwise equal (via git). Furthermore if you expect a change and want to show the differences of old and new font in fontforge you need both fonts in the filesystem. But a normal gotta-patch-em-all run replaces the font. A different destination folder would help here. [how] Introduce two new (independent) options to a) keep the timestamp equal to previous patch run b) generate the fonts in a different directory While b) is straight forward, a) is a bit more complicated, esp because filenames can change and so on. So the script examines just one (1) random font in the specific font directory and uses its timestamp. In most cases this is correct enough if the developer uses gotta-patch-em-all consequently. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
40ded7c2f0
commit
3c4fa008c1
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
temp-glyph-source-fonts/*
|
||||
temp/*
|
||||
patched-fonts/Input*
|
||||
check-fonts/*
|
||||
unpatched-sample-fonts/Input*
|
||||
casks/*
|
||||
archives/*
|
||||
|
@ -32,40 +32,80 @@ total_count=0
|
||||
last_parent_dir=""
|
||||
unpatched_parent_dir="bin/scripts/../../src/unpatched-fonts"
|
||||
patched_parent_dir="patched-fonts"
|
||||
timestamp_parent_dir=${patched_parent_dir}
|
||||
max_parallel_process=64
|
||||
|
||||
while getopts ":h-:" option; do
|
||||
function activate_keeptime {
|
||||
type ttfdump >/dev/null 2>&1 || {
|
||||
echo >&2 "$LINE_PREFIX ttfdump must be installed for option --keeptime"
|
||||
exit 1
|
||||
}
|
||||
keeptime=TRUE
|
||||
}
|
||||
|
||||
function activate_checkfont {
|
||||
patched_parent_dir="check-fonts"
|
||||
}
|
||||
|
||||
function activate_info {
|
||||
info_only=$2
|
||||
echo "${LINE_PREFIX} 'Info Only' option given, only generating font info (not patching)"
|
||||
}
|
||||
|
||||
function show_help {
|
||||
echo "Usage: $0 [OPTION] [FILTER]"
|
||||
echo
|
||||
echo " OPTION:"
|
||||
echo " -c, --checkfont Create the font(s) in check-fonts/ instead"
|
||||
echo " -t, --keeptime Try to preserve timestamp of previously patched"
|
||||
echo " font in patched-fonts/ directory"
|
||||
echo " -i, --info Rebuild JUST the readmes"
|
||||
echo " -h, --help Show this help"
|
||||
echo
|
||||
echo " FILTER:"
|
||||
echo " The filter argument to this script is a filter for the fonts to patch."
|
||||
echo " The filter is a regex (glob "*" is expressed as "[^/]*", see \`man 7 glob\`)"
|
||||
echo " All font files that start with that filter (and are ttf, otf, or sfd files) will"
|
||||
echo " be processed only."
|
||||
echo " Example ./gotta-patch-em-all-font-patcher\!.sh \"iosevka\""
|
||||
echo " Process all font files that start with \"iosevka\""
|
||||
echo " If the argument starts with a '/' all font files in a directory that matches"
|
||||
echo " the filter are processed only."
|
||||
echo " Example ./gotta-patch-em-all-font-patcher\!.sh \"/iosevka\""
|
||||
echo " Process all font files that are in directory \"iosevka\""
|
||||
}
|
||||
|
||||
while getopts ":chit-:" option; do
|
||||
case "${option}" in
|
||||
c)
|
||||
activate_checkfont
|
||||
;;
|
||||
h)
|
||||
echo "Usage: $0 [OPTION] [FILTER]"
|
||||
echo
|
||||
echo " OPTION:"
|
||||
echo " --info Rebuild JUST the readmes"
|
||||
echo
|
||||
echo " FILTER:"
|
||||
echo " The filter argument to this script is a filter for the fonts to patch."
|
||||
echo " The filter is a regex (glob "*" is expressed as "[^/]*", see \`man 7 glob\`)"
|
||||
echo " All font files that start with that filter (and are ttf, otf, or sfd files) will"
|
||||
echo " be processed only."
|
||||
echo " Example ./gotta-patch-em-all-font-patcher\!.sh \"iosevka\""
|
||||
echo " Process all font files that start with \"iosevka\""
|
||||
echo " If the argument starts with a '/' all font files in a directory that matches"
|
||||
echo " the filter are processed only."
|
||||
echo " Example ./gotta-patch-em-all-font-patcher\!.sh \"/iosevka\""
|
||||
echo " Process all font files that are in directory \"iosevka\""
|
||||
show_help
|
||||
exit 0;;
|
||||
i)
|
||||
activate_info
|
||||
;;
|
||||
t)
|
||||
activate_keeptime
|
||||
;;
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
info)
|
||||
info_only=$2
|
||||
echo "${LINE_PREFIX} 'Info Only' option given, only generating font info (not patching)"
|
||||
activate_info
|
||||
;;
|
||||
keeptime)
|
||||
activate_keeptime
|
||||
;;
|
||||
checkfont)
|
||||
activate_checkfont
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Option '${OPTARG}' unknown"
|
||||
echo >&2 "Option '--${OPTARG}' unknown"
|
||||
exit 1;;
|
||||
esac;;
|
||||
*)
|
||||
echo >&2 "Option '${OPTARG}' unknown"
|
||||
echo >&2 "Option '-${OPTARG}' unknown"
|
||||
exit 1;;
|
||||
esac
|
||||
done
|
||||
@ -73,7 +113,7 @@ shift $((${OPTIND}-1))
|
||||
|
||||
if [ $# -gt 1 ]
|
||||
then
|
||||
echo >&2 "Unknown parameter(s): $2.."
|
||||
echo >&2 "Unknown parameter(s): $2 ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -114,6 +154,23 @@ function patch_font {
|
||||
local f=$1; shift
|
||||
local i=$1; shift
|
||||
local purge=$1; shift
|
||||
|
||||
# Try to copy the release date from the 'original' patch
|
||||
if [ -n "${keeptime}" ]
|
||||
then
|
||||
# take everything before the last slash (/) to start building the full path
|
||||
local ts_font_dir="${f%/*}/"
|
||||
local ts_font_dir="${ts_font_dir/$unpatched_parent_dir/$timestamp_parent_dir}"
|
||||
local one_font=$(find ${ts_font_dir} -name '*.[ot]tf' | head -n 1)
|
||||
if [ -n "${one_font}" ]
|
||||
then
|
||||
orig_font_date=$(ttfdump -t head "${one_font}" | \
|
||||
grep -E '[^a-z]modified:.*0x' | sed 's/.*x//' | tr 'a-f' 'A-F')
|
||||
SOURCE_DATE_EPOCH=$(dc -e "16i ${orig_font_date} Ai 86400 24107 * - p")
|
||||
echo "$LINE_PREFIX Release timestamp adjusted to $(date -R --date=@${SOURCE_DATE_EPOCH})"
|
||||
fi
|
||||
fi
|
||||
|
||||
# take everything before the last slash (/) to start building the full path
|
||||
local patched_font_dir="${f%/*}/"
|
||||
# find replace unpatched parent dir with patched parent dir:
|
||||
|
Loading…
x
Reference in New Issue
Block a user