OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/formfiller/cba_fontmap.h" | 7 #include "fpdfsdk/formfiller/cba_fontmap.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA"); | 212 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA"); |
213 if (pObj) | 213 if (pObj) |
214 sDA = pObj->GetString(); | 214 sDA = pObj->GetString(); |
215 | 215 |
216 if (bWidget) { | 216 if (bWidget) { |
217 if (sDA.IsEmpty()) { | 217 if (sDA.IsEmpty()) { |
218 pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA"); | 218 pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA"); |
219 sDA = pObj ? pObj->GetString() : CFX_ByteString(); | 219 sDA = pObj ? pObj->GetString() : CFX_ByteString(); |
220 } | 220 } |
221 } | 221 } |
| 222 if (sDA.IsEmpty()) |
| 223 return nullptr; |
222 | 224 |
| 225 CPDF_SimpleParser syntax(sDA.AsStringC()); |
| 226 syntax.FindTagParamFromStart("Tf", 2); |
| 227 CFX_ByteString sFontName(syntax.GetWord()); |
| 228 sAlias = PDF_NameDecode(sFontName).Mid(1); |
223 CPDF_Dictionary* pFontDict = nullptr; | 229 CPDF_Dictionary* pFontDict = nullptr; |
224 | 230 |
225 if (!sDA.IsEmpty()) { | 231 if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) { |
226 CPDF_SimpleParser syntax(sDA.AsStringC()); | 232 if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) { |
227 syntax.FindTagParamFromStart("Tf", 2); | 233 if (CPDF_Dictionary* pNormalResDict = |
228 CFX_ByteString sFontName(syntax.GetWord()); | 234 pNormalDict->GetDictBy("Resources")) { |
229 sAlias = PDF_NameDecode(sFontName).Mid(1); | 235 if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDictBy("Font")) |
230 | 236 pFontDict = pResFontDict->GetDictBy(sAlias); |
231 if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR")) | |
232 if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) | |
233 pFontDict = pDRFontDict->GetDictBy(sAlias); | |
234 | |
235 if (!pFontDict) | |
236 if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) | |
237 if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) | |
238 if (CPDF_Dictionary* pNormalResDict = | |
239 pNormalDict->GetDictBy("Resources")) | |
240 if (CPDF_Dictionary* pResFontDict = | |
241 pNormalResDict->GetDictBy("Font")) | |
242 pFontDict = pResFontDict->GetDictBy(sAlias); | |
243 | |
244 if (bWidget) { | |
245 if (!pFontDict) { | |
246 if (pAcroFormDict) { | |
247 if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR")) | |
248 if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) | |
249 pFontDict = pDRFontDict->GetDictBy(sAlias); | |
250 } | |
251 } | 237 } |
252 } | 238 } |
253 } | 239 } |
254 | 240 |
| 241 if (bWidget && !pFontDict && pAcroFormDict) { |
| 242 if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR")) { |
| 243 if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) |
| 244 pFontDict = pDRFontDict->GetDictBy(sAlias); |
| 245 } |
| 246 } |
| 247 |
255 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; | 248 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
256 } | 249 } |
257 | 250 |
258 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { | 251 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
259 m_sAPType = sAPType; | 252 m_sAPType = sAPType; |
260 | 253 |
261 Reset(); | 254 Reset(); |
262 Initialize(); | 255 Initialize(); |
263 } | 256 } |
OLD | NEW |