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 <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2024-05-06 22:08:56 +02:00
parent a5704a532f
commit cb0c9ed1e7
2 changed files with 7 additions and 7 deletions

View file

@ -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)

View file

@ -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)