ttf: prevent crash while converting utf8 to unicode

If wrong utf8 sequence if given as an input, decoding
return nullptr and it has to be handled correctly.
This commit is contained in:
Mira Grudzinska 2025-04-10 10:09:58 +02:00 committed by Hermet Park
parent ee8eebfef8
commit 852424e69d

View file

@ -277,6 +277,7 @@ bool TtfLoader::read(Shape* shape, char* text, FontMetrics& out)
auto n = strlen(text); auto n = strlen(text);
auto code = _codepoints(text, n); auto code = _codepoints(text, n);
if (!code) return false;
//TODO: optimize with the texture-atlas? //TODO: optimize with the texture-atlas?
TtfGlyphMetrics gmetrics; TtfGlyphMetrics gmetrics;