CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, CFX_ByteString& sFontAlias, int32_t nCharset) { if (!pResDict) return NULL; CPDF_Document* pDocument = GetDocument(); ASSERT(pDocument != NULL); CPDF_Dictionary* pFonts = pResDict->GetDict("Font"); if (pFonts == NULL) return NULL; CPDF_Font* pFind = NULL; FX_POSITION pos = pFonts->GetStartPos(); while (pos) { CPDF_Object* pObj = NULL; CFX_ByteString csKey; pObj = pFonts->GetNextElement(pos, csKey); if (pObj == NULL) continue; CPDF_Object* pDirect = pObj->GetDirect(); if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) continue; CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; if (pElement->GetString("Type") != "Font") continue; CPDF_Font* pFont = pDocument->LoadFont(pElement); if (pFont == NULL) continue; const CFX_SubstFont* pSubst = pFont->GetSubstFont(); if (pSubst == NULL) continue; if (pSubst->m_Charset == nCharset) { sFontAlias = csKey; pFind = pFont; } } return pFind; }
CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, CFX_ByteString& sFontAlias, int32_t nCharset) { if (!pResDict) return nullptr; CPDF_Dictionary* pFonts = pResDict->GetDictBy("Font"); if (!pFonts) return nullptr; CPDF_Document* pDocument = GetDocument(); CPDF_Font* pFind = nullptr; for (const auto& it : *pFonts) { const CFX_ByteString& csKey = it.first; CPDF_Object* pObj = it.second; if (!pObj) continue; CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); if (!pElement) continue; if (pElement->GetStringBy("Type") != "Font") continue; CPDF_Font* pFont = pDocument->LoadFont(pElement); if (!pFont) continue; const CFX_SubstFont* pSubst = pFont->GetSubstFont(); if (!pSubst) continue; if (pSubst->m_Charset == nCharset) { sFontAlias = csKey; pFind = pFont; } } return pFind; }