summaryrefslogtreecommitdiff
path: root/src/sliceitoff/text/fonts.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/text/fonts.py')
-rw-r--r--src/sliceitoff/text/fonts.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sliceitoff/text/fonts.py b/src/sliceitoff/text/fonts.py
index 9f267b3..8776530 100644
--- a/src/sliceitoff/text/fonts.py
+++ b/src/sliceitoff/text/fonts.py
@@ -6,17 +6,17 @@ DEBUG = os.getenv("DEBUG")
class Fonts:
""" Fonts - static class to store loaded fonts """
- fonts = {}
+ def __init__(self):
+ self.fonts = {}
- @staticmethod
- def load_fonts(base_path):
+ 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)
- __class__.fonts[name] = Font(filename)
+ self.fonts[name] = Font(filename)
return True
@@ -42,3 +42,11 @@ class Font:
def get(self, ch):
""" Just get surface of the font size 8x16 max """
return self.surfaces[ch%256]
+
+# Initialize only one time
+try:
+ # pylint: disable = used-before-assignment
+ # This is intented behaviour
+ fonts
+except NameError:
+ fonts = Fonts()