Fixed a text shaping issue when there was a font change for the last character of a string

This commit is contained in:
Leon Styhre 2024-08-01 14:36:29 +02:00
parent 84e850a507
commit 81bc30cc26

View file

@ -713,6 +713,9 @@ bool Font::buildShapeSegments(const std::string& text)
else if (textCursor == text.length()) {
// Last (and possibly only) segment for this text.
addSegment = true;
// In case the font changed for the last character.
if (lastFont != nullptr && lastFont != currGlyph->fontHB)
textCursor -= byteLength;
}
else if (lastFont != nullptr && lastFont != currGlyph->fontHB) {
// The font changed, which requires a new segment.