summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_font
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
committerLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
commit412e908082a361d0fd9591eab939e96a882212f1 (patch)
tree11726052ae08f13dc5a05a82cbce870758580aeb /core/src/fpdfapi/fpdf_font
parent96660d6f382204339d6b1aadc3913303d436e252 (diff)
downloadpdfium-412e908082a361d0fd9591eab939e96a882212f1.tar.xz
Merge to XFA: Get rid of most instance of 'foo == NULL'
TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1520063002 . (cherry picked from commit e385244f8cd6ae376f6b3cf1265a0795d5d30eff) Review URL: https://codereview.chromium.org/1528763003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_font')
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp31
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp32
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.cpp4
3 files changed, 32 insertions, 35 deletions
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 4a71382da4..3170b55e20 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -351,7 +351,7 @@ void CPDF_Font::CheckFontMetrics() {
void CPDF_Font::LoadUnicodeMap() {
m_bToUnicodeLoaded = TRUE;
CPDF_Stream* pStream = m_pFontDict->GetStream("ToUnicode");
- if (pStream == NULL) {
+ if (!pStream) {
return;
}
m_pToUnicodeMap = new CPDF_ToUnicodeMap;
@@ -425,7 +425,7 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
}
if (i < count) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDict("FontDescriptor");
- if (pFontDesc == NULL || !pFontDesc->KeyExist("FontFile2")) {
+ if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) {
pFont = new CPDF_CIDFont;
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
@@ -455,7 +455,7 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
return pFont;
}
FX_BOOL CPDF_Font::Load() {
- if (m_pFontDict == NULL) {
+ if (!m_pFontDict) {
return FALSE;
}
CFX_ByteString type = m_pFontDict->GetString("Subtype");
@@ -488,7 +488,7 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) {
}
const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer();
FX_DWORD buf_len = m_MultiCharBuf.GetLength();
- if (buf == NULL || buf_len == 0) {
+ if (!buf || buf_len == 0) {
return CFX_WideString();
}
FX_DWORD index = value >> 16;
@@ -704,7 +704,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
CFX_ByteString*& pCharNames,
FX_BOOL bEmbedded,
FX_BOOL bTrueType) {
- if (pEncoding == NULL) {
+ if (!pEncoding) {
if (m_BaseFont == "Symbol") {
iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
: PDFFONT_ENCODING_ADOBE_SYMBOL;
@@ -748,7 +748,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
iBaseEncoding = PDFFONT_ENCODING_STANDARD;
}
CPDF_Array* pDiffs = pDict->GetArray("Differences");
- if (pDiffs == NULL) {
+ if (!pDiffs) {
return;
}
pCharNames = new CFX_ByteString[256];
@@ -879,13 +879,10 @@ const FX_CHAR* GetAdobeCharName(int iBaseEncoding,
if (pCharNames) {
name = pCharNames[charcode];
}
- if ((name == NULL || name[0] == 0) && iBaseEncoding) {
+ if ((!name || name[0] == 0) && iBaseEncoding) {
name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
}
- if (name == NULL || name[0] == 0) {
- return NULL;
- }
- return name;
+ return name && name[0] ? name : nullptr;
}
FX_BOOL CPDF_SimpleFont::LoadCommon() {
CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor");
@@ -1127,7 +1124,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1228,7 +1225,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1328,7 +1325,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1453,7 +1450,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
}
if (((baseEncoding == PDFFONT_ENCODING_MACROMAN ||
baseEncoding == PDFFONT_ENCODING_WINANSI) &&
- m_pCharNames == NULL) ||
+ !m_pCharNames) ||
(m_Flags & PDFFONT_NONSYMBOLIC)) {
if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) &&
(!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) {
@@ -1486,7 +1483,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
m_GlyphIndex[charcode] =
m_pFontFile ? FXFT_Get_Char_Index(m_Font.GetFace(), charcode) : -1;
continue;
@@ -1562,7 +1559,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 89004fee55..6e7a051b34 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -848,14 +848,14 @@ FX_WORD CPDF_CMap::CIDFromCharCode(FX_DWORD charcode) const {
if (m_pEmbedMap) {
return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode);
}
- if (m_pMapping == NULL) {
+ if (!m_pMapping) {
return (FX_WORD)charcode;
}
if (charcode >> 16) {
if (m_pAddMapping) {
void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4,
*(FX_DWORD*)m_pAddMapping, 8, CompareCID);
- if (found == NULL) {
+ if (!found) {
if (m_pUseMap) {
return m_pUseMap->CIDFromCharCode(charcode);
}
@@ -1058,7 +1058,7 @@ CPDF_CIDFont::~CPDF_CIDFont() {
delete m_pTTGSUBTable;
}
FX_WORD CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const {
- if (m_pCMap == NULL) {
+ if (!m_pCMap) {
return (FX_WORD)charcode;
}
return m_pCMap->CIDFromCharCode(charcode);
@@ -1073,12 +1073,12 @@ FX_WCHAR CPDF_CIDFont::_UnicodeFromCharCode(FX_DWORD charcode) const {
case CIDCODING_UTF16:
return (FX_WCHAR)charcode;
case CIDCODING_CID:
- if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) {
+ if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
return 0;
}
return m_pCID2UnicodeMap->UnicodeFromCID((FX_WORD)charcode);
}
- if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL ||
+ if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap ||
!m_pCID2UnicodeMap->IsLoaded()) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
FX_WCHAR unicode;
@@ -1111,7 +1111,7 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const {
case CIDCODING_UTF16:
return unicode;
case CIDCODING_CID: {
- if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) {
+ if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
return 0;
}
FX_DWORD CID = 0;
@@ -1157,14 +1157,14 @@ FX_BOOL CPDF_CIDFont::_Load() {
return LoadGB2312();
}
CPDF_Array* pFonts = m_pFontDict->GetArray("DescendantFonts");
- if (pFonts == NULL) {
+ if (!pFonts) {
return FALSE;
}
if (pFonts->GetCount() != 1) {
return FALSE;
}
CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0);
- if (pCIDFontDict == NULL) {
+ if (!pCIDFontDict) {
return FALSE;
}
m_BaseFont = pCIDFontDict->GetString("BaseFont");
@@ -1180,7 +1180,7 @@ FX_BOOL CPDF_CIDFont::_Load() {
LoadFontDescriptor(pFontDesc);
}
CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding");
- if (pEncoding == NULL) {
+ if (!pEncoding) {
return FALSE;
}
CFX_ByteString subtype = pCIDFontDict->GetString("Subtype");
@@ -1201,7 +1201,7 @@ FX_BOOL CPDF_CIDFont::_Load() {
} else {
return FALSE;
}
- if (m_pCMap == NULL) {
+ if (!m_pCMap) {
return FALSE;
}
m_Charset = m_pCMap->m_Charset;
@@ -1218,8 +1218,8 @@ FX_BOOL CPDF_CIDFont::_Load() {
->GetFontGlobals()
->m_CMapManager.GetCID2UnicodeMap(
m_Charset,
- m_pFontFile == NULL && (m_pCMap->m_Coding == CIDCODING_CID ||
- pCIDFontDict->KeyExist("W")));
+ !m_pFontFile && (m_pCMap->m_Coding == CIDCODING_CID ||
+ pCIDFontDict->KeyExist("W")));
if (m_Font.GetFace()) {
if (m_bType1) {
FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE);
@@ -1333,7 +1333,7 @@ void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) {
} else {
rect = FX_RECT(0, 0, 0, 0);
}
- if (m_pFontFile == NULL && m_Charset == CIDSET_JAPAN1) {
+ if (!m_pFontFile && m_Charset == CIDSET_JAPAN1) {
FX_WORD CID = CIDFromCharCode(charcode);
const uint8_t* pTransform = GetCIDTransform(CID);
if (pTransform && !bVert) {
@@ -1458,7 +1458,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) {
if (pVertGlyph) {
*pVertGlyph = FALSE;
}
- if (m_pFontFile == NULL && m_pCIDToGIDMap == NULL) {
+ if (!m_pFontFile && !m_pCIDToGIDMap) {
FX_WORD cid = CIDFromCharCode(charcode);
FX_WCHAR unicode = 0;
if (m_bCIDIsGID) {
@@ -1504,7 +1504,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) {
iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
}
const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode);
- if (name == NULL) {
+ if (!name) {
return charcode == 0 ? -1 : (int)charcode;
}
FX_WORD unicode = PDF_UnicodeFromAdobeName(name);
@@ -1616,7 +1616,7 @@ int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const {
return m_pCMap->AppendChar(str, charcode);
}
FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const {
- if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL ||
+ if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap ||
!m_pCID2UnicodeMap->IsLoaded()) {
return m_pCMap->m_Coding != CIDCODING_UNKNOWN;
}
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
index 4786b8be94..035ea8a0ff 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -47,7 +47,7 @@ FX_BOOL CFX_GlyphMap::Lookup(int key, int& value) {
void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(),
m_Buffer.GetSize() / sizeof(_IntPair),
sizeof(_IntPair), _CompareInt);
- if (pResult == NULL) {
+ if (!pResult) {
return FALSE;
}
value = ((FX_DWORD*)pResult)[1];
@@ -158,7 +158,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum,
int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage,
uint32_t g) {
int i = 0;
- if (Coverage == NULL) {
+ if (!Coverage) {
return -1;
}
switch (Coverage->CoverageFormat) {