OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfdoc/cpvt_generateap.h" | 7 #include "core/fpdfdoc/cpvt_generateap.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_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 CPDF_SimpleParser syntax(DA.AsStringC()); | 40 CPDF_SimpleParser syntax(DA.AsStringC()); |
41 syntax.FindTagParamFromStart("Tf", 2); | 41 syntax.FindTagParamFromStart("Tf", 2); |
42 CFX_ByteString sFontName(syntax.GetWord()); | 42 CFX_ByteString sFontName(syntax.GetWord()); |
43 sFontName = PDF_NameDecode(sFontName); | 43 sFontName = PDF_NameDecode(sFontName); |
44 if (sFontName.IsEmpty()) | 44 if (sFontName.IsEmpty()) |
45 return false; | 45 return false; |
46 | 46 |
47 FX_FLOAT fFontSize = FX_atof(syntax.GetWord()); | 47 FX_FLOAT fFontSize = FX_atof(syntax.GetWord()); |
48 CPVT_Color crText = CPVT_Color::ParseColor(DA); | 48 CPVT_Color crText = CPVT_Color::ParseColor(DA); |
49 FX_BOOL bUseFormRes = FALSE; | 49 CPDF_Dictionary* pDRDict = pFormDict->GetDictBy("DR"); |
50 CPDF_Dictionary* pFontDict = nullptr; | 50 if (!pDRDict) |
51 CPDF_Dictionary* pDRDict = pAnnotDict->GetDictBy("DR"); | 51 return false; |
52 if (!pDRDict) { | 52 |
53 pDRDict = pFormDict->GetDictBy("DR"); | 53 CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"); |
54 bUseFormRes = TRUE; | |
55 } | |
56 CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr; | |
57 if (pDRFontDict) { | |
58 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1)); | |
59 if (!pFontDict && !bUseFormRes) { | |
60 pDRDict = pFormDict->GetDictBy("DR"); | |
61 pDRFontDict = pDRDict->GetDictBy("Font"); | |
62 if (pDRFontDict) | |
63 pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1)); | |
64 } | |
65 } | |
66 if (!pDRFontDict) | 54 if (!pDRFontDict) |
67 return false; | 55 return false; |
68 | 56 |
| 57 CPDF_Dictionary* pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1)); |
69 if (!pFontDict) { | 58 if (!pFontDict) { |
70 pFontDict = new CPDF_Dictionary; | 59 pFontDict = new CPDF_Dictionary; |
71 pFontDict->SetAtName("Type", "Font"); | 60 pFontDict->SetAtName("Type", "Font"); |
72 pFontDict->SetAtName("Subtype", "Type1"); | 61 pFontDict->SetAtName("Subtype", "Type1"); |
73 pFontDict->SetAtName("BaseFont", "Helvetica"); | 62 pFontDict->SetAtName("BaseFont", "Helvetica"); |
74 pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); | 63 pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); |
75 pDoc->AddIndirectObject(pFontDict); | 64 pDoc->AddIndirectObject(pFontDict); |
76 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); | 65 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); |
77 } | 66 } |
78 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); | 67 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); |
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 int32_t nFontIndex, | 1334 int32_t nFontIndex, |
1346 FX_FLOAT fFontSize) { | 1335 FX_FLOAT fFontSize) { |
1347 CFX_ByteTextBuf sRet; | 1336 CFX_ByteTextBuf sRet; |
1348 if (pFontMap) { | 1337 if (pFontMap) { |
1349 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 1338 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
1350 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 1339 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
1351 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 1340 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
1352 } | 1341 } |
1353 return sRet.MakeString(); | 1342 return sRet.MakeString(); |
1354 } | 1343 } |
OLD | NEW |