Fix crash in Type tool on linux (#2011, #3604)

This commit is contained in:
Le-dragon-dev 2021-02-20 17:33:16 +01:00 committed by manongjohn
parent e70e7ead32
commit 00280c1da5

View file

@ -167,6 +167,19 @@ TPoint TFont::drawChar(QImage &outImage, TPoint &unused, wchar_t charcode,
return TPoint(0, 0);
}
// Workaround for unix when the user using the space character:
// alphaMapForGlyph with a space character returns an invalid
// QImage for some reason.
// Bug 3604: https://github.com/opentoonz/opentoonz/issues/3604
#ifdef Q_OS_UNIX
if (chars[0] == L' ') {
outImage = QImage(raw.averageCharWidth(), raw.ascent() + raw.descent(),
QImage::Format_Grayscale8);
outImage.fill(255);
return getDistance(charcode, nextCharCode);
}
#endif
QImage image = raw.alphaMapForGlyph(indices[0], QRawFont::PixelAntialiasing);
if (image.format() != QImage::Format_Indexed8 &&
image.format() != QImage::Format_Alpha8)