Added a precaution to prevent crashes in case of broken fonts being used

This commit is contained in:
Leon Styhre 2024-08-03 14:54:49 +02:00
parent 75b93794b0
commit 7a8bd97226

View file

@ -760,6 +760,9 @@ std::vector<Font::ShapeSegment> Font::shapeText(const std::string& text)
lastCursor = textCursor;
const unsigned int unicode {Utils::String::chars2Unicode(text, textCursor)};
Glyph* currGlyph {getGlyph(unicode)};
// Extra precaution in case the font is really broken.
if (currGlyph == nullptr)
continue;
byteLength = textCursor - lastCursor;
if (unicode == '\'' || unicode == '\n' || currGlyph->fontHB == nullptr) {