Manifest-driven cache for sf::Font resources.
More...
#include <Malena/Resources/FontManager.h>
|
| static const sf::Font & | get (const Asset &asset) |
| | Retrieve the cached resource for an asset enum value.
|
| static const sf::Font & | getDefault () |
| | Return the built-in Arial font.
|
| static void | prewarm (const sf::Font &font, unsigned int charSize) |
| | Pre-populate the glyph atlas for a font at a given character size.
|
| static void | unload (Asset asset) |
| | Remove a resource from the cache.
|
template<typename
Manifest = DefaultManifest>
class ml::FontManager< Manifest >
Manifest-driven cache for sf::Font resources.
FontManager<Manifest> extends ResourceManager to provide lazy-loaded, cached access to fonts declared in a manifest's Fonts enum. It also provides getDefault(), which returns a built-in Arial font that is always available without any manifest registration.
FontManager defaults to DefaultManifest so it can be used without a custom manifest when only the built-in font is needed:
static std::enable_if_t< has_Image< M >::value, const sf::Texture & > get(typename M::Images image)
Retrieve a cached sf::Texture by manifest enum value.
static const sf::Font & getDefault()
Return the built-in Arial font.
static const sf::Font & get(const Asset &asset)
- Template Parameters
-
- See also
- ResourceManager, AssetsManager, DefaultManifest
Definition at line 46 of file FontManager.h.
◆ get()
Retrieve the cached resource for an asset enum value.
Loads and caches on first access. Throws std::runtime_error if the path is not registered or loading fails.
- Template Parameters
-
| Asset | An enum type declared inside Manifest. |
- Parameters
-
| asset | The specific enum value to load. |
- Returns
- Const reference to the cached
Resource.
◆ getDefault()
template<typename
Manifest = DefaultManifest>
Return the built-in Arial font.
The Arial font is embedded in the framework and requires no manifest registration or file path. Use it as a reliable fallback for UI text when no custom font has been loaded.
- Returns
- Const reference to the built-in
sf::Font.
◆ prewarm()
template<typename
Manifest = DefaultManifest>
Pre-populate the glyph atlas for a font at a given character size.
Call this before rendering any text at charSize to prevent mid-render atlas reorganization, which causes glyph corruption in SFML 3.
- Parameters
-
| font | The font to warm. |
| charSize | Character size to load glyphs for. |
◆ unload()
Remove a resource from the cache.
The next get(asset) call will reload from disk. If called during draw(), the unload is deferred until after the frame completes to prevent mid-frame dangling references.
- Template Parameters
-
| Asset | The enum type of the key to remove. |
- Parameters
-
| asset | The specific enum value to evict from the cache. |
The documentation for this class was generated from the following file: