mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-12 09:41:47 +02:00
font-patcher: Pull out opening and generating the font
[why] These operations are also not strictly patching. When we want to handle more than one font we need to have this outside the patch() function. [how] Put opening and exporting (previously in __init__() and patch() into main() outside the patcher object. No functional change (except the sourceFont is now closed :->) Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
2432a5700a
commit
1b8c9e2768
1 changed files with 11 additions and 7 deletions
18
font-patcher
18
font-patcher
|
@ -165,10 +165,9 @@ class font_patcher:
|
|||
self.onlybitmaps = 0
|
||||
self.essential = set()
|
||||
self.config = configparser.ConfigParser(empty_lines_in_values=False, allow_no_value=True)
|
||||
try:
|
||||
self.sourceFont = fontforge.open(self.args.font, 1) # 1 = ("fstypepermitted",))
|
||||
except Exception:
|
||||
sys.exit(projectName + ": Can not open font, try to open with fontforge interactively to get more information")
|
||||
|
||||
def patch(self, font):
|
||||
self.sourceFont = font
|
||||
self.setup_version()
|
||||
self.get_essential_references()
|
||||
self.setup_name_backup()
|
||||
|
@ -180,8 +179,6 @@ class font_patcher:
|
|||
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
|
||||
|
||||
|
||||
def patch(self):
|
||||
if self.args.single:
|
||||
# Force width to be equal on all glyphs to ensure the font is considered monospaced on Windows.
|
||||
# This needs to be done on all characters, as some information seems to be lost from the original font file.
|
||||
|
@ -1279,7 +1276,14 @@ def main():
|
|||
check_fontforge_min_version()
|
||||
args = setup_arguments()
|
||||
patcher = font_patcher(args)
|
||||
patcher.patch()
|
||||
|
||||
try:
|
||||
sourceFont = fontforge.open(args.font, 1) # 1 = ("fstypepermitted",))
|
||||
except Exception:
|
||||
sys.exit(projectName + ": Can not open font, try to open with fontforge interactively to get more information")
|
||||
|
||||
patcher.patch(sourceFont)
|
||||
|
||||
print("\nDone with Patch Sets, generating font...\n")
|
||||
patcher.setup_font_names()
|
||||
patcher.generate()
|
||||
|
|
Loading…
Reference in a new issue