From bf70b4dbed2b278413337a3e312991b5b085a686 Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Thu, 5 Mar 2026 22:07:12 +0100 Subject: [PATCH] Added PixelRenderer::Font class --- other/build.nr | 2 +- src/ogfx/PixelRenderer.hpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/other/build.nr b/other/build.nr index 22c92a2..5bc0067 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -1971 +1972 diff --git a/src/ogfx/PixelRenderer.hpp b/src/ogfx/PixelRenderer.hpp index 856c55b..f85ae73 100644 --- a/src/ogfx/PixelRenderer.hpp +++ b/src/ogfx/PixelRenderer.hpp @@ -1,5 +1,7 @@ #pragma once +#include "IOHandlers.hpp" +#include "String.hpp" #include #include #include @@ -33,6 +35,27 @@ namespace ogfx inline static int8_t s_cursor_pos_x = 0; }; + public: class Font + { + public: + inline Font(void) { } + inline Font(const ostd::String& fontPath) + { + ostd::ConsoleOutputHandler out; + m_fontSurface = SDL_LoadBMP(fontPath.c_str()); + if (m_fontSurface == NULL) + out.bg(ostd::ConsoleColors::Red).p("Error loading pixel font.").reset().nl(); + m_fontPixels = (uint32_t*)m_fontSurface->pixels; + } + inline ~Font(void) + { + SDL_FreeSurface(m_fontSurface); + } + + public: + SDL_Surface* m_fontSurface { nullptr }; + uint32_t* m_fontPixels { nullptr }; + }; public: inline PixelRenderer(void) { invalidate(); } ~PixelRenderer(void);