Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/core/StarDirectives.cpp2
-rw-r--r--source/rendering/StarFontTextureGroup.cpp34
2 files changed, 22 insertions, 14 deletions
diff --git a/source/core/StarDirectives.cpp b/source/core/StarDirectives.cpp
index 89985a0..b995b37 100644
--- a/source/core/StarDirectives.cpp
+++ b/source/core/StarDirectives.cpp
@@ -140,7 +140,7 @@ void Directives::parse(String&& directives) {
}
catch (StarException const& e) {
prefix = split;
- return;
+ entries.emplace_back(ImageOperation(ErrorImageOperation{std::current_exception()}), beg, end);
}
}
else {
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);
}