Add CPDF_Type1Font::IsBase14Font() to replace GetBase14Font(). IsBase14Font() is what its only caller really needs. Also use it in Load() which does the same check, and restructure Load() to have an early return. Change-Id: I1d051d10b80aa82bcf590c79169ffe29607b3c13 Reviewed-on: https://pdfium-review.googlesource.com/39970 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index f2aa4da..9b83733 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -346,9 +346,7 @@ return false; if (m_pFontFile) return false; - if (AsType1Font()->GetBase14Font() < 0) - return false; - return true; + return AsType1Font()->IsBase14Font(); } const char* CPDF_Font::GetAdobeCharName(
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp index 9e2f4ef..44e6b3e 100644 --- a/core/fpdfapi/font/cpdf_type1font.cpp +++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -84,25 +84,25 @@ bool CPDF_Type1Font::Load() { m_Base14Font = PDF_GetStandardFontName(&m_BaseFont); - if (m_Base14Font >= 0) { - const CPDF_Dictionary* pFontDesc = - m_pFontDict->GetDictFor("FontDescriptor"); - if (pFontDesc && pFontDesc->KeyExist("Flags")) - m_Flags = pFontDesc->GetIntegerFor("Flags"); - else - m_Flags = m_Base14Font >= 12 ? FXFONT_SYMBOLIC : FXFONT_NONSYMBOLIC; + if (!IsBase14Font()) + return LoadCommon(); - if (m_Base14Font < 4) { - for (int i = 0; i < 256; i++) - m_CharWidth[i] = 600; - } - if (m_Base14Font == 12) - m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; - else if (m_Base14Font == 13) - m_BaseEncoding = PDFFONT_ENCODING_ZAPFDINGBATS; - else if (FontStyleIsNonSymbolic(m_Flags)) - m_BaseEncoding = PDFFONT_ENCODING_STANDARD; + const CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictFor("FontDescriptor"); + if (pFontDesc && pFontDesc->KeyExist("Flags")) + m_Flags = pFontDesc->GetIntegerFor("Flags"); + else + m_Flags = m_Base14Font >= 12 ? FXFONT_SYMBOLIC : FXFONT_NONSYMBOLIC; + + if (m_Base14Font < 4) { + for (int i = 0; i < 256; i++) + m_CharWidth[i] = 600; } + if (m_Base14Font == 12) + m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; + else if (m_Base14Font == 13) + m_BaseEncoding = PDFFONT_ENCODING_ZAPFDINGBATS; + else if (FontStyleIsNonSymbolic(m_Flags)) + m_BaseEncoding = PDFFONT_ENCODING_STANDARD; return LoadCommon(); }
diff --git a/core/fpdfapi/font/cpdf_type1font.h b/core/fpdfapi/font/cpdf_type1font.h index eaabaae..cbcb9af 100644 --- a/core/fpdfapi/font/cpdf_type1font.h +++ b/core/fpdfapi/font/cpdf_type1font.h
@@ -23,7 +23,7 @@ int GlyphFromCharCodeExt(uint32_t charcode) override; #endif - int GetBase14Font() const { return m_Base14Font; } + bool IsBase14Font() const { return m_Base14Font >= 0; } private: // CPDF_Font: