aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/FontFacade.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/facade/FontFacade.cpp')
-rw-r--r--src/crepe/facade/FontFacade.cpp12
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);
}