Editor plugin: WIP

This commit is contained in:
Jakub Melka
2024-04-20 19:41:14 +02:00
parent b481b3afcc
commit d255e27fd3
12 changed files with 454 additions and 60 deletions

View File

@@ -295,7 +295,7 @@ private:
class PDF4QTLIBCORESHARED_EXPORT PDFFont
{
public:
explicit PDFFont(CIDSystemInfo CIDSystemInfo, FontDescriptor fontDescriptor);
explicit PDFFont(CIDSystemInfo CIDSystemInfo, QByteArray fontId, FontDescriptor fontDescriptor);
virtual ~PDFFont() = default;
/// Returns the font type
@@ -318,8 +318,9 @@ public:
/// Creates font from the object. If font can't be created, exception is thrown.
/// \param object Font dictionary
/// \param fontId Font ID
/// \param document Document
static PDFFontPointer createFont(const PDFObject& object, const PDFDocument* document);
static PDFFontPointer createFont(const PDFObject& object, QByteArray fontId, const PDFDocument* document);
/// Tries to read font descriptor from the object
/// \param fontDescriptorObject Font descriptor dictionary
@@ -331,9 +332,13 @@ public:
/// \param document Document
static CIDSystemInfo readCIDSystemInfo(const PDFObject& cidSystemInfoObject, const PDFDocument* document);
/// Returns font id from the font dictionary
QByteArray getFontId() const;
protected:
CIDSystemInfo m_CIDSystemInfo;
FontDescriptor m_fontDescriptor;
QByteArray m_fontId;
};
/// Simple font, see PDF reference 1.7, chapter 5.5. Simple fonts have encoding table,
@@ -344,6 +349,7 @@ class PDFSimpleFont : public PDFFont
public:
explicit PDFSimpleFont(CIDSystemInfo cidSystemInfo,
QByteArray fontId,
FontDescriptor fontDescriptor,
QByteArray name,
QByteArray baseFont,
@@ -381,6 +387,7 @@ class PDFType1Font : public PDFSimpleFont
public:
explicit PDFType1Font(FontType fontType,
QByteArray fontId,
CIDSystemInfo cidSystemInfo,
FontDescriptor fontDescriptor,
QByteArray name,
@@ -434,7 +441,8 @@ public:
/// Retrieves font from the cache. If font can't be accessed or created,
/// then exception is thrown.
/// \param fontObject Font object
PDFFontPointer getFont(const PDFObject& fontObject) const;
/// \param fontId Font identification in resource dictionary
PDFFontPointer getFont(const PDFObject& fontObject, const QByteArray& fontId) const;
/// Retrieves realized font from the cache. If realized font can't be accessed or created,
/// then exception is thrown.
@@ -600,6 +608,7 @@ class PDFType3Font : public PDFFont
{
public:
explicit PDFType3Font(FontDescriptor fontDescriptor,
QByteArray fontId,
int firstCharacterIndex,
int lastCharacterIndex,
QTransform fontMatrix,
@@ -641,8 +650,15 @@ private:
class PDFType0Font : public PDFFont
{
public:
explicit inline PDFType0Font(CIDSystemInfo cidSystemInfo, FontDescriptor fontDescriptor, PDFFontCMap cmap, PDFFontCMap toUnicode, PDFCIDtoGIDMapper mapper, PDFReal defaultAdvance, std::unordered_map<CID, PDFReal> advances) :
PDFFont(qMove(cidSystemInfo), qMove(fontDescriptor)),
explicit inline PDFType0Font(CIDSystemInfo cidSystemInfo,
QByteArray fontId,
FontDescriptor fontDescriptor,
PDFFontCMap cmap,
PDFFontCMap toUnicode,
PDFCIDtoGIDMapper mapper,
PDFReal defaultAdvance,
std::unordered_map<CID, PDFReal> advances) :
PDFFont(qMove(cidSystemInfo), qMove(fontId), qMove(fontDescriptor)),
m_cmap(qMove(cmap)),
m_toUnicode(qMove(toUnicode)),
m_mapper(qMove(mapper)),