Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 | 36 | 
| 37 CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler) | 37 CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler) | 
| 38 : 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 Empty(); | 43 Empty(); | 
| 44 } | 44 } | 
| 45 | 45 | 
| 46 void CPWL_FontMap::SetSystemHandler(CFX_SystemHandler* pSystemHandler) { | |
| 47 m_pSystemHandler = pSystemHandler; | |
| 48 } | |
| 49 | |
| 50 CPDF_Document* CPWL_FontMap::GetDocument() { | 46 CPDF_Document* CPWL_FontMap::GetDocument() { | 
| 51 if (!m_pPDFDoc) { | 47 if (!m_pPDFDoc) { | 
| 52 if (CPDF_ModuleMgr::Get()) { | 48 if (CPDF_ModuleMgr::Get()) { | 
| 53 m_pPDFDoc.reset(new CPDF_Document(nullptr)); | 49 m_pPDFDoc.reset(new CPDF_Document(nullptr)); | 
| 54 m_pPDFDoc->CreateNewDoc(); | 50 m_pPDFDoc->CreateNewDoc(); | 
| 55 } | 51 } | 
| 56 } | 52 } | 
| 57 | 53 | 
| 58 return m_pPDFDoc.get(); | 54 return m_pPDFDoc.get(); | 
| 59 } | 55 } | 
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 } | 265 } | 
| 270 | 266 | 
| 271 return ""; | 267 return ""; | 
| 272 } | 268 } | 
| 273 | 269 | 
| 274 CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) { | 270 CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) { | 
| 275 if (nCharset == DEFAULT_CHARSET) | 271 if (nCharset == DEFAULT_CHARSET) | 
| 276 nCharset = GetNativeCharset(); | 272 nCharset = GetNativeCharset(); | 
| 277 | 273 | 
| 278 CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset); | 274 CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset); | 
| 279 if (m_pSystemHandler) { | 275 if (m_pSystemHandler) { | 
| 
 
Wei Li
2016/08/24 16:54:06
No longer need the check? Ditto other places
 
dsinclair
2016/08/24 17:47:41
Done.
 
 | |
| 280 if (m_pSystemHandler->FindNativeTrueTypeFont(sFontName)) | 276 if (m_pSystemHandler->FindNativeTrueTypeFont(sFontName)) | 
| 281 return sFontName; | 277 return sFontName; | 
| 282 | 278 | 
| 283 sFontName.clear(); | 279 sFontName.clear(); | 
| 284 } | 280 } | 
| 285 return sFontName; | 281 return sFontName; | 
| 286 } | 282 } | 
| 287 | 283 | 
| 288 CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, | 284 CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, | 
| 289 CFX_ByteString& sFontName, | 285 CFX_ByteString& sFontName, | 
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 return RUSSIAN_CHARSET; | 473 return RUSSIAN_CHARSET; | 
| 478 | 474 | 
| 479 if (word >= 0x0100 && word <= 0x024F) | 475 if (word >= 0x0100 && word <= 0x024F) | 
| 480 return EASTEUROPE_CHARSET; | 476 return EASTEUROPE_CHARSET; | 
| 481 | 477 | 
| 482 if (word >= 0x1E00 && word <= 0x1EFF) | 478 if (word >= 0x1E00 && word <= 0x1EFF) | 
| 483 return VIETNAMESE_CHARSET; | 479 return VIETNAMESE_CHARSET; | 
| 484 | 480 | 
| 485 return ANSI_CHARSET; | 481 return ANSI_CHARSET; | 
| 486 } | 482 } | 
| 487 | |
| 488 CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, | |
| 489 CPDF_Document* pAttachedDoc) | |
| 490 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} | |
| 491 | |
| 492 CPWL_DocFontMap::~CPWL_DocFontMap() {} | |
| 493 | |
| 494 CPDF_Document* CPWL_DocFontMap::GetDocument() { | |
| 495 return m_pAttachedDoc; | |
| 496 } | |
| OLD | NEW |