Bugfixing: Crash in case of invalid image, invalid font CID character 0 width

This commit is contained in:
Jakub Melka
2020-01-02 13:13:52 +01:00
parent 78b56ab007
commit b490dc7c89
2 changed files with 51 additions and 25 deletions

View File

@ -538,10 +538,17 @@ void PDFRealizedFontImpl::fillTextSequence(const QByteArray& byteArray, TextSequ
}
else
{
reporter->reportRenderError(RenderErrorType::Warning, PDFTranslationContext::tr("Glyph for composite font character with cid '%1' not found.").arg(cid));
if (cid > 0)
{
// Character with CID == 0 is treated as default whitespace, it hasn't glyph
reporter->reportRenderError(RenderErrorType::Warning, PDFTranslationContext::tr("Glyph for composite font character with cid '%1' not found.").arg(cid));
}
if (glyphWidth > 0)
{
textSequence.items.emplace_back(nullptr, QChar(), glyphWidth * m_pixelSize * FONT_WIDTH_MULTIPLIER);
// We do not multiply advance with font size and FONT_WIDTH_MULTIPLIER, because in the code,
// "advance" is treated as in font space.
textSequence.items.emplace_back(nullptr, QChar(), -glyphWidth);
}
}
}