Skip to content

Commit

Permalink
font-patcher: Fix escaping warnings
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
Finii committed May 6, 2024
1 parent a5704a5 commit cb0c9ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bin/scripts/name_parser/FontnameTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def postscript_char_filter(name):
( '(.*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
Expand Down Expand Up @@ -399,7 +399,7 @@ def parse_font_name(name):
('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)
Expand Down
10 changes: 5 additions & 5 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cb0c9ed

Please sign in to comment.