diff options
Diffstat (limited to 'src/crepe/facade/SDLFontContext.cpp')
-rw-r--r-- | src/crepe/facade/SDLFontContext.cpp | 19 |
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)); } |