From d001c1e7cae8f69435545b8715038b1d0fc1ee62 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 11 Sep 2024 02:58:41 -0500 Subject: BUGFIX: Use absolute paths for font files Use absolute paths for font files so that they are loaded successfully, regardless of whether the application is run with the working directory being the root of the GN2 repo/package or not. --- gn2/utility/Plot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gn2/utility') diff --git a/gn2/utility/Plot.py b/gn2/utility/Plot.py index f984963f..a97ece5e 100644 --- a/gn2/utility/Plot.py +++ b/gn2/utility/Plot.py @@ -22,8 +22,9 @@ # # Created by GeneNetwork Core Team 2010/08/10 # -# Last updated by GeneNetwork Core Team 2010/10/20 +# Last updated by GeneNetwork Core Team 2024/09/11 import os +from pathlib import Path from PIL import ImageColor from PIL import ImageDraw @@ -44,9 +45,11 @@ BLACK = ImageColor.getrgb("black") # ---- END: Define common colours ---- # # ---- FONT FILES ---- # -VERDANA_FILE = "./gn2/wqflask/static/fonts/verdana.ttf" -COUR_FILE = "./gn2/wqflask/static/fonts/courbd.ttf" -TAHOMA_FILE = "./gn2/wqflask/static/fonts/tahoma.ttf" +REPO_ROOT = Path(__file__).parent.parent +FONTS_DIR = REPO_ROOT.joinpath("wqflask/static/fonts") +VERDANA_FILE = f"{FONTS_DIR.joinpath('verdana.ttf')}" +COUR_FILE = f"{FONTS_DIR.joinpath('courbd.ttf')}" +TAHOMA_FILE = f"{FONTS_DIR.joinpath('tahoma.ttf')}" # ---- END: FONT FILES ---- # -- cgit v1.2.3