From 1e52c0c063224d28587c2bd1aec93625fb050e3e Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Thu, 21 Mar 2024 15:29:29 +0100 Subject: [PATCH] Issue #173: errors loading file Echoplex.pdf --- Pdf4QtLibCore/sources/pdffont.cpp | 35 ++++++++++++++++++++++++++++++- Pdf4QtLibCore/sources/pdffont.h | 2 +- RELEASES.txt | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Pdf4QtLibCore/sources/pdffont.cpp b/Pdf4QtLibCore/sources/pdffont.cpp index 79c452e..d461849 100644 --- a/Pdf4QtLibCore/sources/pdffont.cpp +++ b/Pdf4QtLibCore/sources/pdffont.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2022 Jakub Melka +// Copyright (C) 2019-2024 Jakub Melka // // This file is part of PDF4QT. // @@ -93,6 +93,23 @@ static constexpr std::array S_DEFAULT_CJK_FONTS = PDF_Default_CJK_Font{ ECjkDefaultFontType::AdobeKorea, true, "Batang" }, }; +struct PDF_Font_Replacement +{ + const char* origFont; + const char* replaceFont; +}; + +static constexpr std::array S_FONT_REPLACEMENTS +{ + PDF_Font_Replacement{"Futura", "Calibri"}, + PDF_Font_Replacement{"Utopia-Bold", "Georgia"}, + PDF_Font_Replacement{"Utopia-BoldItalic", "Georgia"}, + PDF_Font_Replacement{"Utopia-Italic", "Georgia"}, + PDF_Font_Replacement{"Utopia-Semibold", "Georgia"}, + PDF_Font_Replacement{"Utopia-SemiboldItalic", "Georgia"}, + PDF_Font_Replacement{"Utopia", "Georgia"}, +}; + /// Storage class for system fonts class PDFSystemFontInfoStorage { @@ -250,6 +267,22 @@ QByteArray PDFSystemFontInfoStorage::loadFont(const CIDSystemInfo* cidSystemInfo } } + if (fontData.isEmpty()) + { + for (const PDF_Font_Replacement& fontReplacement : S_FONT_REPLACEMENTS) + { + if (fontName.contains(QLatin1String(fontReplacement.origFont))) + { + fontData = loadFontImpl(descriptor, QString(fontReplacement.replaceFont), StandardFontType::Invalid, reporter); + + if (!fontData.isEmpty()) + { + return fontData; + } + } + } + } + return fontData; } diff --git a/Pdf4QtLibCore/sources/pdffont.h b/Pdf4QtLibCore/sources/pdffont.h index 9f5863e..1b12fb8 100644 --- a/Pdf4QtLibCore/sources/pdffont.h +++ b/Pdf4QtLibCore/sources/pdffont.h @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2021 Jakub Melka +// Copyright (C) 2019-2024 Jakub Melka // // This file is part of PDF4QT. // diff --git a/RELEASES.txt b/RELEASES.txt index 8eb5bff..9668c84 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -1,4 +1,5 @@ CURRENT: + - Issue #173: errors loading file Echoplex.pdf - Issue #172: access keys are missing from most menu items/action text strings - Issue #168: When opening a PDF file or merging some PDF files, stamp will disappear. - Issue #164: Taskbar icon not shown in linux mint.