summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/include/fpdfapi/fpdf_resource.h185
-rw-r--r--core/include/fxcrt/fx_basic.h45
2 files changed, 113 insertions, 117 deletions
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h
index 268e75c7bf..1aa0347c6e 100644
--- a/core/include/fpdfapi/fpdf_resource.h
+++ b/core/include/fpdfapi/fpdf_resource.h
@@ -331,64 +331,53 @@ public:
FX_WCHAR m_Unicodes[256];
};
+
class CPDF_SimpleFont : public CPDF_Font
{
public:
explicit CPDF_SimpleFont(int fonttype);
~CPDF_SimpleFont() override;
- CPDF_FontEncoding* GetEncoding()
+ CPDF_FontEncoding* GetEncoding()
{
return &m_Encoding;
}
- virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
- virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
- virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL);
- virtual FX_BOOL IsUnicodeCompatible() const;
+ int GetCharWidthF(FX_DWORD charcode, int level = 0) override;
+ void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0) override;
+ int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL) override;
+ FX_BOOL IsUnicodeCompatible() const override;
+
protected:
+ FX_BOOL LoadCommon();
- FX_BOOL LoadCommon();
+ void LoadSubstFont();
- void LoadSubstFont();
+ void LoadFaceMetrics();
- void LoadFaceMetrics();
+ virtual void LoadGlyphMap() = 0;
- virtual void LoadGlyphMap() = 0;
- virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const
+ FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const override
{
return m_Encoding.UnicodeFromCharCode((uint8_t)charcode);
}
- virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const
+
+ FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const override
{
return m_Encoding.CharCodeFromUnicode(Unicode);
}
+ void LoadCharMetrics(int charcode);
-
- CPDF_FontEncoding m_Encoding;
-
- FX_WORD m_GlyphIndex[256];
- FX_WORD m_ExtGID[256];
-
-
-
-
- CFX_ByteString* m_pCharNames;
-
- int m_BaseEncoding;
-
-
-
-
- FX_WORD m_CharWidth[256];
-
- FX_SMALL_RECT m_CharBBox[256];
-
- FX_BOOL m_bUseFontWidth;
-
- void LoadCharMetrics(int charcode);
-
+ CPDF_FontEncoding m_Encoding;
+ FX_WORD m_GlyphIndex[256];
+ FX_WORD m_ExtGID[256];
+ CFX_ByteString* m_pCharNames;
+ int m_BaseEncoding;
+ FX_WORD m_CharWidth[256];
+ FX_SMALL_RECT m_CharBBox[256];
+ FX_BOOL m_bUseFontWidth;
};
+
class CPDF_Type1Font : public CPDF_SimpleFont
{
public:
@@ -447,34 +436,39 @@ class CPDF_Type3Font : public CPDF_SimpleFont
public:
CPDF_Type3Font();
~CPDF_Type3Font() override;
- void SetPageResources(CPDF_Dictionary* pResources)
+
+ void SetPageResources(CPDF_Dictionary* pResources)
{
m_pPageResources = pResources;
}
- CPDF_Type3Char* LoadChar(FX_DWORD charcode, int level = 0);
- virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
- virtual int GetCharTypeWidth(FX_DWORD charcode)
+ CPDF_Type3Char* LoadChar(FX_DWORD charcode, int level = 0);
+ int GetCharWidthF(FX_DWORD charcode, int level = 0) override;
+ int GetCharTypeWidth(FX_DWORD charcode) override
{
return GetCharWidthF(charcode);
}
- virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
- CFX_AffineMatrix& GetFontMatrix()
+ void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0) override;
+ CFX_AffineMatrix& GetFontMatrix()
{
return m_FontMatrix;
}
- void CheckType3FontMetrics();
-private:
- virtual FX_BOOL _Load();
- virtual void LoadGlyphMap() {}
- int m_CharWidthL[256];
- CPDF_Dictionary* m_pCharProcs;
- CPDF_Dictionary* m_pPageResources;
- CPDF_Dictionary* m_pFontResources;
- CFX_MapPtrToPtr m_CacheMap;
- CFX_MapPtrToPtr m_DeletedMap;
+ void CheckType3FontMetrics();
+
protected:
- CFX_AffineMatrix m_FontMatrix;
+ CFX_AffineMatrix m_FontMatrix;
+
+private:
+ FX_BOOL _Load() override;
+ void LoadGlyphMap() override {}
+
+ int m_CharWidthL[256];
+ CPDF_Dictionary* m_pCharProcs;
+ CPDF_Dictionary* m_pPageResources;
+ CPDF_Dictionary* m_pFontResources;
+ CFX_MapPtrToPtr m_CacheMap;
+ CFX_MapPtrToPtr m_DeletedMap;
};
+
#define CIDSET_UNKNOWN 0
#define CIDSET_GB1 1
#define CIDSET_CNS1 2
@@ -489,63 +483,62 @@ public:
CPDF_CIDFont();
- virtual ~CPDF_CIDFont();
+ ~CPDF_CIDFont() override;
- FX_BOOL LoadGB2312();
- virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL);
- virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
- virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
- FX_WORD CIDFromCharCode(FX_DWORD charcode) const;
+ FX_BOOL LoadGB2312();
+ int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL) override;
+ int GetCharWidthF(FX_DWORD charcode, int level = 0) override;
+ void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0) override;
+ FX_WORD CIDFromCharCode(FX_DWORD charcode) const;
- FX_BOOL IsTrueType()
+ FX_BOOL IsTrueType() const
{
return !m_bType1;
}
- virtual FX_DWORD GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const override;
- virtual int CountChar(const FX_CHAR* pString, int size) const;
- virtual int AppendChar(FX_CHAR* str, FX_DWORD charcode) const;
- virtual int GetCharSize(FX_DWORD charcode) const;
+ virtual FX_DWORD GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const override;
+ int CountChar(const FX_CHAR* pString, int size) const override;
+ int AppendChar(FX_CHAR* str, FX_DWORD charcode) const override;
+ int GetCharSize(FX_DWORD charcode) const override;
- int GetCharset() const
+ int GetCharset() const
{
return m_Charset;
}
- const uint8_t* GetCIDTransform(FX_WORD CID) const;
- virtual FX_BOOL IsVertWriting() const;
- short GetVertWidth(FX_WORD CID) const;
- void GetVertOrigin(FX_WORD CID, short& vx, short& vy) const;
- virtual FX_BOOL IsUnicodeCompatible() const;
- virtual FX_BOOL IsFontStyleFromCharCode(FX_DWORD charcode) const;
+ const uint8_t* GetCIDTransform(FX_WORD CID) const;
+ FX_BOOL IsVertWriting() const override;
+ short GetVertWidth(FX_WORD CID) const;
+ void GetVertOrigin(FX_WORD CID, short& vx, short& vy) const;
+ FX_BOOL IsUnicodeCompatible() const override;
+ virtual FX_BOOL IsFontStyleFromCharCode(FX_DWORD charcode) const;
protected:
- friend class CPDF_Font;
- virtual FX_BOOL _Load();
- virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const;
- virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const;
- int GetGlyphIndex(FX_DWORD unicodeb, FX_BOOL *pVertGlyph);
-
- CPDF_CMap* m_pCMap;
- CPDF_CMap* m_pAllocatedCMap;
- CPDF_CID2UnicodeMap* m_pCID2UnicodeMap;
- int m_Charset;
- FX_BOOL m_bType1;
- CPDF_StreamAcc* m_pCIDToGIDMap;
- FX_BOOL m_bCIDIsGID;
- FX_WORD m_DefaultWidth;
- FX_WORD* m_pAnsiWidths;
- FX_SMALL_RECT m_CharBBox[256];
- CFX_DWordArray m_WidthList;
- short m_DefaultVY;
- short m_DefaultW1;
- CFX_DWordArray m_VertMetrics;
-
- void LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, int nElements);
- void LoadSubstFont();
-
- FX_BOOL m_bAdobeCourierStd;
- CFX_CTTGSUBTable* m_pTTGSUBTable;
+ friend class CPDF_Font;
+
+ FX_BOOL _Load() override;
+ FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const override;
+ FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const override;
+ int GetGlyphIndex(FX_DWORD unicodeb, FX_BOOL *pVertGlyph);
+ void LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, int nElements);
+ void LoadSubstFont();
+
+ CPDF_CMap* m_pCMap;
+ CPDF_CMap* m_pAllocatedCMap;
+ CPDF_CID2UnicodeMap* m_pCID2UnicodeMap;
+ int m_Charset;
+ FX_BOOL m_bType1;
+ CPDF_StreamAcc* m_pCIDToGIDMap;
+ FX_BOOL m_bCIDIsGID;
+ FX_WORD m_DefaultWidth;
+ FX_WORD* m_pAnsiWidths;
+ FX_SMALL_RECT m_CharBBox[256];
+ CFX_DWordArray m_WidthList;
+ short m_DefaultVY;
+ short m_DefaultW1;
+ CFX_DWordArray m_VertMetrics;
+ FX_BOOL m_bAdobeCourierStd;
+ CFX_CTTGSUBTable* m_pTTGSUBTable;
};
#define PDFCS_DEVICEGRAY 1
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 35eacdfb0a..0083825bb0 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -228,58 +228,61 @@ protected:
const uint8_t* m_pLoadingBuf;
FX_DWORD m_LoadingSize;
+
};
+
class IFX_BufferArchive
{
public:
IFX_BufferArchive(FX_STRSIZE size);
- virtual ~IFX_BufferArchive() { }
-
- virtual void Clear();
+ virtual ~IFX_BufferArchive() {}
+ virtual void Clear();
- FX_BOOL Flush();
+ FX_BOOL Flush();
+ int32_t AppendBlock(const void* pBuf, size_t size);
- int32_t AppendBlock(const void* pBuf, size_t size);
+ int32_t AppendByte(uint8_t byte);
- int32_t AppendByte(uint8_t byte);
+ int32_t AppendDWord(FX_DWORD i);
- int32_t AppendDWord(FX_DWORD i);
-
- int32_t AppendString(const CFX_ByteStringC& lpsz);
+ int32_t AppendString(const CFX_ByteStringC& lpsz);
protected:
- virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
+ virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
- FX_STRSIZE m_BufSize;
+ FX_STRSIZE m_BufSize;
- uint8_t* m_pBuffer;
+ uint8_t* m_pBuffer;
- FX_STRSIZE m_Length;
+ FX_STRSIZE m_Length;
};
+
class CFX_FileBufferArchive : public IFX_BufferArchive
{
public:
CFX_FileBufferArchive(FX_STRSIZE size = 32768);
~CFX_FileBufferArchive() override;
- virtual void Clear();
- FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = FALSE);
+ void Clear() override;
- FX_BOOL AttachFile(const FX_WCHAR* filename);
+ FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = FALSE);
- FX_BOOL AttachFile(const FX_CHAR* filename);
-private:
+ FX_BOOL AttachFile(const FX_WCHAR* filename);
- virtual FX_BOOL DoWork(const void* pBuf, size_t size);
+ FX_BOOL AttachFile(const FX_CHAR* filename);
- IFX_StreamWrite *m_pFile;
+private:
+ FX_BOOL DoWork(const void* pBuf, size_t size) override;
- FX_BOOL m_bTakeover;
+ IFX_StreamWrite* m_pFile;
+
+ FX_BOOL m_bTakeover;
};
+
struct CFX_CharMap {
static CFX_CharMap* GetDefaultMapper(int32_t codepage = 0);