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 <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 CPDF_Dictionary* pDRDict = pFormDict->GetDictFor("DR"); | 54 CPDF_Dictionary* pDRDict = pFormDict->GetDictFor("DR"); |
55 if (!pDRDict) | 55 if (!pDRDict) |
56 return false; | 56 return false; |
57 | 57 |
58 CPDF_Dictionary* pDRFontDict = pDRDict->GetDictFor("Font"); | 58 CPDF_Dictionary* pDRFontDict = pDRDict->GetDictFor("Font"); |
59 if (!pDRFontDict) | 59 if (!pDRFontDict) |
60 return false; | 60 return false; |
61 | 61 |
62 CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(sFontName.Mid(1)); | 62 CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(sFontName.Mid(1)); |
63 if (!pFontDict) { | 63 if (!pFontDict) { |
64 pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 64 pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(); |
65 pFontDict->SetNameFor("Type", "Font"); | 65 pFontDict->SetNameFor("Type", "Font"); |
66 pFontDict->SetNameFor("Subtype", "Type1"); | 66 pFontDict->SetNameFor("Subtype", "Type1"); |
67 pFontDict->SetNameFor("BaseFont", "Helvetica"); | 67 pFontDict->SetNameFor("BaseFont", "Helvetica"); |
68 pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 68 pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); |
69 pDRFontDict->SetReferenceFor(sFontName.Mid(1), pDoc, pFontDict); | 69 pDRFontDict->SetReferenceFor(sFontName.Mid(1), pDoc, pFontDict); |
70 } | 70 } |
71 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); | 71 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); |
72 if (!pDefFont) | 72 if (!pDefFont) |
73 return false; | 73 return false; |
74 | 74 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 565 |
566 auto pExtGStateDict = | 566 auto pExtGStateDict = |
567 pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); | 567 pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); |
568 pExtGStateDict->SetFor(sExtGSDictName, pGSDict.release()); | 568 pExtGStateDict->SetFor(sExtGSDictName, pGSDict.release()); |
569 return pExtGStateDict; | 569 return pExtGStateDict; |
570 } | 570 } |
571 | 571 |
572 std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict( | 572 std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict( |
573 CPDF_Document* pDoc, | 573 CPDF_Document* pDoc, |
574 const CFX_ByteString& sFontDictName) { | 574 const CFX_ByteString& sFontDictName) { |
575 CPDF_Dictionary* pFontDict = | 575 CPDF_Dictionary* pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(); |
576 pDoc->NewIndirect<CPDF_Dictionary>(pDoc->GetByteStringPool()); | |
577 pFontDict->SetNameFor("Type", "Font"); | 576 pFontDict->SetNameFor("Type", "Font"); |
578 pFontDict->SetNameFor("Subtype", "Type1"); | 577 pFontDict->SetNameFor("Subtype", "Type1"); |
579 pFontDict->SetNameFor("BaseFont", "Helvetica"); | 578 pFontDict->SetNameFor("BaseFont", "Helvetica"); |
580 pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 579 pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); |
581 | 580 |
582 auto pResourceFontDict = | 581 auto pResourceFontDict = |
583 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 582 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); |
584 pResourceFontDict->SetReferenceFor(sFontDictName, pDoc, pFontDict); | 583 pResourceFontDict->SetReferenceFor(sFontDictName, pDoc, pFontDict); |
585 return pResourceFontDict; | 584 return pResourceFontDict; |
586 } | 585 } |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 int32_t nFontIndex, | 1361 int32_t nFontIndex, |
1363 FX_FLOAT fFontSize) { | 1362 FX_FLOAT fFontSize) { |
1364 CFX_ByteTextBuf sRet; | 1363 CFX_ByteTextBuf sRet; |
1365 if (pFontMap) { | 1364 if (pFontMap) { |
1366 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 1365 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
1367 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 1366 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
1368 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 1367 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
1369 } | 1368 } |
1370 return sRet.MakeString(); | 1369 return sRet.MakeString(); |
1371 } | 1370 } |
OLD | NEW |