catch image processing errors in font rendering
think this was done before and accidentally undone
This commit is contained in:
parent
6fc52e2fe7
commit
de3d099d51
@ -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 = {};
|
||||
}
|
||||
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.colored = true;
|
||||
} else
|
||||
processImageOperation(entry.operation, image);
|
||||
}
|
||||
|
||||
glyphTexture.offset = (preSize - Vec2F(image.size())) / 2;
|
||||
|
Loading…
Reference in New Issue
Block a user