diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-24 16:29:51 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-24 16:29:51 +1000 |
commit | 6f7e2bbb83d518c8df06966d71e83a23ed5dfefd (patch) | |
tree | 1cdacfaaa834f841a43d63a480b214b34b97545c /source/rendering/StarFontTextureGroup.cpp | |
parent | f58702683fda7d9b6c26548b1cf7e2382f958893 (diff) |
slight font directives changes
invalid font directives stopped checkerboarding the glyph texture at some point, fixed that too
Diffstat (limited to 'source/rendering/StarFontTextureGroup.cpp')
-rw-r--r-- | source/rendering/StarFontTextureGroup.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
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<ErrorImageOperation>()) { + 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); } |