Skip to content

Commit d4f22a2

Browse files
committed
font-patcher: Allow absolute paths on Windows
[why] On Windows an absolute path can start with the drive letter followed by a colon. When we sanitize the pathname the colon is replaced by an underscore. [how] Add special handling on Windows. Signed-off-by: Fini Jastrow <[email protected]>
1 parent 273b7aa commit d4f22a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

font-patcher

+6-2
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.18.0"
9+
script_version = "4.18.1"
1010

1111
version = "3.3.0"
1212
projectName = "Nerd Fonts"
@@ -1845,6 +1845,7 @@ def sanitize_filename(filename, allow_dirs = False):
18451845
""" Enforces to not use forbidden characters in a filename/path. """
18461846
if filename == '.' and not allow_dirs:
18471847
return '_'
1848+
restore_colon = sys.platform == 'win32' and re.match('[a-z]:', filename, re.I)
18481849
trans = filename.maketrans('<>:"|?*', '_______')
18491850
for i in range(0x00, 0x20):
18501851
trans[i] = ord('_')
@@ -1853,7 +1854,10 @@ def sanitize_filename(filename, allow_dirs = False):
18531854
trans[ord('\\')] = ord('_')
18541855
else:
18551856
trans[ord('\\')] = ord('/') # We use Posix paths
1856-
return filename.translate(trans)
1857+
new_filename = filename.translate(trans)
1858+
if restore_colon:
1859+
new_filename = new_filename[ :1] + ':' + new_filename[2: ]
1860+
return new_filename
18571861

18581862
def get_multiglyph_boundingBox(glyphs, destGlyph = None):
18591863
""" Returns dict of the dimensions of multiple glyphs combined(, as if they are copied into destGlyph) """

0 commit comments

Comments
 (0)