ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
FontManager.h
浏览该文件的文档.
1#pragma once
2
3#include <string>
4#include <unordered_map>
5#include <memory>
6#include <SDL3_ttf/SDL_ttf.h>
7
9
10namespace Shit {
11 class FontManager final {
12 friend class ResourceManager;
13 public:
14 FontManager(const FontManager&) = delete;
18 ~FontManager() { clearFont(); }
19
20 private:
21 FontManager() = default;
22
23 struct TTF_FontDeleter {
24 void operator()(TTF_Font* font) const {
25 if (font) TTF_CloseFont(font);
26 }
27 };
28
29 TTF_Font* loadFont(const std::string& filePath);
30 TTF_Font* getFont(const std::string& filePath);
31 void unloadFont(const std::string& filePath);
32 void clearFont();
33
34 float m_fontSize = 16.0f;
35 std::unordered_map<std::string, std::unique_ptr<TTF_Font, TTF_FontDeleter>> m_fonts;
36 };
37}
FontManager(FontManager &&)=default
~FontManager()
定义 FontManager.h:18
FontManager & operator=(const FontManager &)=delete
friend class ResourceManager
定义 FontManager.h:12
FontManager(const FontManager &)=delete
FontManager & operator=(FontManager &&)=default
定义 AudioPlayer.h:9