From 860a2d0299996d253272d831c9c7e533e9d3e890 Mon Sep 17 00:00:00 2001 From: npm Date: Mon, 12 Sep 2016 15:02:28 -0700 Subject: Remove GetDictBy("DR") from annot/field dictionaries We should not use DR field from annotation/field dictionaries, since these are not supposed to have one. In PDF spec 1.7, DR is defined only for the form dictionary, in 8.6.1. In addition, note 118 in Appendix H says "In PDF 1.2, an additional entry in the field dictionary, DR, was defined but was never implemented. Beginning with PDF 1.5, this entry is obsolete and should be ignored." The changes in CBA_FontMap fix the bug below. The changes in cpvt_generateap do not affect the bug but follow the reasoning from the above paragraph. BUG=pdfium:538 Review-Url: https://codereview.chromium.org/2337673002 --- core/fpdfdoc/cpvt_generateap.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'core/fpdfdoc/cpvt_generateap.cpp') 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"); -- cgit v1.2.3