summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp23
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp41
2 files changed, 23 insertions, 41 deletions
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index be96d2d1d3..8c8cb9333c 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -46,26 +46,15 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
FX_FLOAT fFontSize = FX_atof(syntax.GetWord());
CPVT_Color crText = CPVT_Color::ParseColor(DA);
- FX_BOOL bUseFormRes = FALSE;
- CPDF_Dictionary* pFontDict = nullptr;
- CPDF_Dictionary* pDRDict = pAnnotDict->GetDictBy("DR");
- if (!pDRDict) {
- pDRDict = pFormDict->GetDictBy("DR");
- bUseFormRes = TRUE;
- }
- CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr;
- if (pDRFontDict) {
- pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
- if (!pFontDict && !bUseFormRes) {
- pDRDict = pFormDict->GetDictBy("DR");
- pDRFontDict = pDRDict->GetDictBy("Font");
- if (pDRFontDict)
- pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
- }
- }
+ CPDF_Dictionary* pDRDict = pFormDict->GetDictBy("DR");
+ if (!pDRDict)
+ return false;
+
+ CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font");
if (!pDRFontDict)
return false;
+ CPDF_Dictionary* pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
if (!pFontDict) {
pFontDict = new CPDF_Dictionary;
pFontDict->SetAtName("Type", "Font");
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index a816e2ce7f..575f6c3145 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -219,36 +219,29 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
sDA = pObj ? pObj->GetString() : CFX_ByteString();
}
}
+ if (sDA.IsEmpty())
+ return nullptr;
+ CPDF_SimpleParser syntax(sDA.AsStringC());
+ syntax.FindTagParamFromStart("Tf", 2);
+ CFX_ByteString sFontName(syntax.GetWord());
+ sAlias = PDF_NameDecode(sFontName).Mid(1);
CPDF_Dictionary* pFontDict = nullptr;
- if (!sDA.IsEmpty()) {
- CPDF_SimpleParser syntax(sDA.AsStringC());
- syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString sFontName(syntax.GetWord());
- sAlias = PDF_NameDecode(sFontName).Mid(1);
+ if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) {
+ if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) {
+ if (CPDF_Dictionary* pNormalResDict =
+ pNormalDict->GetDictBy("Resources")) {
+ if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDictBy("Font"))
+ pFontDict = pResFontDict->GetDictBy(sAlias);
+ }
+ }
+ }
- if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR"))
+ if (bWidget && !pFontDict && pAcroFormDict) {
+ if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR")) {
if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
pFontDict = pDRFontDict->GetDictBy(sAlias);
-
- if (!pFontDict)
- if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP"))
- if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N"))
- if (CPDF_Dictionary* pNormalResDict =
- pNormalDict->GetDictBy("Resources"))
- if (CPDF_Dictionary* pResFontDict =
- pNormalResDict->GetDictBy("Font"))
- pFontDict = pResFontDict->GetDictBy(sAlias);
-
- if (bWidget) {
- if (!pFontDict) {
- if (pAcroFormDict) {
- if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR"))
- if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
- pFontDict = pDRFontDict->GetDictBy(sAlias);
- }
- }
}
}