2D_Game_Engine
Loading...
Searching...
No Matches
fontmanager.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <textrenderer.hpp>
4
5struct FontInfo{
6 unsigned int copies;
7 std::shared_ptr<TextRenderer> font;
8
9 FontInfo(): copies(0),font(nullptr){}
10 FontInfo(std::shared_ptr<TextRenderer> f): copies(1),font(f){}
11};
12
14public:
15 FontManager()=default;
16 ~FontManager()=default;
17
23 std::pair<uint32_t,std::shared_ptr<TextRenderer>> GetFont(const std::string &path,int glyph_size,bool fixed);
24
29 std::shared_ptr<TextRenderer> GetFont(uint32_t id);
30
34 void ReleaseFont(uint32_t font_id);
35
39 std::pair<uint32_t,std::shared_ptr<TextRenderer>> UpdateFont(uint32_t font_id,const std::string &path,int glyph_size,bool fixed);
40
41 inline std::unordered_map<uint32_t,struct FontInfo> &GetFonts(){
42 return m_Fonts;
43 }
44private:
45 std::unordered_map<uint32_t,struct FontInfo> m_Fonts;
46
47 uint32_t m_NextID=0;
48};
std::pair< uint32_t, std::shared_ptr< TextRenderer > > UpdateFont(uint32_t font_id, const std::string &path, int glyph_size, bool fixed)
std::unordered_map< uint32_t, struct FontInfo > & GetFonts()
FontManager()=default
std::pair< uint32_t, std::shared_ptr< TextRenderer > > GetFont(const std::string &path, int glyph_size, bool fixed)
~FontManager()=default
void ReleaseFont(uint32_t font_id)
unsigned int copies
std::shared_ptr< TextRenderer > font
FontInfo(std::shared_ptr< TextRenderer > f)