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

summaryrefslogtreecommitdiff
path: root/source/rendering/StarFontTextureGroup.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-05-03 08:53:18 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-05-03 08:53:18 +1000
commitde3d099d51126f27d553e6b33ba47e0825a3a01a (patch)
tree8fbdc655348e041cd23856d76a7888f128cd2d95 /source/rendering/StarFontTextureGroup.cpp
parent6fc52e2fe7d4964f9e9632110dbe9e8a143b5a0a (diff)
catch image processing errors in font rendering
think this was done before and accidentally undone
Diffstat (limited to 'source/rendering/StarFontTextureGroup.cpp')
-rw-r--r--source/rendering/StarFontTextureGroup.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/source/rendering/StarFontTextureGroup.cpp b/source/rendering/StarFontTextureGroup.cpp
index 60f66f6..e312e8b 100644
--- a/source/rendering/StarFontTextureGroup.cpp
+++ b/source/rendering/StarFontTextureGroup.cpp
@@ -62,26 +62,36 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha
Directives const& directives = *processingDirectives;
Vec2F preSize = Vec2F(image.size());
+ bool broken = false;
for (auto& entry : directives->entries) {
if (auto error = entry.operation.ptr<ErrorImageOperation>()) {
if (auto string = error->cause.ptr<std::string>()) {
if (!string->empty()) {
- Logger::error("Error parsing font directives: {}", *string);
+ Logger::error("Error in parsed font directives: {}", *string);
string->clear();
}
} else if (auto& exception = error->cause.get<std::exception_ptr>()) {
try
{ std::rethrow_exception(error->cause.get<std::exception_ptr>()); }
catch (std::exception const& e)
- { Logger::error("Exception parsing font directives: {}", e.what()); };
+ { Logger::error("Exception in parsed font directives: {}", e.what()); };
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);
+ broken |= true;
+ } else {
+ try { processImageOperation(entry.operation, image); }
+ catch (StarException const& e) {
+ broken |= true;
+ Logger::error("Exception processing font directives for {}px '{}': {}", size, String(c), e.what());
+ }
+ }
+ }
+
+ if (broken) {
+ glyphTexture.colored = true;
+ 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;