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 54b33fcd28
commit 934a6e5418

View file

@ -284,6 +284,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;