44 lines
940 B
C++
44 lines
940 B
C++
#pragma once
|
|
|
|
#include <SDL2/SDL_ttf.h>
|
|
#include <frostbite2D/types/type_alias.h>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
namespace frostbite2D {
|
|
|
|
class FontManager {
|
|
public:
|
|
static FontManager& get();
|
|
|
|
bool init();
|
|
void shutdown();
|
|
|
|
bool registerFont(const std::string& name, const std::string& path, int fontSize);
|
|
TTF_Font* getFont(const std::string& name);
|
|
bool hasFont(const std::string& name) const;
|
|
void unregisterFont(const std::string& name);
|
|
void unloadAll();
|
|
|
|
struct FontInfo {
|
|
std::string name;
|
|
std::string path;
|
|
int size = 0;
|
|
};
|
|
|
|
std::optional<FontInfo> getFontInfo(const std::string& name) const;
|
|
|
|
FontManager(const FontManager&) = delete;
|
|
FontManager& operator=(const FontManager&) = delete;
|
|
|
|
private:
|
|
FontManager() = default;
|
|
~FontManager();
|
|
|
|
std::unordered_map<std::string, TTF_Font*> fonts_;
|
|
std::unordered_map<std::string, FontInfo> fontInfos_;
|
|
};
|
|
|
|
}
|