aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/facade')
-rw-r--r--src/crepe/facade/Font.cpp4
-rw-r--r--src/crepe/facade/Font.h7
-rw-r--r--src/crepe/facade/FontFacade.cpp6
-rw-r--r--src/crepe/facade/FontFacade.h2
4 files changed, 14 insertions, 5 deletions
diff --git a/src/crepe/facade/Font.cpp b/src/crepe/facade/Font.cpp
index d419974..5af943d 100644
--- a/src/crepe/facade/Font.cpp
+++ b/src/crepe/facade/Font.cpp
@@ -1,3 +1,5 @@
+#include <SDL2/SDL_ttf.h>
+
#include "../api/Asset.h"
#include "../api/Config.h"
@@ -15,7 +17,7 @@ Font::Font(const Asset & src, Mediator & mediator)
if (loaded_font == NULL) {
throw runtime_error(format("Font: {} (path: {})", TTF_GetError(), FONT_PATH));
}
- this->font = {loaded_font, [](TTF_Font * font) { TTF_CloseFont(font); }};
+ this->font = {loaded_font, [](TTF_Font * close_font) { TTF_CloseFont(close_font); }};
}
TTF_Font * Font::get_font() const { return this->font.get(); }
diff --git a/src/crepe/facade/Font.h b/src/crepe/facade/Font.h
index 3ff156f..16f8cb6 100644
--- a/src/crepe/facade/Font.h
+++ b/src/crepe/facade/Font.h
@@ -24,7 +24,14 @@ public:
* \param mediator The Mediator object used for managing the SDL context or related systems.
*/
Font(const Asset & src, Mediator & mediator);
+ Font(const Font &) = delete;
+ Font &operator=(const Font &) = delete;
+ // Default move constructor and move assignment operator
+ Font(Font &&) noexcept = delete;
+ Font &operator=(Font &&) noexcept = delete;
+
+ ~Font() = default;
/**
* \brief Gets the underlying TTF_Font resource.
*
diff --git a/src/crepe/facade/FontFacade.cpp b/src/crepe/facade/FontFacade.cpp
index aa9d00c..d447b6d 100644
--- a/src/crepe/facade/FontFacade.cpp
+++ b/src/crepe/facade/FontFacade.cpp
@@ -6,7 +6,7 @@
using namespace crepe;
using namespace std;
-Asset FontFacade::get_font_asset(const string font_family) {
+Asset FontFacade::get_font_asset(const string& font_family) {
if (!FcInit()) {
throw runtime_error("Failed to initialize Fontconfig.");
}
@@ -19,7 +19,7 @@ Asset FontFacade::get_font_asset(const string font_family) {
// Default configuration
FcConfig * config = FcConfigGetCurrent();
if (config == NULL) {
- FcPatternDestroy(pattern);
+ // FcPatternDestroy(pattern);
throw runtime_error("Failed to get current Fontconfig configuration.");
}
@@ -37,7 +37,7 @@ Asset FontFacade::get_font_asset(const string font_family) {
FcChar8 * file_path = nullptr;
if (FcPatternGetString(matched_pattern, FC_FILE, 0, &file_path) != FcResultMatch
|| file_path == NULL) {
- FcPatternDestroy(matched_pattern);
+ // FcPatternDestroy(matched_pattern);
throw runtime_error("Failed to get font file path.");
}
diff --git a/src/crepe/facade/FontFacade.h b/src/crepe/facade/FontFacade.h
index 0e6b7da..fc200d6 100644
--- a/src/crepe/facade/FontFacade.h
+++ b/src/crepe/facade/FontFacade.h
@@ -22,7 +22,7 @@ public:
* \param font_family Name of the font family name.
* \return Asset with filepath to the font.
*/
- static Asset get_font_asset(const std::string font_family);
+ static Asset get_font_asset(const std::string& font_family);
};
} // namespace crepe