Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of a warning if a font cannot be found in the QFontDatabase. #629

Open
edward-dauvergne opened this issue May 15, 2023 · 2 comments

Comments

@edward-dauvergne
Copy link

After some debugging due to a number of Linux font issues, I think I have worked out why gImageReader has not been outputting PDFs as I expected - it silently reverts back to the default font if a word element's font cannot be found. Would it be possible to warn about this? For example with something like:

index d8277ccc..b2c1b5ca 100644
--- a/qt/src/hocr/HOCRPdfExporter.cc
+++ b/qt/src/hocr/HOCRPdfExporter.cc
@@ -562,6 +562,7 @@ PoDoFo::PdfFont* HOCRPoDoFoPdfPrinter::getFont(QString family, bool bold, bool i
        if(it == m_fontCache.end()) {
                if(family.isEmpty() || !m_fontDatabase.hasFamily(family)) {
                        family = m_defaultFontFamily;
+            QMessageBox::warning(MAIN, _("Missing Font"), _("WARNING: Cannot find the font '%1' in the QFontDatabase, switching to the font '%2'.").arg(key).arg(family));
                }
                PoDoFo::PdfFont* font = nullptr;
                try {

This doesn't work, probably as the parent should be HOCRPdfExporter rather than MAIN, but it makes it crystal clear why the PDF output is not what you see in the GUI.

Cheers,

Edward

@manisandro
Copy link
Owner

manisandro commented May 26, 2023

Might make sense to collect all the missing fonts and then display a final warning after the export, rather than risking many popups appearing during the export.

@edward-dauvergne
Copy link
Author

Is there a global data structure for storing this info? I haven't looked too deeply into the code yet. There are a number of font failures that would be useful to report back to the user, so they know that a better result can be obtained by switching away from the failing fonts. I could try coding something in a few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants