diff --git a/scribus/scfonts.cpp b/scribus/scfonts.cpp index 35c538718b..49ed1f813e 100644 --- a/scribus/scfonts.cpp +++ b/scribus/scfonts.cpp @@ -660,15 +660,19 @@ bool SCFonts::AddScalableFont(const QString& filename, FT_Library &library, cons if (face != nullptr) FT_Done_Face(face); checkedFonts.insert(filename, foCache); + auto errorMessage = QObject::tr("Font %1 is broken, discarding it. Error message: \"%2\"").arg(filename, getFtError(error)); + addRejectedFont(filename, errorMessage); if (showFontInformation) - sDebug(QObject::tr("Font %1 is broken, discarding it. Error message: \"%2\"").arg(filename, getFtError(error))); + qDebug() << errorMessage; return true; } getFontFormat(face, format, type); if (format == ScFace::UNKNOWN_FORMAT) { + auto errorMessage = QObject::tr("Failed to load font %1 - font type unknown").arg(filename); + addRejectedFont(filename, errorMessage); if (showFontInformation) - sDebug(QObject::tr("Failed to load font %1 - font type unknown").arg(filename)); + sDebug(errorMessage); FT_Done_Face(face); checkedFonts.insert(filename, foCache); return true; @@ -677,8 +681,10 @@ bool SCFonts::AddScalableFont(const QString& filename, FT_Library &library, cons // and do not provide a valid value for units_per_EM if (face->units_per_EM == 0) { + auto errorMessage = QObject::tr("Failed to load font %1 - font is not scalable").arg(filename); + addRejectedFont(filename, errorMessage); if (showFontInformation) - sDebug(QObject::tr("Failed to load font %1 - font is not scalable").arg(filename)); + sDebug(errorMessage); FT_Done_Face(face); checkedFonts.insert(filename, foCache); return true; @@ -696,12 +702,14 @@ bool SCFonts::AddScalableFont(const QString& filename, FT_Library &library, cons error = FT_Load_Glyph(face, gindex, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); if (error) { - if (showFontInformation) - sDebug(QObject::tr("Font %1 has broken glyph %2 (charcode U+%3). Error message: \"%4\"") + auto errorMessage = QObject::tr("Font %1 has broken glyph %2 (charcode U+%3). Error message: \"%4\"") .arg(filename) .arg(gindex) .arg(charcode, 4, 16, QChar('0')) - .arg(getFtError(error))); + .arg(getFtError(error)); + addRejectedFont(filename, errorMessage); + if (showFontInformation) + sDebug(errorMessage); FT_Done_Face(face); checkedFonts.insert(filename, foCache); return true; @@ -737,12 +745,14 @@ bool SCFonts::AddScalableFont(const QString& filename, FT_Library &library, cons error = FT_Load_Glyph(face, gindex, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); if (error) { - if (showFontInformation) - sDebug(QObject::tr("Font %1 has broken glyph %2 (charcode U+%3). Error message: \"%4\"") + auto errorMessage = QObject::tr("Font %1 has broken glyph %2 (charcode U+%3). Error message: \"%4\"") .arg(filename) .arg(gindex) .arg(charcode, 4, 16, QChar('0')) - .arg(getFtError(error))); + .arg(getFtError(error)); + addRejectedFont(filename, errorMessage); + if (showFontInformation) + sDebug(errorMessage); FT_Done_Face(face); checkedFonts.insert(filename, foCache); return true; @@ -1021,7 +1031,11 @@ void SCFonts::AddFontconfigFonts() } else if (showFontInformation) - sDebug(QObject::tr("Failed to load a font - freetype2 couldn't find the font file")); + { + auto errorMessage = QObject::tr("Failed to load a font - freetype2 couldn't find the font file"); + addRejectedFont(QString((char*)file), errorMessage); + sDebug(errorMessage); + } } FT_Done_FreeType(library); FcFontSetDestroy(fs); @@ -1221,3 +1235,8 @@ void SCFonts::GetFonts(const QString& pf, bool showFontInfo) updateFontMap(); WriteCacheList(pf); } + +void SCFonts::addRejectedFont(QString fontPath, QString message) +{ + m_rejectedFonts.append({fontPath, message}); +} diff --git a/scribus/scfonts.h b/scribus/scfonts.h index bb2d85915c..b5daeffc36 100644 --- a/scribus/scfonts.h +++ b/scribus/scfonts.h @@ -12,6 +12,8 @@ for which a new license (GPL+exception) is in place. #include #include #include +#include +#include #include #include @@ -54,6 +56,7 @@ class SCRIBUS_API SCFonts : public QMap void WriteCacheList(); /// maps family name to face variants QMap fontMap; + QVector> m_rejectedFonts; private: void ReadCacheList(const QString& pf); void WriteCacheList(const QString& pf); @@ -77,6 +80,7 @@ class SCRIBUS_API SCFonts : public QMap QDateTime lastMod; }; QMap checkedFonts; + void addRejectedFont(QString fontPath, QString message); protected: bool showFontInformation; }; diff --git a/scribus/ui/prefs_fonts.cpp b/scribus/ui/prefs_fonts.cpp index 38a076a69f..fef102704a 100644 --- a/scribus/ui/prefs_fonts.cpp +++ b/scribus/ui/prefs_fonts.cpp @@ -47,7 +47,7 @@ Prefs_Fonts::Prefs_Fonts(QWidget* parent, ScribusDoc* doc) CurrentPath = ""; m_askBeforeSubstitute = true; - setMinimumSize(fontMetrics().width( tr( "Available Fonts" )+ tr( "Font Substitutions" )+ tr( "Additional Paths" ))+180, 200); + setMinimumSize(fontMetrics().width( tr( "Available Fonts" )+ tr( "Font Substitutions" )+ tr( "Additional Paths" )+ tr( "Rejected Fonts" ))+180, 200); fontListTableView->setModel(new FontListModel(fontListTableView, m_doc, true)); @@ -206,6 +206,23 @@ void Prefs_Fonts::restoreDefaults(struct ApplicationPrefs *prefsData) a++; } deleteSubstitutionButton->setEnabled(false); + // fontsRejectedTableWidget->headerView()->resizeSection(0, 500); + auto headerView = fontsRejectedTableWidget->horizontalHeader(); + headerView->resizeSection(0, 150); + headerView->resizeSection(1, 250); + headerView->setStretchLastSection(true); + int i{0}; + for (const auto& font: prefsData->fontPrefs.AvailFonts.m_rejectedFonts) + { + fontsRejectedTableWidget->insertRow (i); + fontsRejectedTableWidget->setItem(i, 0, + new QTableWidgetItem(QFileInfo(font.second).baseName())); + fontsRejectedTableWidget->setItem(i, 1, + new QTableWidgetItem(font.second)); + fontsRejectedTableWidget->setItem(i, 2, + new QTableWidgetItem(font.first)); + i++; + } updateFontList(); } diff --git a/scribus/ui/prefs_fontsbase.ui b/scribus/ui/prefs_fontsbase.ui index 0610623242..cd359066c9 100644 --- a/scribus/ui/prefs_fontsbase.ui +++ b/scribus/ui/prefs_fontsbase.ui @@ -186,6 +186,35 @@ + + + Rejected Fonts + + + + + + 3 + + + + Font name + + + + + Error message + + + + + Font file + + + + + +