aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLFontContext.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-10 12:27:59 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-10 12:27:59 +0100
commitb2c72ee8ce282bb13b0fbeb2ddb01fdfd6ad1280 (patch)
treef3c678779f326f4b175f91a2b3c7db44d026cd2f /src/crepe/facade/SDLFontContext.cpp
parent29f2d4537cf4d4d4c74c16447a45a5d7034161f4 (diff)
font progress
Diffstat (limited to 'src/crepe/facade/SDLFontContext.cpp')
-rw-r--r--src/crepe/facade/SDLFontContext.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/crepe/facade/SDLFontContext.cpp b/src/crepe/facade/SDLFontContext.cpp
index 6ce5efd..a4be143 100644
--- a/src/crepe/facade/SDLFontContext.cpp
+++ b/src/crepe/facade/SDLFontContext.cpp
@@ -1,19 +1,22 @@
-#include "SDLFontContext.h"
#include <stdexcept>
+#include "SDLFontContext.h"
+
+
using namespace crepe;
using namespace std;
SDLFontContext::SDLFontContext(){
- if (!FcInit()) {
- throw std::runtime_error("Failed to initialize Fontconfig.");
- }
+
}
SDLFontContext::~SDLFontContext(){
- FcFini();
+
}
-Asset SDLFontContext::get_font_asset(const std::string & font_family) {
+unique_ptr<Asset> SDLFontContext::get_font_asset(const std::string & font_family) {
+ if (!FcInit()) {
+ throw std::runtime_error("Failed to initialize Fontconfig.");
+ }
// Create a pattern to search for the font family
FcPattern* pattern = FcNameParse(reinterpret_cast<const FcChar8*>(font_family.c_str()));
if (!pattern) {
@@ -46,6 +49,6 @@ Asset SDLFontContext::get_font_asset(const std::string & font_family) {
// Convert the file path to a std::string
std::string font_file_path(reinterpret_cast<const char*>(file_path));
FcPatternDestroy(matched_pattern);
-
- return Asset(font_file_path);
+ FcFini();
+ return std::move(make_unique<Asset>(font_file_path));
}