aboutsummaryrefslogtreecommitdiff
path: root/gn2/utility
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-11 02:58:41 -0500
committerFrederick Muriuki Muriithi2024-09-11 02:58:41 -0500
commitd001c1e7cae8f69435545b8715038b1d0fc1ee62 (patch)
tree5bfda6ade7119f2564b94f2b7d42f601757e4d5c /gn2/utility
parent01d56903ba01a91841d199fe393f9b307a7596a2 (diff)
downloadgenenetwork2-d001c1e7cae8f69435545b8715038b1d0fc1ee62.tar.gz
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.
Diffstat (limited to 'gn2/utility')
-rw-r--r--gn2/utility/Plot.py11
1 files changed, 7 insertions, 4 deletions
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 ---- #