| 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/include/pdfwindow/PDFWindow.h" | |
| 8 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" |
| 8 |
| 9 #include "core/include/fpdfapi/fpdf_module.h" |
| 9 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
| 10 | 11 |
| 11 #define DEFAULT_FONT_NAME "Helvetica" | 12 #define DEFAULT_FONT_NAME "Helvetica" |
| 12 | 13 |
| 13 /* ------------------------------ CPWL_FontMap ------------------------------ */ | |
| 14 | |
| 15 CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) | 14 CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) |
| 16 : m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) { | 15 : m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) { |
| 17 ASSERT(m_pSystemHandler); | 16 ASSERT(m_pSystemHandler); |
| 18 } | 17 } |
| 19 | 18 |
| 20 CPWL_FontMap::~CPWL_FontMap() { | 19 CPWL_FontMap::~CPWL_FontMap() { |
| 21 delete m_pPDFDoc; | 20 delete m_pPDFDoc; |
| 22 m_pPDFDoc = NULL; | 21 m_pPDFDoc = NULL; |
| 23 | 22 |
| 24 Empty(); | 23 Empty(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 break; | 231 break; |
| 233 } | 232 } |
| 234 } | 233 } |
| 235 } | 234 } |
| 236 | 235 |
| 237 CPDF_Font* pNewFont = GetPDFFont(nFind); | 236 CPDF_Font* pNewFont = GetPDFFont(nFind); |
| 238 | 237 |
| 239 if (!pNewFont) | 238 if (!pNewFont) |
| 240 return -1; | 239 return -1; |
| 241 | 240 |
| 242 /* | |
| 243 if (CPDF_Font* pFont = GetPDFFont(nFind)) | |
| 244 { | |
| 245 PWLFont.AddWordToFontDict(pFontDict, word); | |
| 246 } | |
| 247 */ | |
| 248 | |
| 249 CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset); | 241 CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset); |
| 250 AddedFont(pNewFont, sAlias); | 242 AddedFont(pNewFont, sAlias); |
| 251 | 243 |
| 252 return AddFontData(pNewFont, sAlias, nCharset); | 244 return AddFontData(pNewFont, sAlias, nCharset); |
| 253 } | 245 } |
| 254 | 246 |
| 255 CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, | 247 CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, |
| 256 int32_t nCharset) { | 248 int32_t nCharset) { |
| 257 return NULL; | 249 return NULL; |
| 258 } | 250 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return AddSystemFont(pDoc, sFontName, nCharset); | 298 return AddSystemFont(pDoc, sFontName, nCharset); |
| 307 } | 299 } |
| 308 | 300 |
| 309 CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc, | 301 CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc, |
| 310 CFX_ByteString& sFontName) { | 302 CFX_ByteString& sFontName) { |
| 311 if (!pDoc) | 303 if (!pDoc) |
| 312 return NULL; | 304 return NULL; |
| 313 | 305 |
| 314 CPDF_Font* pFont = NULL; | 306 CPDF_Font* pFont = NULL; |
| 315 | 307 |
| 316 if (sFontName == "ZapfDingbats") | 308 if (sFontName == "ZapfDingbats") { |
| 317 pFont = pDoc->AddStandardFont(sFontName, NULL); | 309 pFont = pDoc->AddStandardFont(sFontName, NULL); |
| 318 else { | 310 } else { |
| 319 CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI); | 311 CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI); |
| 320 pFont = pDoc->AddStandardFont(sFontName, &fe); | 312 pFont = pDoc->AddStandardFont(sFontName, &fe); |
| 321 } | 313 } |
| 322 | 314 |
| 323 return pFont; | 315 return pFont; |
| 324 } | 316 } |
| 325 | 317 |
| 326 CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, | 318 CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, |
| 327 CFX_ByteString& sFontName, | 319 CFX_ByteString& sFontName, |
| 328 uint8_t nCharset) { | 320 uint8_t nCharset) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 484 |
| 493 if (word >= 0x0100 && word <= 0x024F) | 485 if (word >= 0x0100 && word <= 0x024F) |
| 494 return EASTEUROPE_CHARSET; | 486 return EASTEUROPE_CHARSET; |
| 495 | 487 |
| 496 if (word >= 0x1E00 && word <= 0x1EFF) | 488 if (word >= 0x1E00 && word <= 0x1EFF) |
| 497 return VIETNAMESE_CHARSET; | 489 return VIETNAMESE_CHARSET; |
| 498 | 490 |
| 499 return ANSI_CHARSET; | 491 return ANSI_CHARSET; |
| 500 } | 492 } |
| 501 | 493 |
| 502 /* ------------------------ CPWL_DocFontMap ------------------------ */ | |
| 503 | |
| 504 CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, | 494 CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, |
| 505 CPDF_Document* pAttachedDoc) | 495 CPDF_Document* pAttachedDoc) |
| 506 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} | 496 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} |
| 507 | 497 |
| 508 CPWL_DocFontMap::~CPWL_DocFontMap() {} | 498 CPWL_DocFontMap::~CPWL_DocFontMap() {} |
| 509 | 499 |
| 510 CPDF_Document* CPWL_DocFontMap::GetDocument() { | 500 CPDF_Document* CPWL_DocFontMap::GetDocument() { |
| 511 return m_pAttachedDoc; | 501 return m_pAttachedDoc; |
| 512 } | 502 } |
| OLD | NEW |