From 1694d310a87085b6f55aaf4b5fdcefba5dd9cf27 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Sat, 6 Apr 2019 17:32:36 +0200 Subject: [PATCH] Better behaviour when font cant be loaded --- .../sources/pdfpagecontentprocessor.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/PdfForQtLib/sources/pdfpagecontentprocessor.cpp b/PdfForQtLib/sources/pdfpagecontentprocessor.cpp index b186e4e..ba2039a 100644 --- a/PdfForQtLib/sources/pdfpagecontentprocessor.cpp +++ b/PdfForQtLib/sources/pdfpagecontentprocessor.cpp @@ -1530,11 +1530,21 @@ void PDFPageContentProcessor::operatorTextSetFontAndFontSize(PDFOperandName font { if (m_fontDictionary->hasKey(fontName.name)) { - PDFFontPointer font = PDFFont::createFont(m_fontDictionary->get(fontName.name), m_document); + try + { + PDFFontPointer font = PDFFont::createFont(m_fontDictionary->get(fontName.name), m_document); - m_graphicState.setTextFont(qMove(font)); - m_graphicState.setTextFontSize(fontSize); - updateGraphicState(); + m_graphicState.setTextFont(qMove(font)); + m_graphicState.setTextFontSize(fontSize); + updateGraphicState(); + } + catch (PDFParserException) + { + m_graphicState.setTextFont(nullptr); + m_graphicState.setTextFontSize(fontSize); + updateGraphicState(); + throw; + } } else {