Replace CPDF_CIDFont::m_bType1 with an enum.
It is not obvious that "!m_bType1" means TrueType.
Change-Id: Idb4869ae99685d4ed9d6eda8b193e77a6a70ef15
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84870
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 2fe9af9..e4f5955 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -422,7 +422,8 @@
return false;
ByteString subtype = pCIDFontDict->GetStringFor("Subtype");
- m_bType1 = (subtype == "CIDFontType0");
+ m_FontType =
+ subtype == "CIDFontType0" ? CIDFontType::kType1 : CIDFontType::kTrueType;
if (!pEncoding->IsName() && !pEncoding->IsStream())
return false;
@@ -456,7 +457,7 @@
m_pCID2UnicodeMap = manager->GetCID2UnicodeMap(m_Charset);
}
if (m_Font.GetFaceRec()) {
- if (m_bType1)
+ if (m_FontType == CIDFontType::kType1)
FXFT_Select_Charmap(m_Font.GetFaceRec(), FT_ENCODING_UNICODE);
else
FT_UseCIDCharmap(m_Font.GetFaceRec(), m_pCMap->GetCoding());
@@ -777,7 +778,7 @@
uint16_t cid = CIDFromCharCode(charcode);
if (!m_pStreamAcc) {
- if (m_bType1)
+ if (m_FontType == CIDFontType::kType1)
return cid;
if (m_pFontFile && m_pCMap->IsDirectCharcodeToCIDTableIsEmpty())
return cid;
@@ -829,9 +830,10 @@
void CPDF_CIDFont::LoadSubstFont() {
FX_SAFE_INT32 safeStemV(m_StemV);
safeStemV *= 5;
- m_Font.LoadSubst(m_BaseFontName, !m_bType1, m_Flags,
- safeStemV.ValueOrDefault(FXFONT_FW_NORMAL), m_ItalicAngle,
- kCharsetCodePages[m_Charset], IsVertWriting());
+ m_Font.LoadSubst(m_BaseFontName, m_FontType == CIDFontType::kTrueType,
+ m_Flags, safeStemV.ValueOrDefault(FXFONT_FW_NORMAL),
+ m_ItalicAngle, kCharsetCodePages[m_Charset],
+ IsVertWriting());
}
// static
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h
index 1c27ee4..17cb56e 100644
--- a/core/fpdfapi/font/cpdf_cidfont.h
+++ b/core/fpdfapi/font/cpdf_cidfont.h
@@ -63,6 +63,11 @@
int GetCharSize(uint32_t charcode) const;
private:
+ enum class CIDFontType : bool {
+ kType1, // CIDFontType0
+ kTrueType // CIDFontType2
+ };
+
CPDF_CIDFont(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);
void LoadGB2312();
@@ -75,7 +80,7 @@
UnownedPtr<const CPDF_CID2UnicodeMap> m_pCID2UnicodeMap;
RetainPtr<CPDF_StreamAcc> m_pStreamAcc;
std::unique_ptr<CFX_CTTGSUBTable> m_pTTGSUBTable;
- bool m_bType1 = false;
+ CIDFontType m_FontType = CIDFontType::kTrueType;
bool m_bCIDIsGID = false;
bool m_bAnsiWidthsFixed = false;
bool m_bAdobeCourierStd = false;