summaryrefslogtreecommitdiff
path: root/src/sliceitoff/text/fonts.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-04-21 00:19:34 +0300
committerViljami Ilola <+@hix.fi>2024-04-21 00:19:34 +0300
commit03ad276bf93e160d19f693bf0a39ef095b0189b3 (patch)
treed80228a8f7e2b0b7d374d42c7b5b2925229ca970 /src/sliceitoff/text/fonts.py
parent9f808fa0e43ae903d6159848d1331dcccb91434d (diff)
find and load fonts from assets dir
Diffstat (limited to 'src/sliceitoff/text/fonts.py')
-rw-r--r--src/sliceitoff/text/fonts.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/sliceitoff/text/fonts.py b/src/sliceitoff/text/fonts.py
index 8776530..24eb91e 100644
--- a/src/sliceitoff/text/fonts.py
+++ b/src/sliceitoff/text/fonts.py
@@ -1,5 +1,6 @@
""" text.fonts - .FNT file loading and storing """
import os
+from pathlib import Path
import pygame
DEBUG = os.getenv("DEBUG")
@@ -10,14 +11,9 @@ class Fonts:
self.fonts = {}
def init(self, base_path):
- """ loads fonts from list """
- filename_fontlist = os.path.join(base_path, "fonts.lst")
- with open(filename_fontlist, "r", encoding="utf-8") as fontlist_file:
- for line in fontlist_file:
- name, *path = line.strip().split()
- filename = os.path.join(base_path, *path)
- self.fonts[name] = Font(filename)
- return True
+ """ loads fonts found in assets directory """
+ for fnt_file in Path(base_path).glob('*.fnt'):
+ self.fonts[str(fnt_file.stem)] = Font(fnt_file)
class Font: