From 00280c1da5cd412a328637acfd9e9333adb1fdef Mon Sep 17 00:00:00 2001 From: Le-dragon-dev Date: Sat, 20 Feb 2021 17:33:16 +0100 Subject: [PATCH] Fix crash in Type tool on linux (#2011, #3604) --- toonz/sources/common/tvrender/tfont_qt.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/toonz/sources/common/tvrender/tfont_qt.cpp b/toonz/sources/common/tvrender/tfont_qt.cpp index 96d55888..e37d9d32 100644 --- a/toonz/sources/common/tvrender/tfont_qt.cpp +++ b/toonz/sources/common/tvrender/tfont_qt.cpp @@ -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)