| 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 "fpdfsdk/pdfwindow/PWL_FontMap.h" | 7 #include "fpdfsdk/pdfwindow/PWL_FontMap.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
| 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" | 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 "Times-Roman", | 28 "Times-Roman", |
| 29 "Times-Bold", | 29 "Times-Bold", |
| 30 "Times-Italic", | 30 "Times-Italic", |
| 31 "Times-BoldItalic", | 31 "Times-BoldItalic", |
| 32 "Symbol", | 32 "Symbol", |
| 33 "ZapfDingbats"}; | 33 "ZapfDingbats"}; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler) | 37 CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler) |
| 38 : m_pPDFDoc(nullptr), m_pSystemHandler(pSystemHandler) { | 38 : m_pSystemHandler(pSystemHandler) { |
| 39 ASSERT(m_pSystemHandler); | 39 ASSERT(m_pSystemHandler); |
| 40 } | 40 } |
| 41 | 41 |
| 42 CPWL_FontMap::~CPWL_FontMap() { | 42 CPWL_FontMap::~CPWL_FontMap() { |
| 43 delete m_pPDFDoc; | |
| 44 m_pPDFDoc = nullptr; | |
| 45 | |
| 46 Empty(); | 43 Empty(); |
| 47 } | 44 } |
| 48 | 45 |
| 49 void CPWL_FontMap::SetSystemHandler(CFX_SystemHandler* pSystemHandler) { | 46 void CPWL_FontMap::SetSystemHandler(CFX_SystemHandler* pSystemHandler) { |
| 50 m_pSystemHandler = pSystemHandler; | 47 m_pSystemHandler = pSystemHandler; |
| 51 } | 48 } |
| 52 | 49 |
| 53 CPDF_Document* CPWL_FontMap::GetDocument() { | 50 CPDF_Document* CPWL_FontMap::GetDocument() { |
| 54 if (!m_pPDFDoc) { | 51 if (!m_pPDFDoc) { |
| 55 if (CPDF_ModuleMgr::Get()) { | 52 if (CPDF_ModuleMgr::Get()) { |
| 56 m_pPDFDoc = new CPDF_Document(nullptr); | 53 m_pPDFDoc.reset(new CPDF_Document(nullptr)); |
| 57 m_pPDFDoc->CreateNewDoc(); | 54 m_pPDFDoc->CreateNewDoc(); |
| 58 } | 55 } |
| 59 } | 56 } |
| 60 | 57 |
| 61 return m_pPDFDoc; | 58 return m_pPDFDoc.get(); |
| 62 } | 59 } |
| 63 | 60 |
| 64 CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex) { | 61 CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex) { |
| 65 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { | 62 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { |
| 66 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) { | 63 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) { |
| 67 return pData->pFont; | 64 return pData->pFont; |
| 68 } | 65 } |
| 69 } | 66 } |
| 70 | 67 |
| 71 return nullptr; | 68 return nullptr; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 case 1258: // Vietnamese | 403 case 1258: // Vietnamese |
| 407 nCharset = VIETNAMESE_CHARSET; | 404 nCharset = VIETNAMESE_CHARSET; |
| 408 break; | 405 break; |
| 409 case 1361: // Korean(Johab) | 406 case 1361: // Korean(Johab) |
| 410 nCharset = JOHAB_CHARSET; | 407 nCharset = JOHAB_CHARSET; |
| 411 break; | 408 break; |
| 412 } | 409 } |
| 413 return nCharset; | 410 return nCharset; |
| 414 } | 411 } |
| 415 | 412 |
| 416 const CPWL_FontMap::CharsetFontMap CPWL_FontMap::defaultTTFMap[] = { | 413 const FPDF_CharsetFontMap CPWL_FontMap::defaultTTFMap[] = { |
| 417 {ANSI_CHARSET, "Helvetica"}, {GB2312_CHARSET, "SimSun"}, | 414 {ANSI_CHARSET, "Helvetica"}, {GB2312_CHARSET, "SimSun"}, |
| 418 {CHINESEBIG5_CHARSET, "MingLiU"}, {SHIFTJIS_CHARSET, "MS Gothic"}, | 415 {CHINESEBIG5_CHARSET, "MingLiU"}, {SHIFTJIS_CHARSET, "MS Gothic"}, |
| 419 {HANGUL_CHARSET, "Batang"}, {RUSSIAN_CHARSET, "Arial"}, | 416 {HANGUL_CHARSET, "Batang"}, {RUSSIAN_CHARSET, "Arial"}, |
| 420 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ | 417 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ |
| 421 _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 418 _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 422 {EASTEUROPE_CHARSET, "Arial"}, | 419 {EASTEUROPE_CHARSET, "Arial"}, |
| 423 #else | 420 #else |
| 424 {EASTEUROPE_CHARSET, "Tahoma"}, | 421 {EASTEUROPE_CHARSET, "Tahoma"}, |
| 425 #endif | 422 #endif |
| 426 {ARABIC_CHARSET, "Arial"}, {-1, nullptr}}; | 423 {ARABIC_CHARSET, "Arial"}, {-1, nullptr}}; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 487 |
| 491 CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, | 488 CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, |
| 492 CPDF_Document* pAttachedDoc) | 489 CPDF_Document* pAttachedDoc) |
| 493 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} | 490 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} |
| 494 | 491 |
| 495 CPWL_DocFontMap::~CPWL_DocFontMap() {} | 492 CPWL_DocFontMap::~CPWL_DocFontMap() {} |
| 496 | 493 |
| 497 CPDF_Document* CPWL_DocFontMap::GetDocument() { | 494 CPDF_Document* CPWL_DocFontMap::GetDocument() { |
| 498 return m_pAttachedDoc; | 495 return m_pAttachedDoc; |
| 499 } | 496 } |
| OLD | NEW |