From 6f7e2bbb83d518c8df06966d71e83a23ed5dfefd Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:29:51 +1000 Subject: slight font directives changes invalid font directives stopped checkerboarding the glyph texture at some point, fixed that too --- source/rendering/StarFontTextureGroup.cpp | 34 +++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'source/rendering/StarFontTextureGroup.cpp') diff --git a/source/rendering/StarFontTextureGroup.cpp b/source/rendering/StarFontTextureGroup.cpp index 5f0cdbc..cdc667a 100644 --- a/source/rendering/StarFontTextureGroup.cpp +++ b/source/rendering/StarFontTextureGroup.cpp @@ -1,6 +1,7 @@ #include "StarFontTextureGroup.hpp" #include "StarTime.hpp" #include "StarImageProcessing.hpp" +#include "StarLogging.hpp" namespace Star { @@ -58,23 +59,30 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha auto renderResult = font->render(c); Image& image = get<0>(renderResult); if (processingDirectives) { - try { - Directives const& directives = *processingDirectives; - Vec2F preSize = Vec2F(image.size()); - - for (auto& entry : directives->entries) + Directives const& directives = *processingDirectives; + Vec2F preSize = Vec2F(image.size()); + + for (auto& entry : directives->entries) { + if (auto error = entry.operation.ptr()) { + if (error->exception) { + try + { std::rethrow_exception(error->exception); } + catch (std::exception const& e) + { Logger::error("Exception parsing font directives: {}", e.what()); } + error->exception = {}; + } + image.forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) { + pixel = ((x + y) % 2 == 0) ? Vec4B(255, 0, 255, pixel[3]) : Vec4B(0, 0, 0, pixel[3]); + }); + glyphTexture.colored = true; + } else processImageOperation(entry.operation, image); - - glyphTexture.offset = (preSize - Vec2F(image.size())) / 2; - } - catch (StarException const&) { - image.forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) { - pixel = ((x + y) % 2 == 0) ? Vec4B(255, 0, 255, pixel[3]) : Vec4B(0, 0, 0, pixel[3]); - }); } + + glyphTexture.offset = (preSize - Vec2F(image.size())) / 2; } - glyphTexture.colored = get<2>(renderResult); + glyphTexture.colored |= get<2>(renderResult); glyphTexture.offset += Vec2F(get<1>(renderResult)); glyphTexture.texture = m_textureGroup->create(image); } -- cgit v1.2.3