| 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 "core/fpdfapi/page/cpdf_docpagedata.h" | 7 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (pFont->GetFontDict()->KeyExist("Widths")) | 168 if (pFont->GetFontDict()->KeyExist("Widths")) |
| 169 continue; | 169 continue; |
| 170 | 170 |
| 171 CPDF_Type1Font* pT1Font = pFont->AsType1Font(); | 171 CPDF_Type1Font* pT1Font = pFont->AsType1Font(); |
| 172 if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding)) | 172 if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding)) |
| 173 continue; | 173 continue; |
| 174 | 174 |
| 175 return fontData->AddRef(); | 175 return fontData->AddRef(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPDFDoc->GetByteStringPool()); | 178 CPDF_Dictionary* pDict = |
| 179 m_pPDFDoc->NewIndirect<CPDF_Dictionary>(m_pPDFDoc->GetByteStringPool()); |
| 179 pDict->SetNameFor("Type", "Font"); | 180 pDict->SetNameFor("Type", "Font"); |
| 180 pDict->SetNameFor("Subtype", "Type1"); | 181 pDict->SetNameFor("Subtype", "Type1"); |
| 181 pDict->SetNameFor("BaseFont", fontName); | 182 pDict->SetNameFor("BaseFont", fontName); |
| 182 if (pEncoding) { | 183 if (pEncoding) { |
| 183 pDict->SetFor("Encoding", | 184 pDict->SetFor("Encoding", |
| 184 pEncoding->Realize(m_pPDFDoc->GetByteStringPool())); | 185 pEncoding->Realize(m_pPDFDoc->GetByteStringPool())); |
| 185 } | 186 } |
| 186 m_pPDFDoc->AddIndirectObject(pDict); | 187 |
| 187 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pDict); | 188 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pDict); |
| 188 if (!pFont) | 189 if (!pFont) |
| 189 return nullptr; | 190 return nullptr; |
| 190 | 191 |
| 191 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont.release()); | 192 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont.release()); |
| 192 m_FontMap[pDict] = fontData; | 193 m_FontMap[pDict] = fontData; |
| 193 return fontData->AddRef(); | 194 return fontData->AddRef(); |
| 194 } | 195 } |
| 195 | 196 |
| 196 void CPDF_DocPageData::ReleaseFont(const CPDF_Dictionary* pFontDict) { | 197 void CPDF_DocPageData::ReleaseFont(const CPDF_Dictionary* pFontDict) { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 528 } |
| 528 | 529 |
| 529 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( | 530 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( |
| 530 CPDF_Object* pPatternObj) const { | 531 CPDF_Object* pPatternObj) const { |
| 531 if (!pPatternObj) | 532 if (!pPatternObj) |
| 532 return nullptr; | 533 return nullptr; |
| 533 | 534 |
| 534 auto it = m_PatternMap.find(pPatternObj); | 535 auto it = m_PatternMap.find(pPatternObj); |
| 535 return it != m_PatternMap.end() ? it->second : nullptr; | 536 return it != m_PatternMap.end() ? it->second : nullptr; |
| 536 } | 537 } |
| OLD | NEW |