-
Notifications
You must be signed in to change notification settings - Fork 0
/
font_manager.py
31 lines (25 loc) · 954 Bytes
/
font_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Module for managing fonts
"""
import os
import sys
import pygame
class FontManager:
"""The `FontManager` class initializes a dictionary of fonts and provides
a method to retrieve the current font."""
def __init__(self):
"""
The function initializes a dictionary of fonts with a default font and font size.
"""
pygame.font.init()
# Finde den korrekten Pfad zur Schriftartendatei
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
font_path = os.path.join(base_path, 'PressStart2P-Regular.ttf')
self.fonts = {"PressStart2P": pygame.font.Font(font_path, 18)}
self.current_font = "PressStart2P"
def get_font(self):
"""
The function `get_font` returns the current font from a list of fonts.
:return: The font corresponding to the current_font value.
"""
return self.fonts[self.current_font]