From 8abc6008880dd9ed0c16a68a126b49f0eb03caa2 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Mon, 16 Dec 2024 20:52:43 +0100 Subject: fonting --- src/crepe/api/Text.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/crepe/api/Text.cpp') diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp index 5b2befe..07d1705 100644 --- a/src/crepe/api/Text.cpp +++ b/src/crepe/api/Text.cpp @@ -1,4 +1,5 @@ #include "../facade/FontFacade.h" +#include "util/Log.h" #include "Text.h" @@ -9,4 +10,6 @@ Text::Text(game_object_id_t id, const vec2 & dimensions, const vec2 & offset, : UIObject(id, dimensions, offset), text(text), data(data), - font(FontFacade::get_font_asset(font_family)) {} + font(FontFacade::get_font_asset(font_family)) { + dbg_trace(); +} -- cgit v1.2.3 From 36f941aa1cdea5faeec20a0dc793e0538ccd6d15 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Tue, 17 Dec 2024 20:47:14 +0100 Subject: implemented feedback --- src/crepe/api/Text.cpp | 3 --- src/crepe/api/Text.h | 2 -- src/crepe/facade/Font.cpp | 2 -- src/crepe/facade/Font.h | 2 +- src/crepe/facade/SDLContext.cpp | 4 ++-- src/crepe/system/RenderSystem.cpp | 1 - 6 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src/crepe/api/Text.cpp') diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp index 9d57abd..4a94180 100644 --- a/src/crepe/api/Text.cpp +++ b/src/crepe/api/Text.cpp @@ -1,6 +1,3 @@ -#include "../facade/FontFacade.h" -#include "util/Log.h" - #include "Text.h" using namespace crepe; diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h index c30dc80..da40141 100644 --- a/src/crepe/api/Text.h +++ b/src/crepe/api/Text.h @@ -3,8 +3,6 @@ #include #include -#include "../Component.h" - #include "Asset.h" #include "Color.h" #include "UIObject.h" diff --git a/src/crepe/facade/Font.cpp b/src/crepe/facade/Font.cpp index 0c670c1..771002f 100644 --- a/src/crepe/facade/Font.cpp +++ b/src/crepe/facade/Font.cpp @@ -2,7 +2,6 @@ #include "../api/Asset.h" #include "../api/Config.h" -#include #include "Font.h" @@ -12,7 +11,6 @@ using namespace crepe; Font::Font(const Asset & src, Mediator & mediator) : Resource(src, mediator) { const Config & config = Config::get_instance(); const std::string FONT_PATH = src.get_path(); - TTF_Font * loaded_font = TTF_OpenFont(FONT_PATH.c_str(), config.font.size); if (loaded_font == NULL) { throw runtime_error(format("Font: {} (path: {})", TTF_GetError(), FONT_PATH)); diff --git a/src/crepe/facade/Font.h b/src/crepe/facade/Font.h index b08366d..b208d96 100644 --- a/src/crepe/facade/Font.h +++ b/src/crepe/facade/Font.h @@ -1,10 +1,10 @@ #pragma once #include -#include #include #include "../Resource.h" +#include "../api/Config.h" namespace crepe { diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index ea3b71c..9a122f5 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -208,14 +208,14 @@ void SDLContext::draw_text(const RenderText & data) { }; SDL_Surface * tmp_font_surface = TTF_RenderText_Solid(font.get_font(), text.text.c_str(), color); - if (!tmp_font_surface) { + if (tmp_font_surface == NULL) { throw runtime_error(format("draw_text: font surface error: {}", SDL_GetError())); } font_surface = {tmp_font_surface, [](SDL_Surface * surface) { SDL_FreeSurface(surface); }}; SDL_Texture * tmp_font_texture = SDL_CreateTextureFromSurface(this->game_renderer.get(), font_surface.get()); - if (!tmp_font_texture) { + if (tmp_font_texture == NULL) { throw runtime_error(format("draw_text: font texture error: {}", SDL_GetError())); } font_texture diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 4082591..bf2bfd3 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -87,7 +87,6 @@ void RenderSystem::render_text() { if (!text.active) continue; if (!text.font.has_value()) text.font.emplace(ctx.get_font_from_name(text.font_family)); - if (!text.font.has_value()) continue; const Font & font = resource_manager.get(text.font.value()); const auto & transform -- cgit v1.2.3