Index: xfa/fgas/font/fgas_gefont.cpp |
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp |
index ae6465c13f210ed47ef990f2c9db0003e467dabe..78f7826b5ef8222277a844f04f28fa5bf024bee4 100644 |
--- a/xfa/fgas/font/fgas_gefont.cpp |
+++ b/xfa/fgas/font/fgas_gefont.cpp |
@@ -15,15 +15,14 @@ IFGAS_Font* IFGAS_Font::LoadFont(const FX_WCHAR* pszFontFamily, |
uint16_t wCodePage, |
IFGAS_FontMgr* pFontMgr) { |
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
- if (NULL != pFontMgr) { |
+ if (pFontMgr) |
return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); |
- } |
- return NULL; |
+ return nullptr; |
#else |
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
if (!pFont->LoadFont(pszFontFamily, dwFontStyles, wCodePage)) { |
pFont->Release(); |
- return NULL; |
+ return nullptr; |
} |
return pFont; |
#endif |
@@ -32,15 +31,14 @@ IFGAS_Font* IFGAS_Font::LoadFont(const uint8_t* pBuffer, |
int32_t iLength, |
IFGAS_FontMgr* pFontMgr) { |
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
- if (NULL != pFontMgr) { |
- return pFontMgr->LoadFont(pBuffer, iLength, 0, NULL); |
- } |
- return NULL; |
+ if (pFontMgr) |
+ return pFontMgr->LoadFont(pBuffer, iLength, 0, nullptr); |
+ return nullptr; |
#else |
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
if (!pFont->LoadFont(pBuffer, iLength)) { |
pFont->Release(); |
- return NULL; |
+ return nullptr; |
} |
return pFont; |
#endif |
@@ -48,15 +46,14 @@ IFGAS_Font* IFGAS_Font::LoadFont(const uint8_t* pBuffer, |
IFGAS_Font* IFGAS_Font::LoadFont(const FX_WCHAR* pszFileName, |
IFGAS_FontMgr* pFontMgr) { |
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
- if (NULL != pFontMgr) { |
- return pFontMgr->LoadFont(pszFileName, 0, NULL); |
- } |
- return NULL; |
+ if (pFontMgr) |
+ return pFontMgr->LoadFont(pszFileName, 0, nullptr); |
+ return nullptr; |
#else |
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
if (!pFont->LoadFont(pszFileName)) { |
pFont->Release(); |
- return NULL; |
+ return nullptr; |
} |
return pFont; |
#endif |
@@ -65,15 +62,14 @@ IFGAS_Font* IFGAS_Font::LoadFont(IFX_Stream* pFontStream, |
IFGAS_FontMgr* pFontMgr, |
FX_BOOL bSaveStream) { |
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
- if (NULL != pFontMgr) { |
- return pFontMgr->LoadFont(pFontStream, 0, NULL); |
- } |
- return NULL; |
+ if (pFontMgr) |
+ return pFontMgr->LoadFont(pFontStream, 0, nullptr); |
+ return nullptr; |
#else |
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
if (!pFont->LoadFont(pFontStream, bSaveStream)) { |
pFont->Release(); |
- return NULL; |
+ return nullptr; |
} |
return pFont; |
#endif |
@@ -84,7 +80,7 @@ IFGAS_Font* IFGAS_Font::LoadFont(CFX_Font* pExtFont, |
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
if (!pFont->LoadFont(pExtFont, bTakeOver)) { |
pFont->Release(); |
- return NULL; |
+ return nullptr; |
} |
return pFont; |
} |
@@ -95,17 +91,17 @@ CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr) |
m_bUseLogFontStyle(FALSE), |
m_dwLogFontStyle(0), |
#endif |
- m_pFont(NULL), |
+ m_pFont(nullptr), |
m_pFontMgr(pFontMgr), |
m_iRefCount(1), |
m_bExtFont(FALSE), |
- m_pStream(NULL), |
- m_pFileRead(NULL), |
- m_pFontEncoding(NULL), |
- m_pCharWidthMap(NULL), |
- m_pRectArray(NULL), |
- m_pBBoxMap(NULL), |
- m_pProvider(NULL), |
+ m_pStream(nullptr), |
+ m_pFileRead(nullptr), |
+ m_pFontEncoding(nullptr), |
+ m_pCharWidthMap(nullptr), |
+ m_pRectArray(nullptr), |
+ m_pBBoxMap(nullptr), |
+ m_pProvider(nullptr), |
m_wCharSet(0xFFFF) { |
} |
@@ -115,17 +111,17 @@ CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles) |
m_bUseLogFontStyle(FALSE), |
m_dwLogFontStyle(0), |
#endif |
- m_pFont(NULL), |
+ m_pFont(nullptr), |
m_pFontMgr(src.m_pFontMgr), |
m_iRefCount(1), |
m_bExtFont(FALSE), |
- m_pStream(NULL), |
- m_pFileRead(NULL), |
- m_pFontEncoding(NULL), |
- m_pCharWidthMap(NULL), |
- m_pRectArray(NULL), |
- m_pBBoxMap(NULL), |
- m_pProvider(NULL), |
+ m_pStream(nullptr), |
+ m_pFileRead(nullptr), |
+ m_pFontEncoding(nullptr), |
+ m_pCharWidthMap(nullptr), |
+ m_pRectArray(nullptr), |
+ m_pBBoxMap(nullptr), |
+ m_pProvider(nullptr), |
m_wCharSet(0xFFFF) { |
ASSERT(src.m_pFont); |
m_pFont = new CFX_Font; |
@@ -165,9 +161,8 @@ CFGAS_GEFont::~CFGAS_GEFont() { |
void CFGAS_GEFont::Release() { |
if (--m_iRefCount < 1) { |
- if (m_pFontMgr != NULL) { |
+ if (m_pFontMgr) |
m_pFontMgr->RemoveFont(this); |
- } |
delete this; |
} |
} |
@@ -182,9 +177,8 @@ FX_BOOL CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, |
return FALSE; |
} |
CFX_ByteString csFontFamily; |
- if (pszFontFamily != NULL) { |
+ if (pszFontFamily) |
csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); |
- } |
uint32_t dwFlags = 0; |
if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { |
dwFlags |= FXFONT_FIXED_PITCH; |
@@ -223,11 +217,10 @@ FX_BOOL CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, |
csFontFamily += ",Italic"; |
} |
m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage); |
- FX_BOOL bRet = m_pFont->GetFace() != nullptr; |
- if (bRet) { |
- bRet = InitFont(); |
- } |
- return bRet; |
+ if (!m_pFont->GetFace()) |
+ return FALSE; |
+ |
+ return InitFont(); |
} |
FX_BOOL CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) { |
if (m_pFont) { |
@@ -339,7 +332,7 @@ void CFGAS_GEFont::GetFamilyName(CFX_WideString& wsFamily) const { |
} |
uint32_t CFGAS_GEFont::GetFontStyles() const { |
- ASSERT(m_pFont != NULL); |
+ ASSERT(m_pFont); |
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
if (m_bUseLogFontStyle) { |
return m_dwLogFontStyle; |
@@ -372,14 +365,13 @@ FX_BOOL CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode, |
int32_t& iWidth, |
FX_BOOL bRecursive, |
FX_BOOL bCharCode) { |
- ASSERT(m_pCharWidthMap != NULL); |
iWidth = m_pCharWidthMap->GetAt(wUnicode, 0); |
if (iWidth < 1) { |
if (!m_pProvider || |
!m_pProvider->GetCharWidth(this, wUnicode, iWidth, bCharCode)) { |
- IFGAS_Font* pFont = NULL; |
+ IFGAS_Font* pFont = nullptr; |
int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); |
- if (iGlyph != 0xFFFF && pFont != NULL) { |
+ if (iGlyph != 0xFFFF && pFont) { |
if (pFont == (IFGAS_Font*)this) { |
iWidth = m_pFont->GetGlyphWidth(iGlyph); |
if (iWidth < 0) { |
@@ -408,13 +400,11 @@ FX_BOOL CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode, |
CFX_Rect& bbox, |
FX_BOOL bRecursive, |
FX_BOOL bCharCode) { |
- ASSERT(m_pRectArray != NULL); |
- ASSERT(m_pBBoxMap != NULL); |
- void* pRect = NULL; |
+ void* pRect = nullptr; |
if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { |
- IFGAS_Font* pFont = NULL; |
+ IFGAS_Font* pFont = nullptr; |
int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); |
- if (iGlyph != 0xFFFF && pFont != NULL) { |
+ if (iGlyph != 0xFFFF && pFont) { |
if (pFont == (IFGAS_Font*)this) { |
FX_RECT rtBBox; |
if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { |
@@ -454,24 +444,22 @@ int32_t CFGAS_GEFont::GetItalicAngle() const { |
return m_pFont->GetSubstFont()->m_ItalicAngle; |
} |
int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) { |
- return GetGlyphIndex(wUnicode, TRUE, NULL, bCharCode); |
+ return GetGlyphIndex(wUnicode, TRUE, nullptr, bCharCode); |
} |
int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, |
FX_BOOL bRecursive, |
IFGAS_Font** ppFont, |
FX_BOOL bCharCode) { |
- ASSERT(m_pFontEncoding != NULL); |
int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); |
if (iGlyphIndex > 0) { |
- if (ppFont != NULL) { |
+ if (ppFont) |
*ppFont = (IFGAS_Font*)this; |
- } |
return iGlyphIndex; |
} |
const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); |
- if (pFontUSB == NULL) { |
+ if (!pFontUSB) |
return 0xFFFF; |
- } |
+ |
uint16_t wBitField = pFontUSB->wBitField; |
if (wBitField >= 128) { |
return 0xFFFF; |
@@ -479,8 +467,8 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, |
auto it = m_FontMapper.find(wUnicode); |
IFGAS_Font* pFont = it != m_FontMapper.end() ? it->second : nullptr; |
if (pFont && pFont != this) { |
- iGlyphIndex = |
- ((CFGAS_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); |
+ iGlyphIndex = ((CFGAS_GEFont*)pFont) |
+ ->GetGlyphIndex(wUnicode, FALSE, nullptr, bCharCode); |
if (iGlyphIndex != 0xFFFF) { |
int32_t i = m_SubstFonts.Find(pFont); |
if (i > -1) { |
@@ -501,7 +489,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, |
pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), |
wsFamily.c_str()); |
if (!pFont) |
- pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), NULL); |
+ pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); |
#endif |
if (pFont) { |
if (pFont == this) { |
@@ -512,7 +500,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, |
int32_t i = m_SubstFonts.GetSize(); |
m_SubstFonts.Add(pFont); |
iGlyphIndex = ((CFGAS_GEFont*)pFont) |
- ->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); |
+ ->GetGlyphIndex(wUnicode, FALSE, nullptr, bCharCode); |
if (iGlyphIndex != 0xFFFF) { |
iGlyphIndex |= ((i + 1) << 24); |
if (ppFont) |
@@ -535,15 +523,12 @@ void CFGAS_GEFont::Reset() { |
IFGAS_Font* pFont = m_SubstFonts[i]; |
((CFGAS_GEFont*)pFont)->Reset(); |
} |
- if (m_pCharWidthMap != NULL) { |
+ if (m_pCharWidthMap) |
m_pCharWidthMap->RemoveAll(); |
- } |
- if (m_pBBoxMap != NULL) { |
+ if (m_pBBoxMap) |
m_pBBoxMap->RemoveAll(); |
- } |
- if (m_pRectArray != NULL) { |
+ if (m_pRectArray) |
m_pRectArray->RemoveAll(); |
- } |
} |
IFGAS_Font* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; |