aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-14 14:45:10 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-14 14:45:10 +0100
commitfda61be91cd8667fa2b51e3b8a17ba6b93b728c8 (patch)
treef44ea9104461ef11ca2441e660485e127da2f64a /src
parent93f0951738d3ac7b0249b5064c3ee7b6270eeb3a (diff)
feedback changes
Diffstat (limited to 'src')
-rw-r--r--src/crepe/facade/SDLContext.cpp3
-rw-r--r--src/crepe/facade/SDLContext.h1
-rw-r--r--src/crepe/facade/SDLFontContext.cpp8
-rw-r--r--src/example/loadfont.cpp3
4 files changed, 8 insertions, 7 deletions
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 <SDL2/SDL_render.h>
#include <SDL2/SDL_surface.h>
#include <SDL2/SDL_video.h>
+#include <SDL2/SDL_ttf.h>
#include <array>
#include <cmath>
#include <cstddef>
@@ -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 <SDL2/SDL_keycode.h>
#include <SDL2/SDL_rect.h>
#include <SDL2/SDL_render.h>
-#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_video.h>
#include <cmath>
#include <functional>
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<const FcChar8 *>(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> font = std::make_unique<Font>(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<Font> fontThrow = std::make_unique<Font>(Asset("../help.txt"), mediator);
// Check if the font is loaded properly
if (ttf_font != nullptr) {
std::cout << "Font successfully loaded!" << std::endl;