Skip to content

Commit

Permalink
font-patcher: Pull out opening and generating the font
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
Finii committed Sep 22, 2022
1 parent 2621e88 commit 7a6fcda
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7a6fcda

Please sign in to comment.