1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2025-01-13 03:03:33 +02:00

font-parser: Allow patching without --ext

[why]
Sometimes fontforge returns None for font.path. That should not be the
case according to specs:

font.path
    (readonly) Returns a string containing the name of the file from
    which the font was originally read (in this session), or if this
    is a new font, returns a made up filename in the current directory
    named something like “Untitled1.sfd”. See also font.sfd_path.

This seems to be the case for fonts that do not have a fullname set.
I did not search for nor file any issue at Fontforge.

[how]
In fact we already have the original font file name, and we want to
retain its extension anyhow (if nothing is specified), so we use the
filename that we opened to determine the extension.

[note]
Related: #412
Related: #641

[note]
This was the sole usage of font.path.
Has been introduced with commit d8b760aee which looks uncritical.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2021-12-15 18:16:38 +01:00
parent 329082d9da
commit f6b6174680

View File

@ -69,7 +69,7 @@ class font_patcher:
self.sourceFont.encoding = 'UnicodeFull' # Update the font encoding to ensure that the Unicode glyphs are available self.sourceFont.encoding = 'UnicodeFull' # Update the font encoding to ensure that the Unicode glyphs are available
self.onlybitmaps = self.sourceFont.onlybitmaps # Fetch this property before adding outlines. NOTE self.onlybitmaps initialized and never used self.onlybitmaps = self.sourceFont.onlybitmaps # Fetch this property before adding outlines. NOTE self.onlybitmaps initialized and never used
if self.args.extension == "": if self.args.extension == "":
self.extension = os.path.splitext(self.sourceFont.path)[1] self.extension = os.path.splitext(self.args.font)[1]
else: else:
self.extension = '.' + self.args.extension self.extension = '.' + self.args.extension