summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp7
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.h8
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp40
-rw-r--r--core/fpdfapi/font/cpdf_font.h18
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp6
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.h4
-rw-r--r--core/fpdfapi/font/cpdf_truetypefont.cpp6
-rw-r--r--core/fpdfapi/font/cpdf_truetypefont.h3
-rw-r--r--core/fpdfapi/font/cpdf_type1font.cpp6
-rw-r--r--core/fpdfapi/font/cpdf_type1font.h5
-rw-r--r--core/fpdfapi/font/cpdf_type3font.cpp4
-rw-r--r--core/fpdfapi/font/cpdf_type3font.h2
12 files changed, 57 insertions, 52 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index ef471d02f1..b25b728ce0 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -207,11 +207,8 @@ bool IsMetricForCID(const uint32_t* pEntry, uint16_t CID) {
} // namespace
-CPDF_CIDFont::CPDF_CIDFont()
- : m_pCID2UnicodeMap(nullptr),
- m_bCIDIsGID(false),
- m_bAnsiWidthsFixed(false),
- m_bAdobeCourierStd(false) {
+CPDF_CIDFont::CPDF_CIDFont(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict)
+ : CPDF_Font(pDocument, pFontDict) {
for (size_t i = 0; i < FX_ArraySize(m_CharBBox); ++i)
m_CharBBox[i] = FX_RECT(-1, -1, -1, -1);
}
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h
index 3ff60b0f67..43c1184969 100644
--- a/core/fpdfapi/font/cpdf_cidfont.h
+++ b/core/fpdfapi/font/cpdf_cidfont.h
@@ -34,7 +34,7 @@ class CPDF_StreamAcc;
class CPDF_CIDFont : public CPDF_Font {
public:
- CPDF_CIDFont();
+ CPDF_CIDFont(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);
~CPDF_CIDFont() override;
static float CIDTransformToFloat(uint8_t ch);
@@ -76,15 +76,15 @@ class CPDF_CIDFont : public CPDF_Font {
UnownedPtr<const CPDF_CID2UnicodeMap> m_pCID2UnicodeMap;
CIDSet m_Charset;
bool m_bType1;
- bool m_bCIDIsGID;
+ bool m_bCIDIsGID = false;
uint16_t m_DefaultWidth;
RetainPtr<CPDF_StreamAcc> m_pStreamAcc;
- bool m_bAnsiWidthsFixed;
+ bool m_bAnsiWidthsFixed = false;
std::vector<uint32_t> m_WidthList;
short m_DefaultVY;
short m_DefaultW1;
std::vector<uint32_t> m_VertMetrics;
- bool m_bAdobeCourierStd;
+ bool m_bAdobeCourierStd = false;
std::unique_ptr<CFX_CTTGSUBTable> m_pTTGSUBTable;
FX_RECT m_CharBBox[256];
};
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 0bba1057e7..110770a604 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -31,11 +31,13 @@
namespace {
-const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00},
- {0xBF, 0xAC, 0xCC, 0xE5, 0x00},
- {0xBA, 0xDA, 0xCC, 0xE5, 0x00},
- {0xB7, 0xC2, 0xCB, 0xCE, 0x00},
- {0xD0, 0xC2, 0xCB, 0xCE, 0x00}};
+constexpr size_t kChineseFontNameSize = 4;
+const uint8_t kChineseFontNames[][kChineseFontNameSize] = {
+ {0xCB, 0xCE, 0xCC, 0xE5},
+ {0xBF, 0xAC, 0xCC, 0xE5},
+ {0xBA, 0xDA, 0xCC, 0xE5},
+ {0xB7, 0xC2, 0xCB, 0xCE},
+ {0xD0, 0xC2, 0xCB, 0xCE}};
void GetPredefinedEncoding(const ByteString& value, int* basemap) {
if (value == "WinAnsiEncoding")
@@ -50,15 +52,10 @@ void GetPredefinedEncoding(const ByteString& value, int* basemap) {
} // namespace
-CPDF_Font::CPDF_Font()
- : m_pFontFile(nullptr),
- m_pFontDict(nullptr),
- m_bToUnicodeLoaded(false),
- m_Flags(0),
- m_StemV(0),
- m_Ascent(0),
- m_Descent(0),
- m_ItalicAngle(0) {}
+CPDF_Font::CPDF_Font(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict)
+ : m_pDocument(pDocument),
+ m_pFontDict(pFontDict),
+ m_BaseFont(pFontDict->GetStringFor("BaseFont")) {}
CPDF_Font::~CPDF_Font() {
if (m_pFontFile) {
@@ -323,26 +320,23 @@ std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
if (type == "TrueType") {
ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4);
for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) {
- if (tag == ByteString(kChineseFontNames[i], 4)) {
+ if (tag == ByteString(kChineseFontNames[i], kChineseFontNameSize)) {
const CPDF_Dictionary* pFontDesc =
pFontDict->GetDictFor("FontDescriptor");
if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
- pFont = pdfium::MakeUnique<CPDF_CIDFont>();
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>(pDoc, pFontDict);
break;
}
}
if (!pFont)
- pFont = pdfium::MakeUnique<CPDF_TrueTypeFont>();
+ pFont = pdfium::MakeUnique<CPDF_TrueTypeFont>(pDoc, pFontDict);
} else if (type == "Type3") {
- pFont = pdfium::MakeUnique<CPDF_Type3Font>();
+ pFont = pdfium::MakeUnique<CPDF_Type3Font>(pDoc, pFontDict);
} else if (type == "Type0") {
- pFont = pdfium::MakeUnique<CPDF_CIDFont>();
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>(pDoc, pFontDict);
} else {
- pFont = pdfium::MakeUnique<CPDF_Type1Font>();
+ pFont = pdfium::MakeUnique<CPDF_Type1Font>(pDoc, pFontDict);
}
- pFont->m_pFontDict = pFontDict;
- pFont->m_pDocument = pDoc;
- pFont->m_BaseFont = pFontDict->GetStringFor("BaseFont");
return pFont->Load() ? std::move(pFont) : nullptr;
}
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index 9580d1c36b..d79b13fb6b 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -88,7 +88,7 @@ class CPDF_Font {
CFX_Font* GetFontFallback(int position);
protected:
- CPDF_Font();
+ CPDF_Font(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);
static int TT2PDF(int m, FXFT_Face face);
static bool FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id);
@@ -108,20 +108,20 @@ class CPDF_Font {
const std::vector<ByteString>& charnames,
int charcode);
- UnownedPtr<CPDF_Document> m_pDocument;
+ UnownedPtr<CPDF_Document> const m_pDocument;
CFX_Font m_Font;
std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks;
- ByteString m_BaseFont;
RetainPtr<CPDF_StreamAcc> m_pFontFile;
UnownedPtr<CPDF_Dictionary> m_pFontDict;
+ ByteString m_BaseFont;
mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap;
- mutable bool m_bToUnicodeLoaded;
- int m_Flags;
+ mutable bool m_bToUnicodeLoaded = false;
+ int m_Flags = 0;
+ int m_StemV = 0;
+ int m_Ascent = 0;
+ int m_Descent = 0;
+ int m_ItalicAngle = 0;
FX_RECT m_FontBBox;
- int m_StemV;
- int m_Ascent;
- int m_Descent;
- int m_ItalicAngle;
};
#endif // CORE_FPDFAPI_FONT_CPDF_FONT_H_
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index f7652d2635..e646c14ba8 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -11,7 +11,9 @@
#include "core/fxge/fx_freetype.h"
#include "third_party/base/numerics/safe_math.h"
-CPDF_SimpleFont::CPDF_SimpleFont() : m_BaseEncoding(PDFFONT_ENCODING_BUILTIN) {
+CPDF_SimpleFont::CPDF_SimpleFont(CPDF_Document* pDocument,
+ CPDF_Dictionary* pFontDict)
+ : CPDF_Font(pDocument, pFontDict) {
memset(m_CharWidth, 0xff, sizeof(m_CharWidth));
memset(m_GlyphIndex, 0xff, sizeof(m_GlyphIndex));
memset(m_ExtGID, 0xff, sizeof(m_ExtGID));
@@ -19,7 +21,7 @@ CPDF_SimpleFont::CPDF_SimpleFont() : m_BaseEncoding(PDFFONT_ENCODING_BUILTIN) {
m_CharBBox[i] = FX_RECT(-1, -1, -1, -1);
}
-CPDF_SimpleFont::~CPDF_SimpleFont() {}
+CPDF_SimpleFont::~CPDF_SimpleFont() = default;
int CPDF_SimpleFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
if (pVertGlyph)
diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h
index 3aa68d73a6..77df55bf99 100644
--- a/core/fpdfapi/font/cpdf_simplefont.h
+++ b/core/fpdfapi/font/cpdf_simplefont.h
@@ -16,7 +16,7 @@
class CPDF_SimpleFont : public CPDF_Font {
public:
- CPDF_SimpleFont();
+ CPDF_SimpleFont(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);
~CPDF_SimpleFont() override;
// CPDF_Font
@@ -39,7 +39,7 @@ class CPDF_SimpleFont : public CPDF_Font {
void LoadCharMetrics(int charcode);
CPDF_FontEncoding m_Encoding;
- int m_BaseEncoding;
+ int m_BaseEncoding = PDFFONT_ENCODING_BUILTIN;
bool m_bUseFontWidth;
std::vector<ByteString> m_CharNames;
uint16_t m_GlyphIndex[256];
diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp
index 91c238a1b4..c77d16c74e 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
@@ -15,7 +15,11 @@ const uint8_t kPrefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
} // namespace
-CPDF_TrueTypeFont::CPDF_TrueTypeFont() {}
+CPDF_TrueTypeFont::CPDF_TrueTypeFont(CPDF_Document* pDocument,
+ CPDF_Dictionary* pFontDict)
+ : CPDF_SimpleFont(pDocument, pFontDict) {}
+
+CPDF_TrueTypeFont::~CPDF_TrueTypeFont() = default;
bool CPDF_TrueTypeFont::IsTrueTypeFont() const {
return true;
diff --git a/core/fpdfapi/font/cpdf_truetypefont.h b/core/fpdfapi/font/cpdf_truetypefont.h
index 6a5e0fc83e..d63e8f105a 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.h
+++ b/core/fpdfapi/font/cpdf_truetypefont.h
@@ -12,7 +12,8 @@
class CPDF_TrueTypeFont : public CPDF_SimpleFont {
public:
- CPDF_TrueTypeFont();
+ CPDF_TrueTypeFont(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);
+ ~CPDF_TrueTypeFont() override;
// CPDF_Font:
bool IsTrueTypeFont() const override;
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp
index fb445832f0..2717ade338 100644
--- a/core/fpdfapi/font/cpdf_type1font.cpp
+++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -60,7 +60,11 @@ bool FT_UseType1Charmap(FXFT_Face face) {
} // namespace
-CPDF_Type1Font::CPDF_Type1Font() : m_Base14Font(-1) {}
+CPDF_Type1Font::CPDF_Type1Font(CPDF_Document* pDocument,
+ CPDF_Dictionary* pFontDict)
+ : CPDF_SimpleFont(pDocument, pFontDict) {}
+
+CPDF_Type1Font::~CPDF_Type1Font() = default;
bool CPDF_Type1Font::IsType1Font() const {
return true;
diff --git a/core/fpdfapi/font/cpdf_type1font.h b/core/fpdfapi/font/cpdf_type1font.h
index 76c4962ecb..688346175b 100644
--- a/core/fpdfapi/font/cpdf_type1font.h
+++ b/core/fpdfapi/font/cpdf_type1font.h
@@ -12,7 +12,8 @@
class CPDF_Type1Font : public CPDF_SimpleFont {
public:
- CPDF_Type1Font();
+ CPDF_Type1Font(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);
+ ~CPDF_Type1Font() override;
// CPDF_Font:
bool IsType1Font() const override;
@@ -34,7 +35,7 @@ class CPDF_Type1Font : public CPDF_SimpleFont {
void CalcExtGID(int charcode);
#endif
- int m_Base14Font;
+ int m_Base14Font = -1;
};
#endif // CORE_FPDFAPI_FONT_CPDF_TYPE1FONT_H_
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index 9a79c30cab..353bf2c244 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -23,7 +23,9 @@ constexpr int kMaxType3FormLevel = 4;
} // namespace
-CPDF_Type3Font::CPDF_Type3Font() {
+CPDF_Type3Font::CPDF_Type3Font(CPDF_Document* pDocument,
+ CPDF_Dictionary* pFontDict)
+ : CPDF_SimpleFont(pDocument, pFontDict) {
memset(m_CharWidthL, 0, sizeof(m_CharWidthL));
}
diff --git a/core/fpdfapi/font/cpdf_type3font.h b/core/fpdfapi/font/cpdf_type3font.h
index 67400d5710..0be1fa3f69 100644
--- a/core/fpdfapi/font/cpdf_type3font.h
+++ b/core/fpdfapi/font/cpdf_type3font.h
@@ -19,7 +19,7 @@ class CPDF_Type3Char;
class CPDF_Type3Font : public CPDF_SimpleFont {
public:
- CPDF_Type3Font();
+ CPDF_Type3Font(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);
~CPDF_Type3Font() override;
// CPDF_Font: