From fda61be91cd8667fa2b51e3b8a17ba6b93b728c8 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Sat, 14 Dec 2024 14:45:10 +0100 Subject: feedback changes --- src/crepe/facade/SDLContext.cpp | 3 ++- src/crepe/facade/SDLContext.h | 1 - src/crepe/facade/SDLFontContext.cpp | 8 ++++---- src/example/loadfont.cpp | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index cbb0f3b..47dda81 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -75,8 +76,8 @@ SDLContext::~SDLContext() { // thread that SDL_Init() was called on? This has caused problems for me // before. IMG_Quit(); - SDL_Quit(); TTF_Quit(); + SDL_Quit(); } Keycode SDLContext::sdl_to_keycode(SDL_Keycode sdl_key) { diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 76cd99a..efdd6fe 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/src/crepe/facade/SDLFontContext.cpp b/src/crepe/facade/SDLFontContext.cpp index 5123b3b..e0b9a89 100644 --- a/src/crepe/facade/SDLFontContext.cpp +++ b/src/crepe/facade/SDLFontContext.cpp @@ -17,13 +17,13 @@ Asset SDLFontContext::get_font_asset(const string font_family) { // Create a pattern to search for the font family FcPattern * pattern = FcNameParse(reinterpret_cast(font_family.c_str())); - if (!pattern) { + if (pattern == NULL) { throw runtime_error("Failed to create font pattern."); } // Default configuration FcConfig * config = FcConfigGetCurrent(); - if (!config) { + if (config == NULL) { FcPatternDestroy(pattern); throw runtime_error("Failed to get current Fontconfig configuration."); } @@ -33,7 +33,7 @@ Asset SDLFontContext::get_font_asset(const string font_family) { FcPattern * matched_pattern = FcFontMatch(config, pattern, &result); FcPatternDestroy(pattern); - if (!matched_pattern) { + if (matched_pattern == NULL) { FcPatternDestroy(matched_pattern); throw runtime_error("No matching font found."); } @@ -41,7 +41,7 @@ Asset SDLFontContext::get_font_asset(const string font_family) { // Extract the file path FcChar8 * file_path = nullptr; if (FcPatternGetString(matched_pattern, FC_FILE, 0, &file_path) != FcResultMatch - || !file_path) { + || file_path == NULL) { FcPatternDestroy(matched_pattern); throw runtime_error("Failed to get font file path."); } diff --git a/src/example/loadfont.cpp b/src/example/loadfont.cpp index a52e7f0..6020908 100644 --- a/src/example/loadfont.cpp +++ b/src/example/loadfont.cpp @@ -21,7 +21,8 @@ int main() { std::unique_ptr font = std::make_unique(asset, mediator); // Get the TTF_Font from the Font object TTF_Font* ttf_font = font->get_font(); - + //example if the asset is not correct for font + //std::unique_ptr fontThrow = std::make_unique(Asset("../help.txt"), mediator); // Check if the font is loaded properly if (ttf_font != nullptr) { std::cout << "Font successfully loaded!" << std::endl; -- cgit v1.2.3