CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, uint8_t charSet, CFX_ByteString& csNameTag) { if (!pFormDict) { InitInterFormDict(pFormDict, pDocument); } CFX_ByteString csTemp; CPDF_Font* pFont = GetNativeInterFormFont(pFormDict, pDocument, charSet, csTemp); if (pFont) { csNameTag = csTemp; return pFont; } CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet); if (!csFontName.IsEmpty()) { if (FindInterFormFont(pFormDict, pDocument, csFontName, pFont, csNameTag)) { return pFont; } } pFont = CPDF_InterForm::AddNativeFont(charSet, pDocument); if (pFont) { AddInterFormFont(pFormDict, pDocument, pFont, csNameTag); } return pFont; }
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) { if (!pFormDict || !pFont) { return; } CFX_ByteString csTag; if (!FindInterFormFont(pFormDict, pFont, csTag)) { return; } CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); CPDF_Dictionary* pFonts = pDR->GetDict("Font"); pFonts->RemoveAt(csTag); }
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString& csNameTag) { csNameTag = ""; FX_BYTE charSet = CPDF_InterForm::GetNativeCharSet(); CFX_SubstFont* pSubst; CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument); if (pFont != NULL) { pSubst = (CFX_SubstFont*)pFont->GetSubstFont(); if (pSubst != NULL && pSubst->m_Charset == (int)charSet) { FindInterFormFont(pFormDict, pFont, csNameTag); return pFont; } } return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag); }
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString& csNameTag) { csNameTag.clear(); uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument); if (pFont) { CFX_SubstFont* pSubst = pFont->GetSubstFont(); if (pSubst && pSubst->m_Charset == (int)charSet) { FindInterFormFont(pFormDict, pFont, csNameTag); return pFont; } } return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag); }
void AddInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, const CPDF_Font* pFont, CFX_ByteString& csNameTag) { if (!pFont) { return; } if (!pFormDict) { InitInterFormDict(pFormDict, pDocument); } CFX_ByteString csTag; if (FindInterFormFont(pFormDict, pFont, csTag)) { csNameTag = csTag; return; } if (!pFormDict) { InitInterFormDict(pFormDict, pDocument); } CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); if (!pDR) { pDR = new CPDF_Dictionary; pFormDict->SetAt("DR", pDR); } CPDF_Dictionary* pFonts = pDR->GetDict("Font"); if (!pFonts) { pFonts = new CPDF_Dictionary; pDR->SetAt("Font", pFonts); } if (csNameTag.IsEmpty()) { csNameTag = pFont->GetBaseFont(); } csNameTag.Remove(' '); csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag); pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict()); }
FX_BOOL CPDF_InterForm::FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag) { return FindInterFormFont(m_pFormDict, m_pDocument, csFontName, pFont, csNameTag); }
FX_BOOL CPDF_InterForm::FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag) { return FindInterFormFont(m_pFormDict, pFont, csNameTag); }