mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
Make output less verbose (with option)
[why] Running gotta-patch-em-all creates a lot of output that is most likely not wanted. [how] Add --verbose option to gotta-patch-em-all. Hide debugging information unless it is wanted by specifying this option. Also change font-patcher to produce less verbose output and respect --quite in more places. This includes a change that we try to tweak the font flags only if source and destination font are ttf or otf, because we can not read the other raw font files anyhow. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
3c4fa008c1
commit
257d6882fa
2 changed files with 58 additions and 37 deletions
|
@ -59,6 +59,7 @@ function show_help {
|
|||
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 " -v, --verbose Show more information when running"
|
||||
echo " -i, --info Rebuild JUST the readmes"
|
||||
echo " -h, --help Show this help"
|
||||
echo
|
||||
|
@ -75,7 +76,7 @@ function show_help {
|
|||
echo " Process all font files that are in directory \"iosevka\""
|
||||
}
|
||||
|
||||
while getopts ":chit-:" option; do
|
||||
while getopts ":chitv-:" option; do
|
||||
case "${option}" in
|
||||
c)
|
||||
activate_checkfont
|
||||
|
@ -89,16 +90,22 @@ while getopts ":chit-:" option; do
|
|||
t)
|
||||
activate_keeptime
|
||||
;;
|
||||
v)
|
||||
verbose=TRUE
|
||||
;;
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
checkfont)
|
||||
activate_checkfont
|
||||
;;
|
||||
info)
|
||||
activate_info
|
||||
;;
|
||||
keeptime)
|
||||
activate_keeptime
|
||||
;;
|
||||
checkfont)
|
||||
activate_checkfont
|
||||
verbose)
|
||||
verbose=TRUE
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Option '--${OPTARG}' unknown"
|
||||
|
@ -178,8 +185,11 @@ function patch_font {
|
|||
|
||||
[[ -d "$patched_font_dir" ]] || mkdir -p "$patched_font_dir"
|
||||
if [ -n ${purge} -a -d "${patched_font_dir}complete" ]
|
||||
then
|
||||
if [ -n "${verbose}" ]
|
||||
then
|
||||
echo "Purging patched font dir ${patched_font_dir}complete"
|
||||
fi
|
||||
rm ${patched_font_dir}complete/*
|
||||
fi
|
||||
|
||||
|
@ -231,11 +241,17 @@ function patch_font {
|
|||
}
|
||||
# Use absolute path to allow fontforge being an AppImage (used in CI)
|
||||
PWD=`pwd`
|
||||
if [ -n "${verbose}" ]
|
||||
then
|
||||
echo "fontforge -quiet -script ${PWD}/font-patcher "$f" -q --also-windows $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" $config_patch_flags"
|
||||
fi
|
||||
{ OUT=$(fontforge -quiet -script ${PWD}/font-patcher "$f" -q --also-windows $powerline $post_process --complete --no-progressbars \
|
||||
--outputdir "${patched_font_dir}complete/" $config_patch_flags 2>&1 1>&3 3>&- ); } 3>&1
|
||||
if [ $? -ne 0 ]; then printf "$OUT\nPatcher run aborted!\n\n"; fi
|
||||
if [ -n "${verbose}" ]
|
||||
then
|
||||
echo "fontforge -quiet -script ${PWD}/font-patcher "$f" -q -s ${font_config} --also-windows $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" $config_patch_flags"
|
||||
fi
|
||||
{ OUT=$(fontforge -quiet -script ${PWD}/font-patcher "$f" -q -s ${font_config} --also-windows $powerline $post_process --complete --no-progressbars \
|
||||
--outputdir "${patched_font_dir}complete/" $config_patch_flags 2>&1 1>&3 3>&- ); } 3>&1
|
||||
if [ $? -ne 0 ]; then printf "$OUT\nPatcher run aborted!\n\n"; fi
|
||||
|
@ -395,6 +411,7 @@ then
|
|||
purge_destination="TRUE"
|
||||
fi
|
||||
fi
|
||||
echo "$LINE_PREFIX Processing font $((i+1))/${#source_fonts[@]}"
|
||||
patch_font "${source_fonts[$i]}" "$i" "$purge_destination" 2>/dev/null
|
||||
|
||||
|
||||
|
|
16
font-patcher
16
font-patcher
|
@ -6,7 +6,7 @@
|
|||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Change the script version when you edit this script:
|
||||
script_version = "3.3.0"
|
||||
script_version = "3.3.1"
|
||||
|
||||
version = "2.3.0-RC"
|
||||
projectName = "Nerd Fonts"
|
||||
|
@ -331,7 +331,7 @@ class font_patcher:
|
|||
sanitize_filename(self.args.outputdir, True),
|
||||
sanitize_filename(sourceFont.familyname) + ".ttc"))
|
||||
sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=gen_flags, layer=layer)
|
||||
message = "\nGenerated: {} fonts in '{}'".format(len(sourceFonts), outfile)
|
||||
message = " Generated {} fonts\n \===> '{}'".format(len(sourceFonts), outfile)
|
||||
else:
|
||||
fontname = sourceFont.fullname
|
||||
if not fontname:
|
||||
|
@ -341,23 +341,28 @@ class font_patcher:
|
|||
sanitize_filename(fontname) + self.args.extension))
|
||||
bitmaps = str()
|
||||
if len(self.sourceFont.bitmapSizes):
|
||||
if not self.args.quiet:
|
||||
print("Preserving bitmaps {}".format(self.sourceFont.bitmapSizes))
|
||||
bitmaps = str('otf') # otf/ttf, both is bf_ttf
|
||||
sourceFont.generate(outfile, bitmap_type=bitmaps, flags=gen_flags)
|
||||
message = "\nGenerated: {} in '{}'".format(self.sourceFont.fullname, outfile)
|
||||
message = " {}\n \===> '{}'".format(self.sourceFont.fullname, outfile)
|
||||
|
||||
# Adjust flags that can not be changed via fontforge
|
||||
if re.search('\\.[ot]tf$', self.args.font, re.IGNORECASE) and re.search('\\.[ot]tf$', outfile, re.IGNORECASE):
|
||||
try:
|
||||
source_font = TableHEADWriter(self.args.font)
|
||||
dest_font = TableHEADWriter(outfile)
|
||||
for idx in range(source_font.num_fonts):
|
||||
if not self.args.quiet:
|
||||
print("{}: Tweaking {}/{}".format(projectName, idx + 1, source_font.num_fonts))
|
||||
source_font.find_head_table(idx)
|
||||
dest_font.find_head_table(idx)
|
||||
if source_font.flags & 0x08 == 0 and dest_font.flags & 0x08 != 0:
|
||||
if not self.args.quiet:
|
||||
print("Changing flags from 0x{:X} to 0x{:X}".format(dest_font.flags, dest_font.flags & ~0x08))
|
||||
dest_font.putshort(dest_font.flags & ~0x08, 'flags') # clear 'ppem_to_int'
|
||||
if source_font.lowppem != dest_font.lowppem:
|
||||
if not self.args.quiet:
|
||||
print("Changing lowestRecPPEM from {} to {}".format(dest_font.lowppem, source_font.lowppem))
|
||||
dest_font.putshort(source_font.lowppem, 'lowestRecPPEM')
|
||||
if dest_font.modified:
|
||||
|
@ -641,8 +646,6 @@ class font_patcher:
|
|||
print("Failed to remove subtable:", subtable)
|
||||
elif self.args.removeligatures:
|
||||
print("Unable to read configfile, unable to remove ligatures")
|
||||
else:
|
||||
print("No configfile given, skipping configfile related actions")
|
||||
|
||||
|
||||
def assert_monospace(self):
|
||||
|
@ -1564,6 +1567,7 @@ def main():
|
|||
sourceFonts = []
|
||||
all_fonts = fontforge.fontsInFile(args.font)
|
||||
for i, subfont in enumerate(all_fonts):
|
||||
if len(all_fonts) > 1:
|
||||
print("\n{}: Processing {} ({}/{})".format(projectName, subfont, i + 1, len(all_fonts)))
|
||||
try:
|
||||
sourceFonts.append(fontforge.open("{}({})".format(args.font, subfont), 1)) # 1 = ("fstypepermitted",))
|
||||
|
@ -1573,7 +1577,7 @@ def main():
|
|||
|
||||
patcher.patch(sourceFonts[-1])
|
||||
|
||||
print("\nDone with Patch Sets, generating font...\n")
|
||||
print("Done with Patch Sets, generating font...")
|
||||
for f in sourceFonts:
|
||||
patcher.setup_font_names(f)
|
||||
patcher.generate(sourceFonts)
|
||||
|
|
Loading…
Reference in a new issue