From 1b8c9e276867437a246cc31ec85e98e2b4159900 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Wed, 9 Feb 2022 16:04:32 +0100 Subject: [PATCH] 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 --- font-patcher | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/font-patcher b/font-patcher index 5306b7139..8d1b52533 100755 --- a/font-patcher +++ b/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()