Font Manager Module
This module provides a centralized FontManager class responsible for loading, caching, and scaling fonts used throughout the Property Tycoon application. It ensures consistent font usage and adapts font sizes dynamically based on the current screen resolution, maintaining readability across different display sizes.
The Font Manager module provides:
A mechanism to load TrueType Fonts (.ttf) from a specified path.
Caching of loaded pygame.font.Font objects to improve performance by avoiding redundant file loading.
Automatic scaling of requested font sizes based on the current screen dimensions relative to a base resolution (1280x720).
A global font_manager instance for easy access from other modules.
Methods to update the font path or recalculate the scale factor, clearing the cache when necessary.
- class src.Font_Manager.FontManager[source]
Bases:
object
- classmethod get_font(size)[source]
Get a font at the specified base size (will be automatically scaled)
Detailed Design
FontManager Class Diagram
This diagram illustrates the structure of the FontManager class, emphasizing its use of class attributes and methods to manage font resources globally.
Shows the process of requesting a font from the FontManager, including scaling and cache interaction.
Illustrates how the scale factor is updated (e.g., on window resize) and how it affects the cache.