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()) { if (auto string = error->cause.ptr()) { 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()) { try { std::rethrow_exception(error->cause.get()); } 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;