Skip to content

Commit cb0c9ed

Browse files
committed
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 <[email protected]>
1 parent a5704a5 commit cb0c9ed

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bin/scripts/name_parser/FontnameTools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def postscript_char_filter(name):
211211
( '(.*dyslexic ?m)ono', r'\1'), # Open Dyslexic Mono -> Open Dyslexic M
212212
( '(overpass ?m)ono', r'\1'), # Overpass Mono -> Overpass M
213213
( '(proggyclean) ?tt', r'\1'), # Remove TT from ProggyClean
214-
( '(terminess) ?\(ttf\)', r'\1'), # Remove TTF from Terminus (after renamed to Terminess)
214+
( '(terminess) ?(ttf)', r'\1'), # Remove TTF from Terminus (after renamed to Terminess)
215215
( '(.*ne)on', r'\1'), # Monaspace shorten face name
216216
( '(.*ar)gon', r'\1'), # Monaspace shorten face name
217217
( '(.*kr)ypton', r'\1'), # Monaspace shorten face name
@@ -399,7 +399,7 @@ def parse_font_name(name):
399399
('Bold-Italic', 'BoldItalic'), # Terminus
400400
]:
401401
name = re.sub(r'\b' + special[0] + r'\b', special[1], name, 1, re.IGNORECASE)
402-
name = re.sub('[_\s]+', ' ', name)
402+
name = re.sub(r'[_\s]+', ' ', name)
403403
matches = re.match(r'([^-]+)(?:-(.*))?', name)
404404
familyname = FontnameTools.camel_casify(matches.group(1))
405405
style = matches.group(2)

font-patcher

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from __future__ import absolute_import, print_function, unicode_literals
77

88
# Change the script version when you edit this script:
9-
script_version = "4.14.2"
9+
script_version = "4.14.3"
1010

1111
version = "3.2.1"
1212
projectName = "Nerd Fonts"
@@ -429,7 +429,7 @@ class font_patcher:
429429
sanitize_filename(self.args.outputdir, True),
430430
sanitize_filename(create_filename(sourceFonts)) + ".ttc"))
431431
sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=gen_flags, layer=layer)
432-
message = " Generated {} fonts\n \===> '{}'".format(len(sourceFonts), outfile)
432+
message = " Generated {} fonts\n \\===> '{}'".format(len(sourceFonts), outfile)
433433
else:
434434
fontname = create_filename(sourceFonts)
435435
if not fontname:
@@ -445,10 +445,10 @@ class font_patcher:
445445
logger.debug("=====> Filename '%s'", outfile)
446446
return
447447
sourceFont.generate(outfile, bitmap_type=bitmaps, flags=gen_flags)
448-
message = " {}\n \===> '{}'".format(sourceFont.fullname, outfile)
448+
message = " {}\n \\===> '{}'".format(sourceFont.fullname, outfile)
449449

450450
# Adjust flags that can not be changed via fontforge
451-
if re.search('\\.[ot]tf$', self.args.font, re.IGNORECASE) and re.search('\\.[ot]tf$', outfile, re.IGNORECASE):
451+
if re.search(r'\.[ot]tf$', self.args.font, re.IGNORECASE) and re.search(r'\.[ot]tf$', outfile, re.IGNORECASE):
452452
if not os.path.isfile(outfile) or os.path.getsize(outfile) < 1:
453453
logger.critical("Something went wrong and Fontforge did not generate the new font - look for messages above")
454454
sys.exit(1)
@@ -2062,7 +2062,7 @@ def setup_arguments():
20622062
args.extension = os.path.splitext(args.font)[1]
20632063
else:
20642064
args.extension = '.' + args.extension
2065-
if re.match("\.ttc$", args.extension, re.IGNORECASE):
2065+
if re.match(r'\.ttc$', args.extension, re.IGNORECASE):
20662066
if not is_ttc:
20672067
logger.critical("Can not create True Type Collections from single font files")
20682068
sys.exit(1)

0 commit comments

Comments
 (0)