mirror of https://github.com/JakubMelka/PDF4QT.git
Issue #33: ToUnicode for simple fonts not used
This commit is contained in:
parent
cb1c31ba3d
commit
8f6559bf63
|
@ -1259,6 +1259,36 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
|
|||
throw PDFException(PDFTranslationContext::tr("Invalid encoding entry of the font."));
|
||||
}
|
||||
}
|
||||
else if (fontDictionary->hasKey("ToUnicode"))
|
||||
{
|
||||
PDFFontCMap toUnicodeCMap;
|
||||
const PDFObject& toUnicode = document->getObject(fontDictionary->get("ToUnicode"));
|
||||
if (toUnicode.isName())
|
||||
{
|
||||
toUnicodeCMap = PDFFontCMap::createFromName(toUnicode.getString());
|
||||
}
|
||||
else if (toUnicode.isStream())
|
||||
{
|
||||
const PDFStream* stream = toUnicode.getStream();
|
||||
QByteArray decodedStream = document->getDecodedStream(stream);
|
||||
toUnicodeCMap = PDFFontCMap::createFromData(decodedStream);
|
||||
}
|
||||
|
||||
const bool hasToUnicode = toUnicodeCMap.isValid();
|
||||
if (hasToUnicode)
|
||||
{
|
||||
for (size_t i = 0; i < differences.size(); ++i)
|
||||
{
|
||||
QChar character = toUnicodeCMap.getToUnicode(static_cast<CID>(i));
|
||||
|
||||
if (!character.isNull())
|
||||
{
|
||||
differences[i] = character;
|
||||
hasDifferences = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (encoding == PDFEncoding::Encoding::Invalid)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue