summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-04-17 13:17:49 -0700
committerTom Sepez <tsepez@chromium.org>2015-04-17 13:17:49 -0700
commit7a8387e670a2f879b9b2f1fc7bb67064f73fb249 (patch)
tree237ccb53166295bd5aebc4c1d3964ff3caa9bc06 /core
parenta07aa98240c747912b16e474389a7808cc50a10c (diff)
downloadpdfium-7a8387e670a2f879b9b2f1fc7bb67064f73fb249.tar.xz
Merge to XFA: Set m_FontType in CPDF_Font() constructor.
Original Review URL: https://codereview.chromium.org/1060813003 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1060843005
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_resource.h29
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp30
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp2
3 files changed, 18 insertions, 43 deletions
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h
index 86084d0b72..4a85096900 100644
--- a/core/include/fpdfapi/fpdf_resource.h
+++ b/core/include/fpdfapi/fpdf_resource.h
@@ -76,23 +76,16 @@ typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedStreamAcc*> CPDF_FontFil
#define PDFFONT_USEEXTERNATTR 0x80000
FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name);
CFX_ByteString PDF_AdobeNameFromUnicode(FX_WCHAR unicode);
-class CPDF_Font
+class CPDF_Font
{
public:
-
static CPDF_Font* CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDict);
-
static CPDF_Font* GetStockFont(CPDF_Document* pDoc, FX_BSTR fontname);
virtual ~CPDF_Font();
-
-
-
- int GetFontType() const
- {
- return m_FontType;
- }
+ bool IsFontType(int fonttype) const { return fonttype == m_FontType; }
+ int GetFontType() const { return m_FontType; }
CFX_ByteString GetFontTypeName() const;
@@ -256,9 +249,9 @@ public:
class CFX_PathData* LoadGlyphPath(FX_DWORD charcode, int dest_width = 0);
CFX_Font m_Font;
-protected:
- CPDF_Font();
+protected:
+ explicit CPDF_Font(int fonttype);
FX_BOOL Initialize();
@@ -285,8 +278,6 @@ protected:
- int m_FontType;
-
CFX_ByteString m_BaseFont;
CPDF_StreamAcc* m_pFontFile;
@@ -312,6 +303,8 @@ protected:
int m_ItalicAngle;
+private:
+ const int m_FontType;
};
#define PDFFONT_ENCODING_BUILTIN 0
#define PDFFONT_ENCODING_WINANSI 1
@@ -355,10 +348,8 @@ public:
class CPDF_SimpleFont : public CPDF_Font
{
public:
-
- CPDF_SimpleFont();
-
- virtual ~CPDF_SimpleFont();
+ explicit CPDF_SimpleFont(int fonttype);
+ ~CPDF_SimpleFont() override;
CPDF_FontEncoding* GetEncoding()
{
@@ -469,7 +460,7 @@ class CPDF_Type3Font : public CPDF_SimpleFont
{
public:
CPDF_Type3Font();
- virtual ~CPDF_Type3Font();
+ ~CPDF_Type3Font() override;
void SetPageResources(CPDF_Dictionary* pResources)
{
m_pPageResources = pResources;
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 9ee9621849..eace07ceb2 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -110,21 +110,15 @@ void CPDF_FontGlobals::ClearAll()
m_pStockMap.RemoveKey(key);
}
}
-CPDF_Font::CPDF_Font()
+CPDF_Font::CPDF_Font(int fonttype) : m_FontType(fonttype)
{
- m_FontType = 0;
m_FontBBox.left = m_FontBBox.right = m_FontBBox.top = m_FontBBox.bottom = 0;
m_StemV = m_Ascent = m_Descent = m_ItalicAngle = 0;
m_pFontFile = NULL;
m_Flags = 0;
m_pToUnicodeMap = NULL;
m_bToUnicodeLoaded = FALSE;
- m_pCharMap = NULL;
-}
-FX_BOOL CPDF_Font::Initialize()
-{
- m_pCharMap = FX_NEW CPDF_FontCharMap(this);
- return TRUE;
+ m_pCharMap = new CPDF_FontCharMap(this);
}
CPDF_Font::~CPDF_Font()
{
@@ -442,8 +436,6 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDic
CPDF_Dictionary* pFontDesc = pFontDict->GetDict(FX_BSTRC("FontDescriptor"));
if (pFontDesc == NULL || !pFontDesc->KeyExist(FX_BSTRC("FontFile2"))) {
pFont = FX_NEW CPDF_CIDFont;
- pFont->Initialize();
- pFont->m_FontType = PDFFONT_CIDFONT;
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
if (!pFont->Load()) {
@@ -456,20 +448,12 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDic
#endif
}
pFont = FX_NEW CPDF_TrueTypeFont;
- pFont->Initialize();
- pFont->m_FontType = PDFFONT_TRUETYPE;
} else if (type == FX_BSTRC("Type3")) {
pFont = FX_NEW CPDF_Type3Font;
- pFont->Initialize();
- pFont->m_FontType = PDFFONT_TYPE3;
} else if (type == FX_BSTRC("Type0")) {
pFont = FX_NEW CPDF_CIDFont;
- pFont->Initialize();
- pFont->m_FontType = PDFFONT_CIDFONT;
} else {
pFont = FX_NEW CPDF_Type1Font;
- pFont->Initialize();
- pFont->m_FontType = PDFFONT_TYPE1;
}
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
@@ -830,7 +814,7 @@ FX_BOOL CPDF_Font::IsStandardFont() const
return TRUE;
}
extern FX_LPCSTR PDF_CharNameFromPredefinedCharSet(int encoding, FX_BYTE charcode);
-CPDF_SimpleFont::CPDF_SimpleFont()
+CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype)
{
FXSYS_memset8(m_CharBBox, 0xff, sizeof m_CharBBox);
FXSYS_memset8(m_CharWidth, 0xff, sizeof m_CharWidth);
@@ -1028,7 +1012,7 @@ void CPDF_SimpleFont::LoadSubstFont()
}
}
int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140);
- m_Font.LoadSubst(m_BaseFont, m_FontType == PDFFONT_TRUETYPE, m_Flags, weight, m_ItalicAngle, 0);
+ m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight, m_ItalicAngle, 0);
if (m_Font.m_pSubstFont->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) {
}
}
@@ -1037,7 +1021,7 @@ FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const
return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL &&
m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS;
}
-CPDF_Type1Font::CPDF_Type1Font()
+CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1)
{
m_Base14Font = -1;
}
@@ -1429,7 +1413,7 @@ CPDF_Object* CPDF_FontEncoding::Realize()
pDict->SetAt(FX_BSTRC("Differences"), pDiff);
return pDict;
}
-CPDF_TrueTypeFont::CPDF_TrueTypeFont()
+CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE)
{
}
FX_BOOL CPDF_TrueTypeFont::_Load()
@@ -1611,7 +1595,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap()
m_GlyphIndex[charcode] = charcode;
}
}
-CPDF_Type3Font::CPDF_Type3Font()
+CPDF_Type3Font::CPDF_Type3Font() : CPDF_SimpleFont(PDFFONT_TYPE3)
{
m_pPageResources = NULL;
FXSYS_memset32(m_CharWidthL, 0, sizeof m_CharWidthL);
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 0d193e2189..63afbe5983 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -693,7 +693,7 @@ void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPro
FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount);
}
#include "ttgsubtable.h"
-CPDF_CIDFont::CPDF_CIDFont()
+CPDF_CIDFont::CPDF_CIDFont() : CPDF_Font(PDFFONT_CIDFONT)
{
m_pCMap = NULL;
m_pAllocatedCMap = NULL;