| Index: xfa/fgas/font/fgas_stdfontmgr.cpp
|
| diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp
|
| index 9ea37cf32b2f8102bac7df10bb84c813d3e27097..e6dd0696ad56a030e766a1e1f86b09162aab6c07 100644
|
| --- a/xfa/fgas/font/fgas_stdfontmgr.cpp
|
| +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp
|
| @@ -26,7 +26,7 @@ CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator)
|
| m_StreamFonts(4),
|
| m_DeriveFonts(4) {
|
| if (m_pEnumerator) {
|
| - m_pEnumerator(m_FontFaces, NULL, 0xFEFF);
|
| + m_pEnumerator(m_FontFaces, nullptr, 0xFEFF);
|
| }
|
| }
|
|
|
| @@ -48,16 +48,9 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
|
| uint32_t dwFontStyles,
|
| const FX_WCHAR* pszFontFamily) {
|
| uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles);
|
| - IFGAS_Font* pFont = NULL;
|
| + IFGAS_Font* pFont = nullptr;
|
| if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
|
| - return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL;
|
| - }
|
| - FX_FONTDESCRIPTOR const* pFD;
|
| - if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) {
|
| - if ((pFD = FindFont(NULL, dwFontStyles, TRUE, wCodePage)) == NULL) {
|
| - if ((pFD = FindFont(NULL, dwFontStyles, FALSE, wCodePage)) == NULL)
|
| - return NULL;
|
| - }
|
| + return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr;
|
| }
|
| ASSERT(pFD);
|
| pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
|
| @@ -68,7 +61,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
|
| m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
|
| return LoadFont(pFont, dwFontStyles, wCodePage);
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
| IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCharset(
|
| uint8_t nCharset,
|
| @@ -129,19 +122,18 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
|
| uint16_t wCodePage) {
|
| uint32_t dwHash =
|
| FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage);
|
| - IFGAS_Font* pFont = NULL;
|
| + IFGAS_Font* pFont = nullptr;
|
| if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
|
| - return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL;
|
| + return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr;
|
| }
|
| - FX_FONTDESCRIPTOR const* pFD = NULL;
|
| - if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) {
|
| - if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) ==
|
| - NULL) {
|
| - return NULL;
|
| - }
|
| - }
|
| - ASSERT(pFD);
|
| - if (wCodePage == 0xFFFF) {
|
| + FX_FONTDESCRIPTOR const* pFD =
|
| + FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage);
|
| + if (!pFD)
|
| + pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage);
|
| + if (!pFD)
|
| + return nullptr;
|
| +
|
| + if (wCodePage == 0xFFFF)
|
| wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet);
|
| }
|
| pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
|
| @@ -152,12 +144,12 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
|
| m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
|
| return LoadFont(pFont, dwFontStyles, wCodePage);
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
| IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer,
|
| int32_t iLength) {
|
| ASSERT(pBuffer && iLength > 0);
|
| - IFGAS_Font* pFont = NULL;
|
| + IFGAS_Font* pFont = nullptr;
|
| if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) {
|
| if (pFont) {
|
| return pFont->Retain();
|
| @@ -169,24 +161,24 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer,
|
| m_BufferFonts.SetAt((void*)pBuffer, pFont);
|
| return pFont->Retain();
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
| IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) {
|
| ASSERT(pszFileName);
|
| uint32_t dwHash = FX_HashCode_GetW(pszFileName, false);
|
| - IFGAS_Font* pFont = NULL;
|
| + IFGAS_Font* pFont = nullptr;
|
| if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
|
| if (pFont) {
|
| return pFont->Retain();
|
| }
|
| }
|
| - pFont = IFGAS_Font::LoadFont(pszFileName, NULL);
|
| + pFont = IFGAS_Font::LoadFont(pszFileName, nullptr);
|
| if (pFont) {
|
| m_Fonts.Add(pFont);
|
| m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
|
| return pFont->Retain();
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
| IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
|
| const FX_WCHAR* pszFontAlias,
|
| @@ -194,7 +186,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
|
| uint16_t wCodePage,
|
| FX_BOOL bSaveStream) {
|
| ASSERT(pFontStream && pFontStream->GetLength() > 0);
|
| - IFGAS_Font* pFont = NULL;
|
| + IFGAS_Font* pFont = nullptr;
|
| if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) {
|
| if (pFont) {
|
| if (pszFontAlias) {
|
| @@ -216,7 +208,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
|
| }
|
| return LoadFont(pFont, dwFontStyles, wCodePage);
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
| IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFGAS_Font* pSrcFont,
|
| uint32_t dwFontStyles,
|
| @@ -229,7 +221,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFGAS_Font* pSrcFont,
|
| (void*)(uintptr_t)wCodePage};
|
| uint32_t dwHash = FX_HashCode_GetA(
|
| CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false);
|
| - IFGAS_Font* pFont = NULL;
|
| + IFGAS_Font* pFont = nullptr;
|
| if (m_DeriveFonts.GetCount() > 0) {
|
| m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont);
|
| if (pFont) {
|
| @@ -246,7 +238,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFGAS_Font* pSrcFont,
|
| }
|
| return pFont;
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| void CFGAS_StdFontMgrImp::ClearFontCache() {
|
| @@ -260,7 +252,7 @@ void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap,
|
| void* pKey;
|
| void* pFind;
|
| while (pos) {
|
| - pFind = NULL;
|
| + pFind = nullptr;
|
| fontMap.GetNextAssoc(pos, pKey, pFind);
|
| if (pFind != (void*)pFont) {
|
| continue;
|
| @@ -304,11 +296,11 @@ FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont(
|
| if (pszFontFamily && m_pEnumerator) {
|
| CFX_FontDescriptors namedFonts;
|
| m_pEnumerator(namedFonts, pszFontFamily, wUnicode);
|
| - params.pwsFamily = NULL;
|
| + params.pwsFamily = nullptr;
|
| pDesc = FX_DefFontMatcher(¶ms, namedFonts);
|
| - if (pDesc == NULL) {
|
| - return NULL;
|
| - }
|
| + if (!pDesc)
|
| + return nullptr;
|
| +
|
| for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) {
|
| FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i);
|
| if (*pMatch == *pDesc) {
|
| @@ -318,11 +310,11 @@ FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont(
|
| int index = m_FontFaces.Add(*pDesc);
|
| return m_FontFaces.GetPtrAt(index);
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
| FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
|
| const CFX_FontDescriptors& fonts) {
|
| - FX_FONTDESCRIPTOR const* pBestFont = NULL;
|
| + FX_FONTDESCRIPTOR const* pBestFont = nullptr;
|
| int32_t iBestSimilar = 0;
|
| FX_BOOL bMatchStyle =
|
| (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0;
|
| @@ -373,7 +365,7 @@ FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
|
| pBestFont = pFont;
|
| }
|
| }
|
| - return iBestSimilar < 1 ? NULL : pBestFont;
|
| + return iBestSimilar < 1 ? nullptr : pBestFont;
|
| }
|
| int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont,
|
| uint32_t dwFontStyles) {
|
| @@ -442,7 +434,7 @@ static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe,
|
| static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts,
|
| const FX_WCHAR* pwsFaceName,
|
| FX_WCHAR wUnicode) {
|
| - HDC hDC = ::GetDC(NULL);
|
| + HDC hDC = ::GetDC(nullptr);
|
| LOGFONTW lfFind;
|
| FXSYS_memset(&lfFind, 0, sizeof(lfFind));
|
| lfFind.lfCharSet = DEFAULT_CHARSET;
|
| @@ -452,7 +444,7 @@ static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts,
|
| }
|
| EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind,
|
| (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0);
|
| - ::ReleaseDC(NULL, hDC);
|
| + ::ReleaseDC(nullptr, hDC);
|
| }
|
| FX_LPEnumAllFonts FX_GetDefFontEnumerator() {
|
| return FX_EnumGdiFonts;
|
| @@ -478,12 +470,12 @@ CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() {
|
| Restart:
|
| void* pCurHandle =
|
| m_FolderQueue.GetSize() == 0
|
| - ? NULL
|
| + ? nullptr
|
| : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle;
|
| - if (NULL == pCurHandle) {
|
| - if (m_FolderPaths.GetSize() < 1) {
|
| + if (!pCurHandle) {
|
| + if (m_FolderPaths.GetSize() < 1)
|
| return "";
|
| - }
|
| +
|
| pCurHandle =
|
| FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str());
|
| FX_HandleParentPath hpp;
|
| @@ -520,9 +512,9 @@ Restart:
|
| m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath +
|
| bsFolderSpearator + bsName;
|
| hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str());
|
| - if (hpp.pFileHandle == NULL) {
|
| + if (!hpp.pFileHandle)
|
| continue;
|
| - }
|
| +
|
| m_FolderQueue.Add(hpp);
|
| pCurHandle = hpp.pFileHandle;
|
| continue;
|
| @@ -545,7 +537,7 @@ FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() {
|
| IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) {
|
| IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC());
|
| m_wsNext = GetNextFile().UTF8Decode();
|
| - pos = 0 != m_wsNext.GetLength() ? pAccess : NULL;
|
| + pos = 0 != m_wsNext.GetLength() ? pAccess : nullptr;
|
| return (IFX_FileAccess*)pAccess;
|
| }
|
|
|
| @@ -641,18 +633,16 @@ void CFGAS_FontMgrImp::Release() {
|
| uint32_t dwHash;
|
| IFX_FileAccess* pFileAccess;
|
| m_Hash2FileAccess.GetNextAssoc(pos, dwHash, pFileAccess);
|
| - if (NULL != pFileAccess) {
|
| + if (pFileAccess)
|
| pFileAccess->Release();
|
| - }
|
| }
|
| pos = m_FileAccess2IFXFont.GetStartPosition();
|
| while (pos) {
|
| uint32_t dwHash;
|
| IFGAS_Font* pFont;
|
| m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont);
|
| - if (NULL != pFont) {
|
| + if (pFont)
|
| pFont->Release();
|
| - }
|
| }
|
| pos = m_IFXFont2FileRead.GetStartPosition();
|
| while (pos) {
|
| @@ -1216,9 +1206,8 @@ void CFGAS_FontMgrImp::ClearFontCache() {
|
| uint32_t dwHash;
|
| IFGAS_Font* pFont;
|
| m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont);
|
| - if (NULL != pFont) {
|
| + if (pFont)
|
| pFont->Release();
|
| - }
|
| }
|
| pos = m_IFXFont2FileRead.GetStartPosition();
|
| while (pos) {
|
| @@ -1229,9 +1218,9 @@ void CFGAS_FontMgrImp::ClearFontCache() {
|
| }
|
| }
|
| void CFGAS_FontMgrImp::RemoveFont(IFGAS_Font* pEFont) {
|
| - if (NULL == pEFont) {
|
| + if (!pEFont)
|
| return;
|
| - }
|
| +
|
| IFX_FileRead* pFileRead;
|
| if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) {
|
| pFileRead->Release();
|
| @@ -1253,10 +1242,10 @@ void CFGAS_FontMgrImp::RemoveFont(IFGAS_Font* pEFont) {
|
| uint32_t dwHash;
|
| CFX_ArrayTemplate<IFGAS_Font*>* pFonts;
|
| m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts);
|
| - if (NULL != pFonts) {
|
| + if (pFonts) {
|
| for (int32_t i = 0; i < pFonts->GetSize(); i++) {
|
| if (pFonts->GetAt(i) == pEFont) {
|
| - pFonts->SetAt(i, NULL);
|
| + pFonts->SetAt(i, nullptr);
|
| }
|
| }
|
| } else {
|
| @@ -1352,9 +1341,9 @@ uint32_t CFGAS_FontMgrImp::GetFlags(FXFT_Face pFace) {
|
| ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3]))
|
| void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table,
|
| CFX_WideStringArray& Names) {
|
| - if (NULL == name_table) {
|
| + if (!name_table)
|
| return;
|
| - }
|
| +
|
| uint8_t* lpTable = (uint8_t*)name_table;
|
| CFX_WideString wsFamily;
|
| uint8_t* sp = lpTable + 2;
|
| @@ -1458,7 +1447,7 @@ void CFGAS_FontMgrImp::GetCharsets(FXFT_Face pFace,
|
| CFX_ArrayTemplate<uint16_t>& Charsets) {
|
| Charsets.RemoveAll();
|
| TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2);
|
| - if (NULL != pOS2) {
|
| + if (pOS2) {
|
| uint16_t a1, a2, a3, a4;
|
| a1 = pOS2->ulCodePageRange1 & 0x0000ffff;
|
| CODEPAGERANGE_IMPLEMENT(1);
|
| @@ -1477,7 +1466,7 @@ void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace,
|
| uint32_t* USB,
|
| uint32_t* CSB) {
|
| TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2);
|
| - if (NULL != pOS2) {
|
| + if (pOS2) {
|
| USB[0] = pOS2->ulUnicodeRange1;
|
| USB[1] = pOS2->ulUnicodeRange2;
|
| USB[2] = pOS2->ulUnicodeRange3;
|
|
|