From 67eaa5620d7a2cd063180ace8897b909dde8549e Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 25 Dec 2023 13:01:48 +0800 Subject: [PATCH] PlayClass: do not use QRawFont diff --git src/gui/PlayClass.cpp src/gui/PlayClass.cpp index bcf802ff..21cfee5d 100644 --- src/gui/PlayClass.cpp +++ src/gui/PlayClass.cpp @@ -33,7 +33,18 @@ #include #include +#if QT_VERSION >= 0x050000 + #define USE_QRAWFONT +#endif + #include + +#ifdef USE_QRAWFONT + #include +#else + #include +#endif + #include #include #include @@ -384,9 +395,20 @@ void PlayClass::loadSubsFile(const QString &fileName) { const QByteArray fontData = f.readAll(); f.close(); +#ifdef USE_QRAWFONT const QString fontName = QRawFont(fontData, 0.0).familyName(); if (!fontName.isEmpty()) ass->addFont(fontName.toUtf8(), fontData); +#else // For Qt older than 5.0 + const int fontID = QFontDatabase::addApplicationFontFromData(fontData); + if (fontID != -1) + { + const QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontID); + QFontDatabase::removeApplicationFont(fontID); + if (!fontFamilies.isEmpty()) + ass->addFont(fontFamilies.first().toUtf8(), fontData); + } +#endif } }