Better behaviour when font cant be loaded

This commit is contained in:
Jakub Melka 2019-04-06 17:32:36 +02:00
parent cd981183b0
commit 1694d310a8

View File

@ -1529,6 +1529,8 @@ void PDFPageContentProcessor::operatorTextSetFontAndFontSize(PDFOperandName font
if (m_fontDictionary)
{
if (m_fontDictionary->hasKey(fontName.name))
{
try
{
PDFFontPointer font = PDFFont::createFont(m_fontDictionary->get(fontName.name), m_document);
@ -1536,6 +1538,14 @@ void PDFPageContentProcessor::operatorTextSetFontAndFontSize(PDFOperandName font
m_graphicState.setTextFontSize(fontSize);
updateGraphicState();
}
catch (PDFParserException)
{
m_graphicState.setTextFont(nullptr);
m_graphicState.setTextFontSize(fontSize);
updateGraphicState();
throw;
}
}
else
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Font '%1' not found in font dictionary.").arg(QString::fromLatin1(fontName.name)));