From aa36af658756a3e1a892f3bfc1ba039c6b3a85e7 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Tue, 23 Jun 2020 19:28:25 +0200 Subject: [PATCH] Fix display of type 3 fonts --- PdfForQtLib/sources/pdfpagecontentprocessor.cpp | 5 +++-- PdfForQtLib/sources/pdfparser.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/PdfForQtLib/sources/pdfpagecontentprocessor.cpp b/PdfForQtLib/sources/pdfpagecontentprocessor.cpp index f024ac1..813c8ed 100644 --- a/PdfForQtLib/sources/pdfpagecontentprocessor.cpp +++ b/PdfForQtLib/sources/pdfpagecontentprocessor.cpp @@ -2999,14 +2999,15 @@ void PDFPageContentProcessor::drawText(const TextSequence& textSequence) PDFPageContentProcessorStateGuard guard(this); - QMatrix invertedFontMatrix = fontMatrix.inverted(); PDFObject resources = parentFont->getResources(); if (!resources.isNull()) { initDictionaries(resources); } - QMatrix fontAdjustedMatrix = invertedFontMatrix * adjustMatrix; + QMatrix scaleMatrix(fontSize, 0.0, 0.0, fontSize, 0.0, 0.0); + adjustMatrix = scaleMatrix * adjustMatrix; + QMatrix fontAdjustedMatrix = fontMatrix * adjustMatrix; for (const TextSequenceItem& item : textSequence.items) { diff --git a/PdfForQtLib/sources/pdfparser.cpp b/PdfForQtLib/sources/pdfparser.cpp index cfdc0b0..ed45842 100644 --- a/PdfForQtLib/sources/pdfparser.cpp +++ b/PdfForQtLib/sources/pdfparser.cpp @@ -468,7 +468,7 @@ PDFLexicalAnalyzer::Token PDFLexicalAnalyzer::fetch() void PDFLexicalAnalyzer::seek(PDFInteger offset) { const PDFInteger limit = std::distance(m_begin, m_end); - if (offset >= 0 && offset < limit) + if (offset >= 0 && offset <= limit) { m_current = std::next(m_begin, offset); } @@ -545,7 +545,7 @@ PDFInteger PDFLexicalAnalyzer::findSubstring(const char* str, PDFInteger positio const PDFInteger substringLength = qstrlen(str); const PDFInteger startPos = position; const PDFInteger endPos = length - substringLength; - for (PDFInteger i = startPos; i < endPos; ++i) + for (PDFInteger i = startPos; i <= endPos; ++i) { Q_ASSERT(std::distance(m_begin + i + substringLength - 1, m_end) >= 0); if (memcmp(m_begin + i, str, substringLength) == 0)