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/fpdfapi/fpdf_font/include/cpdf_font.h" | 7 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 m_pToUnicodeMap(nullptr), | 53 m_pToUnicodeMap(nullptr), |
54 m_bToUnicodeLoaded(FALSE), | 54 m_bToUnicodeLoaded(FALSE), |
55 m_Flags(0), | 55 m_Flags(0), |
56 m_StemV(0), | 56 m_StemV(0), |
57 m_Ascent(0), | 57 m_Ascent(0), |
58 m_Descent(0), | 58 m_Descent(0), |
59 m_ItalicAngle(0) {} | 59 m_ItalicAngle(0) {} |
60 | 60 |
61 CPDF_Font::~CPDF_Font() { | 61 CPDF_Font::~CPDF_Font() { |
62 delete m_pToUnicodeMap; | 62 delete m_pToUnicodeMap; |
63 m_pToUnicodeMap = NULL; | 63 m_pToUnicodeMap = nullptr; |
64 | 64 |
65 if (m_pFontFile) { | 65 if (m_pFontFile) { |
66 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( | 66 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( |
67 const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream())); | 67 const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream())); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 bool CPDF_Font::IsType1Font() const { | 71 bool CPDF_Font::IsType1Font() const { |
72 return false; | 72 return false; |
73 } | 73 } |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); | 325 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); |
326 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); | 326 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); |
327 if (pFont) { | 327 if (pFont) { |
328 return pFont; | 328 return pFont; |
329 } | 329 } |
330 CPDF_Dictionary* pDict = new CPDF_Dictionary; | 330 CPDF_Dictionary* pDict = new CPDF_Dictionary; |
331 pDict->SetAtName("Type", "Font"); | 331 pDict->SetAtName("Type", "Font"); |
332 pDict->SetAtName("Subtype", "Type1"); | 332 pDict->SetAtName("Subtype", "Type1"); |
333 pDict->SetAtName("BaseFont", fontname); | 333 pDict->SetAtName("BaseFont", fontname); |
334 pDict->SetAtName("Encoding", "WinAnsiEncoding"); | 334 pDict->SetAtName("Encoding", "WinAnsiEncoding"); |
335 pFont = CPDF_Font::CreateFontF(NULL, pDict); | 335 pFont = CPDF_Font::CreateFontF(nullptr, pDict); |
336 pFontGlobals->Set(pDoc, font_id, pFont); | 336 pFontGlobals->Set(pDoc, font_id, pFont); |
337 return pFont; | 337 return pFont; |
338 } | 338 } |
339 | 339 |
340 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, | 340 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, |
341 CPDF_Dictionary* pFontDict) { | 341 CPDF_Dictionary* pFontDict) { |
342 CFX_ByteString type = pFontDict->GetStringBy("Subtype"); | 342 CFX_ByteString type = pFontDict->GetStringBy("Subtype"); |
343 std::unique_ptr<CPDF_Font> pFont; | 343 std::unique_ptr<CPDF_Font> pFont; |
344 if (type == "TrueType") { | 344 if (type == "TrueType") { |
345 CFX_ByteString tag = pFontDict->GetStringBy("BaseFont").Left(4); | 345 CFX_ByteString tag = pFontDict->GetStringBy("BaseFont").Left(4); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 if (charcode < 0 || charcode >= 256) | 462 if (charcode < 0 || charcode >= 256) |
463 return nullptr; | 463 return nullptr; |
464 | 464 |
465 const FX_CHAR* name = nullptr; | 465 const FX_CHAR* name = nullptr; |
466 if (pCharNames) | 466 if (pCharNames) |
467 name = pCharNames[charcode].c_str(); | 467 name = pCharNames[charcode].c_str(); |
468 if ((!name || name[0] == 0) && iBaseEncoding) | 468 if ((!name || name[0] == 0) && iBaseEncoding) |
469 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); | 469 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); |
470 return name && name[0] ? name : nullptr; | 470 return name && name[0] ? name : nullptr; |
471 } | 471 } |
OLD | NEW |