| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 274 |
| 275 return ""; | 275 return ""; |
| 276 } | 276 } |
| 277 | 277 |
| 278 CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) { | 278 CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) { |
| 279 if (nCharset == DEFAULT_CHARSET) | 279 if (nCharset == DEFAULT_CHARSET) |
| 280 nCharset = GetNativeCharset(); | 280 nCharset = GetNativeCharset(); |
| 281 | 281 |
| 282 CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset); | 282 CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset); |
| 283 if (m_pSystemHandler) { | 283 if (m_pSystemHandler) { |
| 284 if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName)) | 284 if (m_pSystemHandler->FindNativeTrueTypeFont(sFontName)) |
| 285 return sFontName; | 285 return sFontName; |
| 286 | 286 |
| 287 sFontName = ""; | 287 sFontName.clear(); |
| 288 } | 288 } |
| 289 return sFontName; | 289 return sFontName; |
| 290 } | 290 } |
| 291 | 291 |
| 292 CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, | 292 CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, |
| 293 CFX_ByteString& sFontName, | 293 CFX_ByteString& sFontName, |
| 294 uint8_t nCharset) { | 294 uint8_t nCharset) { |
| 295 if (IsStandardFont(sFontName)) | 295 if (IsStandardFont(sFontName)) |
| 296 return AddStandardFont(pDoc, sFontName); | 296 return AddStandardFont(pDoc, sFontName); |
| 297 | 297 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 int i = 0; | 430 int i = 0; |
| 431 while (defaultTTFMap[i].charset != -1) { | 431 while (defaultTTFMap[i].charset != -1) { |
| 432 if (nCharset == defaultTTFMap[i].charset) | 432 if (nCharset == defaultTTFMap[i].charset) |
| 433 return defaultTTFMap[i].fontname; | 433 return defaultTTFMap[i].fontname; |
| 434 ++i; | 434 ++i; |
| 435 } | 435 } |
| 436 return ""; | 436 return ""; |
| 437 } | 437 } |
| 438 | 438 |
| 439 int32_t CPWL_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { | 439 int32_t CPWL_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { |
| 440 if (m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet())) | |
| 441 return m_pSystemHandler->GetCharSet(); | |
| 442 // to avoid CJK Font to show ASCII | 440 // to avoid CJK Font to show ASCII |
| 443 if (word < 0x7F) | 441 if (word < 0x7F) |
| 444 return ANSI_CHARSET; | 442 return ANSI_CHARSET; |
| 445 // follow the old charset | 443 // follow the old charset |
| 446 if (nOldCharset != DEFAULT_CHARSET) | 444 if (nOldCharset != DEFAULT_CHARSET) |
| 447 return nOldCharset; | 445 return nOldCharset; |
| 448 | 446 |
| 449 // find new charset | 447 // find new charset |
| 450 if ((word >= 0x4E00 && word <= 0x9FA5) || | 448 if ((word >= 0x4E00 && word <= 0x9FA5) || |
| 451 (word >= 0xE7C7 && word <= 0xE7F3) || | 449 (word >= 0xE7C7 && word <= 0xE7F3) || |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 491 |
| 494 CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, | 492 CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, |
| 495 CPDF_Document* pAttachedDoc) | 493 CPDF_Document* pAttachedDoc) |
| 496 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} | 494 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} |
| 497 | 495 |
| 498 CPWL_DocFontMap::~CPWL_DocFontMap() {} | 496 CPWL_DocFontMap::~CPWL_DocFontMap() {} |
| 499 | 497 |
| 500 CPDF_Document* CPWL_DocFontMap::GetDocument() { | 498 CPDF_Document* CPWL_DocFontMap::GetDocument() { |
| 501 return m_pAttachedDoc; | 499 return m_pAttachedDoc; |
| 502 } | 500 } |
| OLD | NEW |