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/fpdf_page/pageint.h" | 7 #include "core/fpdfapi/fpdf_page/pageint.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (it != m_FontMap.end()) { | 138 if (it != m_FontMap.end()) { |
139 pFontData = it->second; | 139 pFontData = it->second; |
140 if (pFontData->get()) { | 140 if (pFontData->get()) { |
141 return pFontData->AddRef(); | 141 return pFontData->AddRef(); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 if (findOnly) | 145 if (findOnly) |
146 return nullptr; | 146 return nullptr; |
147 | 147 |
148 CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pFontDict); | 148 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pFontDict); |
149 if (!pFont) | 149 if (!pFont) |
150 return nullptr; | 150 return nullptr; |
151 | 151 |
152 if (pFontData) { | 152 if (pFontData) { |
153 pFontData->reset(pFont); | 153 pFontData->reset(pFont.release()); |
154 } else { | 154 } else { |
155 pFontData = new CPDF_CountedFont(pFont); | 155 pFontData = new CPDF_CountedFont(pFont.release()); |
156 m_FontMap[pFontDict] = pFontData; | 156 m_FontMap[pFontDict] = pFontData; |
157 } | 157 } |
158 return pFontData->AddRef(); | 158 return pFontData->AddRef(); |
159 } | 159 } |
160 | 160 |
161 CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteString& fontName, | 161 CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteString& fontName, |
162 CPDF_FontEncoding* pEncoding) { | 162 CPDF_FontEncoding* pEncoding) { |
163 if (fontName.IsEmpty()) | 163 if (fontName.IsEmpty()) |
164 return nullptr; | 164 return nullptr; |
165 | 165 |
(...skipping 19 matching lines...) Expand all Loading... |
185 } | 185 } |
186 | 186 |
187 CPDF_Dictionary* pDict = new CPDF_Dictionary; | 187 CPDF_Dictionary* pDict = new CPDF_Dictionary; |
188 pDict->SetNameFor("Type", "Font"); | 188 pDict->SetNameFor("Type", "Font"); |
189 pDict->SetNameFor("Subtype", "Type1"); | 189 pDict->SetNameFor("Subtype", "Type1"); |
190 pDict->SetNameFor("BaseFont", fontName); | 190 pDict->SetNameFor("BaseFont", fontName); |
191 if (pEncoding) { | 191 if (pEncoding) { |
192 pDict->SetFor("Encoding", pEncoding->Realize()); | 192 pDict->SetFor("Encoding", pEncoding->Realize()); |
193 } | 193 } |
194 m_pPDFDoc->AddIndirectObject(pDict); | 194 m_pPDFDoc->AddIndirectObject(pDict); |
195 CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pDict); | 195 std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pDict); |
196 if (!pFont) { | 196 if (!pFont) |
197 return nullptr; | 197 return nullptr; |
198 } | 198 |
199 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont); | 199 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont.release()); |
200 m_FontMap[pDict] = fontData; | 200 m_FontMap[pDict] = fontData; |
201 return fontData->AddRef(); | 201 return fontData->AddRef(); |
202 } | 202 } |
203 | 203 |
204 void CPDF_DocPageData::ReleaseFont(const CPDF_Dictionary* pFontDict) { | 204 void CPDF_DocPageData::ReleaseFont(const CPDF_Dictionary* pFontDict) { |
205 if (!pFontDict) | 205 if (!pFontDict) |
206 return; | 206 return; |
207 | 207 |
208 auto it = m_FontMap.find(pFontDict); | 208 auto it = m_FontMap.find(pFontDict); |
209 if (it == m_FontMap.end()) | 209 if (it == m_FontMap.end()) |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 544 } |
545 | 545 |
546 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( | 546 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( |
547 CPDF_Object* pPatternObj) const { | 547 CPDF_Object* pPatternObj) const { |
548 if (!pPatternObj) | 548 if (!pPatternObj) |
549 return nullptr; | 549 return nullptr; |
550 | 550 |
551 auto it = m_PatternMap.find(pPatternObj); | 551 auto it = m_PatternMap.find(pPatternObj); |
552 return it != m_PatternMap.end() ? it->second : nullptr; | 552 return it != m_PatternMap.end() ? it->second : nullptr; |
553 } | 553 } |
OLD | NEW |