diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 22:17:43 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 22:17:43 +0100 |
commit | e75e355c3a59d53a1d64fd8fae3331b2234083e2 (patch) | |
tree | 24176a074d529271e7279794f7fa2dcf5aed2525 /src/crepe/facade/SDLFontContext.cpp | |
parent | bb2a6f1a0ab19f6cbc78b2747a26920f24bf13ca (diff) |
text component pretty much finished
Diffstat (limited to 'src/crepe/facade/SDLFontContext.cpp')
-rw-r--r-- | src/crepe/facade/SDLFontContext.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/crepe/facade/SDLFontContext.cpp b/src/crepe/facade/SDLFontContext.cpp index a4be143..d7a0bff 100644 --- a/src/crepe/facade/SDLFontContext.cpp +++ b/src/crepe/facade/SDLFontContext.cpp @@ -7,16 +7,16 @@ using namespace crepe; using namespace std; SDLFontContext::SDLFontContext(){ - + if (!FcInit()) { + throw std::runtime_error("Failed to initialize Fontconfig."); + } } SDLFontContext::~SDLFontContext(){ - + FcFini(); } 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) { @@ -49,6 +49,5 @@ unique_ptr<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); - FcFini(); return std::move(make_unique<Asset>(font_file_path)); } |