diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-17 13:29:58 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-17 13:29:58 +0100 |
commit | bcaee968761c1d2e85c20925b237480c87da9747 (patch) | |
tree | f91ab2c2396a6365eb0696902e63975dc18b5259 /src/crepe/facade/FontFacade.cpp | |
parent | bfc07676707eae2c0161c6b86ccdd1583d96f71b (diff) |
tmp fix
Diffstat (limited to 'src/crepe/facade/FontFacade.cpp')
-rw-r--r-- | src/crepe/facade/FontFacade.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/crepe/facade/FontFacade.cpp b/src/crepe/facade/FontFacade.cpp index aa9d00c..a0464e0 100644 --- a/src/crepe/facade/FontFacade.cpp +++ b/src/crepe/facade/FontFacade.cpp @@ -1,4 +1,5 @@ #include <fontconfig/fontconfig.h> +#include <iostream> #include <stdexcept> #include "FontFacade.h" @@ -12,13 +13,13 @@ Asset FontFacade::get_font_asset(const string font_family) { } // Create a pattern to search for the font family FcPattern * pattern = FcNameParse(reinterpret_cast<const FcChar8 *>(font_family.c_str())); - if (pattern == NULL) { + if (!pattern) { throw runtime_error("Failed to create font pattern."); } // Default configuration FcConfig * config = FcConfigGetCurrent(); - if (config == NULL) { + if (!config) { FcPatternDestroy(pattern); throw runtime_error("Failed to get current Fontconfig configuration."); } @@ -28,15 +29,14 @@ Asset FontFacade::get_font_asset(const string font_family) { FcPattern * matched_pattern = FcFontMatch(config, pattern, &result); FcPatternDestroy(pattern); - if (matched_pattern == NULL) { - FcPatternDestroy(matched_pattern); + if (!matched_pattern) { throw runtime_error("No matching font found."); } // Extract the file path FcChar8 * file_path = nullptr; if (FcPatternGetString(matched_pattern, FC_FILE, 0, &file_path) != FcResultMatch - || file_path == NULL) { + || !file_path) { FcPatternDestroy(matched_pattern); throw runtime_error("Failed to get font file path."); } @@ -44,6 +44,6 @@ Asset FontFacade::get_font_asset(const string font_family) { // Convert the file path to a string string font_file_path = reinterpret_cast<const char *>(file_path); FcPatternDestroy(matched_pattern); - FcFini(); + cout << font_file_path << endl; return Asset(font_file_path); } |