Files
MacroLibX/runtime/Includes/Renderer/Texts/FontLibrary.h
2024-03-27 23:03:54 +01:00

48 lines
1.6 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* font_library.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 09:26:03 by maldavid #+# #+# */
/* Updated: 2024/03/25 19:08:18 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_FONT_LIBRARY__
#define __MLX_FONT_LIBRARY__
#include <renderer/texts/font.h>
#include <renderer/core/render_core.h>
#include <utils/singleton.h>
namespace mlx
{
using FontID = std::uint32_t;
constexpr FontID nullfont = 0;
class FontLibrary : public Singleton<FontLibrary>
{
friend class Singleton<FontLibrary>;
public:
std::shared_ptr<class Font> getFontData(FontID id);
FontID addFontToLibrary(std::shared_ptr<Font> font);
void removeFontFromLibrary(FontID id);
void clearLibrary();
private:
FontLibrary() = default;
~FontLibrary() = default;
private:
std::unordered_map<FontID, std::shared_ptr<class Font>> _cache;
std::vector<FontID> _invalid_ids;
FontID _current_id = 1;
};
}
#endif