From 791cd530f117548bd0381fb2ec58c9af2c2ecdfc Mon Sep 17 00:00:00 2001 From: Anthony <26030673+im-ant@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:35:22 -0500 Subject: [PATCH] Set font path relative to the sf_examples package so code can be instantiated from arbitrary current working directories --- sf_examples/nethack/utils/wrappers/screen_image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sf_examples/nethack/utils/wrappers/screen_image.py b/sf_examples/nethack/utils/wrappers/screen_image.py index fae99f25..530ee06a 100644 --- a/sf_examples/nethack/utils/wrappers/screen_image.py +++ b/sf_examples/nethack/utils/wrappers/screen_image.py @@ -21,6 +21,7 @@ import os from typing import Any, SupportsFloat +import importlib.resources import cv2 import gym @@ -30,8 +31,7 @@ from numba import njit from PIL import Image, ImageDraw, ImageFont -SMALL_FONT_PATH = os.path.abspath("sf_examples/nethack/nethack_render_utils/Hack-Regular.ttf") - +SMALL_FONT_PATH = importlib.resources.files("sf_examples") / "nethack/nethack_render_utils/Hack-Regular.ttf" # Mapping of 0-15 colors used. # Taken from bottom image here. It seems about right