Skip to content

Commit

Permalink
Issue #173: errors loading file Echoplex.pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubMelka committed Mar 21, 2024
1 parent 8b832cc commit 1e52c0c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
35 changes: 34 additions & 1 deletion Pdf4QtLibCore/sources/pdffont.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2022 Jakub Melka
// Copyright (C) 2019-2024 Jakub Melka
//
// This file is part of PDF4QT.
//
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Pdf4QtLibCore/sources/pdffont.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2021 Jakub Melka
// Copyright (C) 2019-2024 Jakub Melka
//
// This file is part of PDF4QT.
//
Expand Down
1 change: 1 addition & 0 deletions RELEASES.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 1e52c0c

Please sign in to comment.