From c396ae5f78222a7c3547ae5e2ce719ae143acb66 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Sun, 1 Dec 2024 21:14:35 +0100 Subject: start of text component --- src/crepe/api/Font.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/crepe/api/Font.h (limited to 'src/crepe/api/Font.h') diff --git a/src/crepe/api/Font.h b/src/crepe/api/Font.h new file mode 100644 index 0000000..012c271 --- /dev/null +++ b/src/crepe/api/Font.h @@ -0,0 +1,60 @@ +#pragma once + +#include +#include +#include + +#include "Asset.h" + +namespace crepe { + +class SDLContext; + +/** + * \class Font + * \brief Manages font loading and text rendering properties. + * + * The Font class is responsible for loading font resources and providing a way to render text + * with different styles and sizes. It can be used for text rendering in the game engine. + */ +class Font { + +public: + /** + * \brief Constructs a Font from an Asset resource. + * \param src Asset with font data to load. + * \param size The point size to render the font at. + */ + Font(const Asset &src, int size); + + /** + * \brief Destroys the Font instance, freeing associated resources. + */ + ~Font(); + + /** + * \brief Gets the size of the font. + * \return The point size of the font. + */ + int get_size() const; + +private: + /** + * \brief Loads the font from an Asset resource. + * \param res The Asset resource containing the font data. + * \param size The point size to render the font at. + */ + void load(const Asset &res, int size); + +private: + //! The font resource from the SDL_ttf library. + std::unique_ptr> font; + + //! The size of the font in points. + int font_size; + + //! Grants SDLContext access to private members. + friend class SDLContext; +}; + +} // namespace crepe -- cgit v1.2.3