From 8f3fb621866edfba3b41e9740c02ebe87fae283a Mon Sep 17 00:00:00 2001 From: weckyy702 Date: Sun, 27 Dec 2020 16:51:57 +0100 Subject: [PATCH] fixed font handling --- draw/code_to_image.py | 10 ++++------ gui/utils.py | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/draw/code_to_image.py b/draw/code_to_image.py index 5bc1466..cbd26c4 100644 --- a/draw/code_to_image.py +++ b/draw/code_to_image.py @@ -12,16 +12,17 @@ font = _bkp_font def NSD_init(x: float, y: float): #get input_img - global img, output_img, font + global img, output_img #img = Image.open(input_dir + file_name + datei_endung) img = Image.new("RGB", (x, y), "white") output_img = ImageDraw.Draw(img) def set_font(font_filepath: str): if not os.path.exists(font_filepath): - raise FileNotFoundError("") + raise FileNotFoundError("TTF file was not found!") + global font try: - font = ImageFont.truetype(font_filepath) + font = ImageFont.truetype(font_filepath, 12) except: font = _bkp_font raise @@ -50,9 +51,6 @@ def draw_generic_instruction(instruction: str, x, y, xsize, ysize) -> Iterable[f return x, y + ysize - - - def draw_if_statement(condition: str, x: int, y: int, xsize: int, ysize: int): """Draw an if statement into the NSD""" if not output_img: diff --git a/gui/utils.py b/gui/utils.py index 939be9c..39e52a8 100644 --- a/gui/utils.py +++ b/gui/utils.py @@ -3,7 +3,6 @@ import os from interpreter.NassiShneidermann import NassiShneidermanDiagram from draw.Iinstruction import * - def nassi(filepath:str, output_path: str, gui, font_filepath: str=None): NSD = NassiShneidermanDiagram(gui.debug_mode) if font_filepath: