summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-11 05:37:27 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-11 05:37:27 +0000
commit3b76669371e54011d8a035122a1af0f0673597ab (patch)
treed5c115f659bcee8e71c5ceaa50e9ff3c4b220da0 /core/fpdfapi/font
parent6fdfe387645217cdd77e8e4230a0d8348d831e31 (diff)
downloadpdfium-3b76669371e54011d8a035122a1af0f0673597ab.tar.xz
Simplify CPDF_SimpleFont::LoadPDFEncoding().
Remove parameters that always refer to the same member variables. Also mark the input object as const since it is only read from. Change-Id: I136ece1ce5b0c00b02d1a76e1540ff26e6f01858 Reviewed-on: https://pdfium-review.googlesource.com/39494 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp50
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.h6
-rw-r--r--core/fpdfapi/font/cpdf_type3font.cpp5
3 files changed, 26 insertions, 35 deletions
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index 76f1c7cbd1..f1bbf69b4f 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -98,66 +98,64 @@ void CPDF_SimpleFont::LoadCharMetrics(int charcode) {
}
}
-void CPDF_SimpleFont::LoadPDFEncoding(CPDF_Object* pEncoding,
- int& iBaseEncoding,
- std::vector<ByteString>* pCharNames,
- bool bEmbedded,
- bool bTrueType) {
+void CPDF_SimpleFont::LoadPDFEncoding(bool bEmbedded, bool bTrueType) {
+ const CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding");
if (!pEncoding) {
if (m_BaseFont == "Symbol") {
- iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
- : PDFFONT_ENCODING_ADOBE_SYMBOL;
- } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) {
- iBaseEncoding = PDFFONT_ENCODING_WINANSI;
+ m_BaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
+ : PDFFONT_ENCODING_ADOBE_SYMBOL;
+ } else if (!bEmbedded && m_BaseEncoding == PDFFONT_ENCODING_BUILTIN) {
+ m_BaseEncoding = PDFFONT_ENCODING_WINANSI;
}
return;
}
if (pEncoding->IsName()) {
- if (iBaseEncoding == PDFFONT_ENCODING_ADOBE_SYMBOL ||
- iBaseEncoding == PDFFONT_ENCODING_ZAPFDINGBATS) {
+ if (m_BaseEncoding == PDFFONT_ENCODING_ADOBE_SYMBOL ||
+ m_BaseEncoding == PDFFONT_ENCODING_ZAPFDINGBATS) {
return;
}
if (FontStyleIsSymbolic(m_Flags) && m_BaseFont == "Symbol") {
if (!bTrueType)
- iBaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL;
+ m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL;
return;
}
ByteString bsEncoding = pEncoding->GetString();
if (bsEncoding.Compare("MacExpertEncoding") == 0) {
bsEncoding = "WinAnsiEncoding";
}
- GetPredefinedEncoding(bsEncoding, &iBaseEncoding);
+ GetPredefinedEncoding(bsEncoding, &m_BaseEncoding);
return;
}
- CPDF_Dictionary* pDict = pEncoding->AsDictionary();
+ const CPDF_Dictionary* pDict = pEncoding->AsDictionary();
if (!pDict)
return;
- if (iBaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL &&
- iBaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) {
+ if (m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL &&
+ m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) {
ByteString bsEncoding = pDict->GetStringFor("BaseEncoding");
if (bTrueType && bsEncoding.Compare("MacExpertEncoding") == 0)
bsEncoding = "WinAnsiEncoding";
- GetPredefinedEncoding(bsEncoding, &iBaseEncoding);
+ GetPredefinedEncoding(bsEncoding, &m_BaseEncoding);
}
- if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN)
- iBaseEncoding = PDFFONT_ENCODING_STANDARD;
+ if ((!bEmbedded || bTrueType) && m_BaseEncoding == PDFFONT_ENCODING_BUILTIN)
+ m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
- CPDF_Array* pDiffs = pDict->GetArrayFor("Differences");
+ const CPDF_Array* pDiffs = pDict->GetArrayFor("Differences");
if (!pDiffs)
return;
- pCharNames->resize(256);
+ m_CharNames.resize(256);
uint32_t cur_code = 0;
for (uint32_t i = 0; i < pDiffs->GetCount(); i++) {
- CPDF_Object* pElement = pDiffs->GetDirectObjectAt(i);
+ const CPDF_Object* pElement = pDiffs->GetDirectObjectAt(i);
if (!pElement)
continue;
- if (CPDF_Name* pName = pElement->AsName()) {
+ const CPDF_Name* pName = pElement->AsName();
+ if (pName) {
if (cur_code < 256)
- (*pCharNames)[cur_code] = pName->GetString();
+ m_CharNames[cur_code] = pName->GetString();
cur_code++;
} else {
cur_code = pElement->GetInteger();
@@ -221,9 +219,7 @@ bool CPDF_SimpleFont::LoadCommon() {
}
if (!FontStyleIsSymbolic(m_Flags))
m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
- CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding");
- LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, !!m_pFontFile,
- m_Font.IsTTFont());
+ LoadPDFEncoding(!!m_pFontFile, m_Font.IsTTFont());
LoadGlyphMap();
m_CharNames.clear();
if (!m_Font.GetFace())
diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h
index 659ad0fa68..4c813a280e 100644
--- a/core/fpdfapi/font/cpdf_simplefont.h
+++ b/core/fpdfapi/font/cpdf_simplefont.h
@@ -37,11 +37,7 @@ class CPDF_SimpleFont : public CPDF_Font {
bool LoadCommon();
void LoadSubstFont();
void LoadCharMetrics(int charcode);
- void LoadPDFEncoding(CPDF_Object* pEncoding,
- int& iBaseEncoding,
- std::vector<ByteString>* pCharNames,
- bool bEmbedded,
- bool bTrueType);
+ void LoadPDFEncoding(bool bEmbedded, bool bTrueType);
CPDF_FontEncoding m_Encoding;
int m_BaseEncoding = PDFFONT_ENCODING_BUILTIN;
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index 353bf2c244..dde452e915 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -78,9 +78,8 @@ bool CPDF_Type3Font::Load() {
}
}
m_pCharProcs = m_pFontDict->GetDictFor("CharProcs");
- CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding");
- if (pEncoding)
- LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, false, false);
+ if (m_pFontDict->GetDirectObjectFor("Encoding"))
+ LoadPDFEncoding(false, false);
return true;
}