From 412c235ed2582e9d90d6320d0ffba376b2c8aac0 Mon Sep 17 00:00:00 2001 From: Le-dragon-dev Date: Feb 20 2021 16:34:44 +0000 Subject: Fix crash in Type tool on linux (#2011, #3604) --- diff --git a/toonz/sources/common/tvrender/tfont_qt.cpp b/toonz/sources/common/tvrender/tfont_qt.cpp index 96d5588..e37d9d3 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)