aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/Font.h
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-17 15:43:49 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-17 15:43:49 +0100
commit4dd30ea92296892c9a9bd94787531d6a1319d8ac (patch)
tree5df2de26f7f6f3170c06c77d8ae21ce635217356 /src/crepe/facade/Font.h
parent6e92c59b3364b00eb15c310120b93acc83ca504e (diff)
parenta8ccf7fe8662086bb223aa4eafd0f85e717d16cf (diff)
Merge remote-tracking branch 'origin/master' into jaro/collision-system-handeling
Diffstat (limited to 'src/crepe/facade/Font.h')
-rw-r--r--src/crepe/facade/Font.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/crepe/facade/Font.h b/src/crepe/facade/Font.h
new file mode 100644
index 0000000..b208d96
--- /dev/null
+++ b/src/crepe/facade/Font.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <SDL2/SDL_ttf.h>
+#include <memory>
+
+#include "../Resource.h"
+#include "../api/Config.h"
+
+namespace crepe {
+
+class Asset;
+/**
+ * \brief Resource for managing font creation and destruction
+ *
+ * This class is a wrapper around an SDL_ttf font instance, encapsulating font loading and usage.
+ * It loads a font from an Asset and manages its lifecycle. The font is automatically unloaded
+ * when this object is destroyed.
+ */
+class Font : public Resource {
+
+public:
+ /**
+ * \param src The Asset containing the font file path and metadata to load the font.
+ * \param mediator The Mediator object used for managing the SDL context or related systems.
+ */
+ Font(const Asset & src, Mediator & mediator);
+ /**
+ * \brief Gets the underlying TTF_Font resource.
+ *
+ * This function returns the raw pointer to the SDL_ttf TTF_Font object that represents
+ * the loaded font. This can be used with SDL_ttf functions to render text.
+ *
+ * \return The raw TTF_Font object wrapped in a unique pointer.
+ */
+ TTF_Font * get_font() const;
+
+private:
+ //! The SDL_ttf font object with custom deleter.
+ std::unique_ptr<TTF_Font, std::function<void(TTF_Font *)>> font = nullptr;
+};
+
+} // namespace crepe