From cb0c9ed1e7b70a3149dfc55a6c3d5e5941be0eb3 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Mon, 6 May 2024 22:08:56 +0200 Subject: [PATCH] font-patcher: Fix escaping warnings [why] Some strings have broken format, because the string should contain a verbatim backslash. It seems this is a new warning for Python 3.12 [how] Use raw strings or escape the escape character via '\\' Signed-off-by: Fini Jastrow --- bin/scripts/name_parser/FontnameTools.py | 4 ++-- font-patcher | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/scripts/name_parser/FontnameTools.py b/bin/scripts/name_parser/FontnameTools.py index 5537bfaaa..f056feb1b 100644 --- a/bin/scripts/name_parser/FontnameTools.py +++ b/bin/scripts/name_parser/FontnameTools.py @@ -211,7 +211,7 @@ class FontnameTools: ( '(.*dyslexic ?m)ono', r'\1'), # Open Dyslexic Mono -> Open Dyslexic M ( '(overpass ?m)ono', r'\1'), # Overpass Mono -> Overpass M ( '(proggyclean) ?tt', r'\1'), # Remove TT from ProggyClean - ( '(terminess) ?\(ttf\)', r'\1'), # Remove TTF from Terminus (after renamed to Terminess) + ( '(terminess) ?(ttf)', r'\1'), # Remove TTF from Terminus (after renamed to Terminess) ( '(.*ne)on', r'\1'), # Monaspace shorten face name ( '(.*ar)gon', r'\1'), # Monaspace shorten face name ( '(.*kr)ypton', r'\1'), # Monaspace shorten face name @@ -399,7 +399,7 @@ class FontnameTools: ('Bold-Italic', 'BoldItalic'), # Terminus ]: name = re.sub(r'\b' + special[0] + r'\b', special[1], name, 1, re.IGNORECASE) - name = re.sub('[_\s]+', ' ', name) + name = re.sub(r'[_\s]+', ' ', name) matches = re.match(r'([^-]+)(?:-(.*))?', name) familyname = FontnameTools.camel_casify(matches.group(1)) style = matches.group(2) diff --git a/font-patcher b/font-patcher index cd8dbba45..c16a67fbd 100755 --- a/font-patcher +++ b/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 = "4.14.2" +script_version = "4.14.3" version = "3.2.1" projectName = "Nerd Fonts" @@ -429,7 +429,7 @@ class font_patcher: sanitize_filename(self.args.outputdir, True), sanitize_filename(create_filename(sourceFonts)) + ".ttc")) sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=gen_flags, layer=layer) - message = " Generated {} fonts\n \===> '{}'".format(len(sourceFonts), outfile) + message = " Generated {} fonts\n \\===> '{}'".format(len(sourceFonts), outfile) else: fontname = create_filename(sourceFonts) if not fontname: @@ -445,10 +445,10 @@ class font_patcher: logger.debug("=====> Filename '%s'", outfile) return sourceFont.generate(outfile, bitmap_type=bitmaps, flags=gen_flags) - message = " {}\n \===> '{}'".format(sourceFont.fullname, outfile) + message = " {}\n \\===> '{}'".format(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): + if re.search(r'\.[ot]tf$', self.args.font, re.IGNORECASE) and re.search(r'\.[ot]tf$', outfile, re.IGNORECASE): if not os.path.isfile(outfile) or os.path.getsize(outfile) < 1: logger.critical("Something went wrong and Fontforge did not generate the new font - look for messages above") sys.exit(1) @@ -2062,7 +2062,7 @@ def setup_arguments(): args.extension = os.path.splitext(args.font)[1] else: args.extension = '.' + args.extension - if re.match("\.ttc$", args.extension, re.IGNORECASE): + if re.match(r'\.ttc$', args.extension, re.IGNORECASE): if not is_ttc: logger.critical("Can not create True Type Collections from single font files") sys.exit(1)