| 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 = | 178 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPDFDoc->GetByteStringPool()); |
| 179 m_pPDFDoc->AddIndirectDictionary(m_pPDFDoc->GetByteStringPool()); | |
| 180 pDict->SetNameFor("Type", "Font"); | 179 pDict->SetNameFor("Type", "Font"); |
| 181 pDict->SetNameFor("Subtype", "Type1"); | 180 pDict->SetNameFor("Subtype", "Type1"); |
| 182 pDict->SetNameFor("BaseFont", fontName); | 181 pDict->SetNameFor("BaseFont", fontName); |
| 183 if (pEncoding) { | 182 if (pEncoding) { |
| 184 pDict->SetFor("Encoding", | 183 pDict->SetFor("Encoding", |
| 185 pEncoding->Realize(m_pPDFDoc->GetByteStringPool())); | 184 pEncoding->Realize(m_pPDFDoc->GetByteStringPool())); |
| 186 } | 185 } |
| 186 m_pPDFDoc->AddIndirectObject(pDict); |
| 187 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pDict); | 187 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pDict); |
| 188 if (!pFont) | 188 if (!pFont) |
| 189 return nullptr; | 189 return nullptr; |
| 190 | 190 |
| 191 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont.release()); | 191 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont.release()); |
| 192 m_FontMap[pDict] = fontData; | 192 m_FontMap[pDict] = fontData; |
| 193 return fontData->AddRef(); | 193 return fontData->AddRef(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void CPDF_DocPageData::ReleaseFont(const CPDF_Dictionary* pFontDict) { | 196 void CPDF_DocPageData::ReleaseFont(const CPDF_Dictionary* pFontDict) { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 } | 537 } |
| 538 | 538 |
| 539 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( | 539 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( |
| 540 CPDF_Object* pPatternObj) const { | 540 CPDF_Object* pPatternObj) const { |
| 541 if (!pPatternObj) | 541 if (!pPatternObj) |
| 542 return nullptr; | 542 return nullptr; |
| 543 | 543 |
| 544 auto it = m_PatternMap.find(pPatternObj); | 544 auto it = m_PatternMap.find(pPatternObj); |
| 545 return it != m_PatternMap.end() ? it->second : nullptr; | 545 return it != m_PatternMap.end() ? it->second : nullptr; |
| 546 } | 546 } |
| OLD | NEW |