mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Support for MMType1 fonts, minor bugfixing
This commit is contained in:
@ -480,6 +480,7 @@ void PDFRealizedFontImpl::fillTextSequence(const QByteArray& byteArray, TextSequ
|
|||||||
{
|
{
|
||||||
case FontType::Type1:
|
case FontType::Type1:
|
||||||
case FontType::TrueType:
|
case FontType::TrueType:
|
||||||
|
case FontType::MMType1:
|
||||||
{
|
{
|
||||||
// We can use encoding
|
// We can use encoding
|
||||||
Q_ASSERT(dynamic_cast<PDFSimpleFont*>(m_parentFont.get()));
|
Q_ASSERT(dynamic_cast<PDFSimpleFont*>(m_parentFont.get()));
|
||||||
@ -808,7 +809,7 @@ PDFRealizedFontPointer PDFRealizedFont::createRealizedFont(PDFFontPointer font,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StandardFontType standardFontType = StandardFontType::Invalid;
|
StandardFontType standardFontType = StandardFontType::Invalid;
|
||||||
if (font->getFontType() == FontType::Type1)
|
if (font->getFontType() == FontType::Type1 || font->getFontType() == FontType::MMType1)
|
||||||
{
|
{
|
||||||
Q_ASSERT(dynamic_cast<const PDFType1Font*>(font.get()));
|
Q_ASSERT(dynamic_cast<const PDFType1Font*>(font.get()));
|
||||||
const PDFType1Font* type1Font = static_cast<const PDFType1Font*>(font.get());
|
const PDFType1Font* type1Font = static_cast<const PDFType1Font*>(font.get());
|
||||||
@ -905,11 +906,12 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
|
|||||||
PDFDocumentDataLoaderDecorator fontLoader(document);
|
PDFDocumentDataLoaderDecorator fontLoader(document);
|
||||||
|
|
||||||
// First, determine the font subtype
|
// First, determine the font subtype
|
||||||
constexpr const std::array<std::pair<const char*, FontType>, 4> fontTypes = {
|
constexpr const std::array fontTypes = {
|
||||||
std::pair<const char*, FontType>{ "Type0", FontType::Type0 },
|
std::pair<const char*, FontType>{ "Type0", FontType::Type0 },
|
||||||
std::pair<const char*, FontType>{ "Type1", FontType::Type1 },
|
std::pair<const char*, FontType>{ "Type1", FontType::Type1 },
|
||||||
std::pair<const char*, FontType>{ "TrueType", FontType::TrueType },
|
std::pair<const char*, FontType>{ "TrueType", FontType::TrueType },
|
||||||
std::pair<const char*, FontType>{ "Type3", FontType::Type3}
|
std::pair<const char*, FontType>{ "Type3", FontType::Type3},
|
||||||
|
std::pair<const char*, FontType>{ "MMType1", FontType::MMType1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
const FontType fontType = fontLoader.readEnumByName(fontDictionary->get("Subtype"), fontTypes.cbegin(), fontTypes.cend(), FontType::Invalid);
|
const FontType fontType = fontLoader.readEnumByName(fontDictionary->get("Subtype"), fontTypes.cbegin(), fontTypes.cend(), FontType::Invalid);
|
||||||
@ -966,6 +968,7 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
|
|||||||
switch (fontType)
|
switch (fontType)
|
||||||
{
|
{
|
||||||
case FontType::Type1:
|
case FontType::Type1:
|
||||||
|
case FontType::MMType1:
|
||||||
case FontType::TrueType:
|
case FontType::TrueType:
|
||||||
{
|
{
|
||||||
bool hasDifferences = false;
|
bool hasDifferences = false;
|
||||||
@ -1417,7 +1420,8 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
|
|||||||
switch (fontType)
|
switch (fontType)
|
||||||
{
|
{
|
||||||
case FontType::Type1:
|
case FontType::Type1:
|
||||||
return PDFFontPointer(new PDFType1Font(qMove(fontDescriptor), qMove(name), qMove(baseFont), firstChar, lastChar, qMove(widths), encoding, simpleFontEncodingTable, standardFont, glyphIndexArray));
|
case FontType::MMType1:
|
||||||
|
return PDFFontPointer(new PDFType1Font(fontType, qMove(fontDescriptor), qMove(name), qMove(baseFont), firstChar, lastChar, qMove(widths), encoding, simpleFontEncodingTable, standardFont, glyphIndexArray));
|
||||||
|
|
||||||
case FontType::TrueType:
|
case FontType::TrueType:
|
||||||
return PDFFontPointer(new PDFTrueTypeFont(qMove(fontDescriptor), qMove(name), qMove(baseFont), firstChar, lastChar, qMove(widths), encoding, simpleFontEncodingTable, glyphIndexArray));
|
return PDFFontPointer(new PDFTrueTypeFont(qMove(fontDescriptor), qMove(name), qMove(baseFont), firstChar, lastChar, qMove(widths), encoding, simpleFontEncodingTable, glyphIndexArray));
|
||||||
@ -1524,7 +1528,8 @@ void PDFSimpleFont::dumpFontToTreeItem(QTreeWidgetItem* item) const
|
|||||||
new QTreeWidgetItem(item, { PDFTranslationContext::tr("Encoding"), encodingTypeString });
|
new QTreeWidgetItem(item, { PDFTranslationContext::tr("Encoding"), encodingTypeString });
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFType1Font::PDFType1Font(FontDescriptor fontDescriptor,
|
PDFType1Font::PDFType1Font(FontType fontType,
|
||||||
|
FontDescriptor fontDescriptor,
|
||||||
QByteArray name,
|
QByteArray name,
|
||||||
QByteArray baseFont,
|
QByteArray baseFont,
|
||||||
PDFInteger firstChar,
|
PDFInteger firstChar,
|
||||||
@ -1535,6 +1540,7 @@ PDFType1Font::PDFType1Font(FontDescriptor fontDescriptor,
|
|||||||
StandardFontType standardFontType,
|
StandardFontType standardFontType,
|
||||||
GlyphIndices glyphIndices) :
|
GlyphIndices glyphIndices) :
|
||||||
PDFSimpleFont(qMove(fontDescriptor), qMove(name), qMove(baseFont), firstChar, lastChar, qMove(widths), encodingType, encoding, glyphIndices),
|
PDFSimpleFont(qMove(fontDescriptor), qMove(name), qMove(baseFont), firstChar, lastChar, qMove(widths), encodingType, encoding, glyphIndices),
|
||||||
|
m_fontType(fontType),
|
||||||
m_standardFontType(standardFontType)
|
m_standardFontType(standardFontType)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1542,7 +1548,7 @@ PDFType1Font::PDFType1Font(FontDescriptor fontDescriptor,
|
|||||||
|
|
||||||
FontType PDFType1Font::getFontType() const
|
FontType PDFType1Font::getFontType() const
|
||||||
{
|
{
|
||||||
return FontType::Type1;
|
return m_fontType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFType1Font::dumpFontToTreeItem(QTreeWidgetItem* item) const
|
void PDFType1Font::dumpFontToTreeItem(QTreeWidgetItem* item) const
|
||||||
|
@ -129,6 +129,7 @@ enum class FontType
|
|||||||
Invalid,
|
Invalid,
|
||||||
Type0,
|
Type0,
|
||||||
Type1,
|
Type1,
|
||||||
|
MMType1,
|
||||||
TrueType,
|
TrueType,
|
||||||
Type3
|
Type3
|
||||||
};
|
};
|
||||||
@ -321,7 +322,8 @@ class PDFType1Font : public PDFSimpleFont
|
|||||||
using BaseClass = PDFSimpleFont;
|
using BaseClass = PDFSimpleFont;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PDFType1Font(FontDescriptor fontDescriptor,
|
explicit PDFType1Font(FontType fontType,
|
||||||
|
FontDescriptor fontDescriptor,
|
||||||
QByteArray name,
|
QByteArray name,
|
||||||
QByteArray baseFont,
|
QByteArray baseFont,
|
||||||
PDFInteger firstChar,
|
PDFInteger firstChar,
|
||||||
@ -340,6 +342,7 @@ public:
|
|||||||
StandardFontType getStandardFontType() const { return m_standardFontType; }
|
StandardFontType getStandardFontType() const { return m_standardFontType; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FontType m_fontType;
|
||||||
StandardFontType m_standardFontType; ///< Type of the standard font (or invalid, if it is not a standard font)
|
StandardFontType m_standardFontType; ///< Type of the standard font (or invalid, if it is not a standard font)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ PDFOptionalContentConfiguration::UsageApplication PDFOptionalContentConfiguratio
|
|||||||
PDFDocumentDataLoaderDecorator loader(document);
|
PDFDocumentDataLoaderDecorator loader(document);
|
||||||
const PDFDictionary* dictionary = dereferencedObject.getDictionary();
|
const PDFDictionary* dictionary = dereferencedObject.getDictionary();
|
||||||
result.event = loader.readNameFromDictionary(dictionary, "Event");
|
result.event = loader.readNameFromDictionary(dictionary, "Event");
|
||||||
result.optionalContengGroups = loader.readReferenceArrayFromDictionary(dictionary, "OCGs");
|
result.optionalContentGroups = loader.readReferenceArrayFromDictionary(dictionary, "OCGs");
|
||||||
result.categories = loader.readNameArrayFromDictionary(dictionary, "Category");
|
result.categories = loader.readNameArrayFromDictionary(dictionary, "Category");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ void PDFOptionalContentActivity::applyConfiguration(const PDFOptionalContentConf
|
|||||||
|
|
||||||
if (usage == m_usage)
|
if (usage == m_usage)
|
||||||
{
|
{
|
||||||
for (PDFObjectReference ocg : usageApplication.optionalContengGroups)
|
for (PDFObjectReference ocg : usageApplication.optionalContentGroups)
|
||||||
{
|
{
|
||||||
if (!m_properties->hasOptionalContentGroup(ocg))
|
if (!m_properties->hasOptionalContentGroup(ocg))
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@ public:
|
|||||||
struct UsageApplication
|
struct UsageApplication
|
||||||
{
|
{
|
||||||
QByteArray event;
|
QByteArray event;
|
||||||
std::vector<PDFObjectReference> optionalContengGroups;
|
std::vector<PDFObjectReference> optionalContentGroups;
|
||||||
std::vector<QByteArray> categories;
|
std::vector<QByteArray> categories;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3131,7 +3131,7 @@ void PDFPageContentProcessor::drawText(const TextSequence& textSequence)
|
|||||||
fontAdjustedMatrix.map(item.advance, 0.0, &displacementX, &ry);
|
fontAdjustedMatrix.map(item.advance, 0.0, &displacementX, &ry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.characterContentStream)
|
if (item.characterContentStream && (fill || stroke))
|
||||||
{
|
{
|
||||||
PDFPageContentProcessorStateGuard guard(this);
|
PDFPageContentProcessorStateGuard guard(this);
|
||||||
|
|
||||||
|
@ -328,6 +328,10 @@ void PDFDocumentPropertiesDialog::initializeFonts(const pdf::PDFDocument* docume
|
|||||||
fontTypeString = tr("Type1 (8 bit keyed)");
|
fontTypeString = tr("Type1 (8 bit keyed)");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case pdf::FontType::MMType1:
|
||||||
|
fontTypeString = tr("MMType1 (8 bit keyed)");
|
||||||
|
break;
|
||||||
|
|
||||||
case pdf::FontType::Type3:
|
case pdf::FontType::Type3:
|
||||||
fontTypeString = tr("Type3 (content streams for font glyphs)");
|
fontTypeString = tr("Type3 (content streams for font glyphs)");
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user