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 "core/fpdfapi/fpdf_font/font_int.h" | 7 #include "core/fpdfapi/fpdf_font/font_int.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" | 9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" |
10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" | 10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 } | 398 } |
399 m_CodeSeq = 0; | 399 m_CodeSeq = 0; |
400 } else if (m_Status == 3) { | 400 } else if (m_Status == 3) { |
401 m_Status = 0; | 401 m_Status = 0; |
402 } else if (m_Status == 4) { | 402 } else if (m_Status == 4) { |
403 m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word)); | 403 m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word)); |
404 m_Status = 0; | 404 m_Status = 0; |
405 } else if (m_Status == 5) { | 405 } else if (m_Status == 5) { |
406 m_Status = 0; | 406 m_Status = 0; |
407 } else if (m_Status == 6) { | 407 } else if (m_Status == 6) { |
408 m_pCMap->m_bVertical = CMap_GetCode(word); | 408 m_pCMap->m_bVertical = CMap_GetCode(word) != 0; |
409 m_Status = 0; | 409 m_Status = 0; |
410 } else if (m_Status == 7) { | 410 } else if (m_Status == 7) { |
411 if (word == "endcodespacerange") { | 411 if (word == "endcodespacerange") { |
412 int nSegs = m_CodeRanges.GetSize(); | 412 int nSegs = m_CodeRanges.GetSize(); |
413 if (nSegs > 1) { | 413 if (nSegs > 1) { |
414 m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes; | 414 m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes; |
415 m_pCMap->m_nCodeRanges = nSegs; | 415 m_pCMap->m_nCodeRanges = nSegs; |
416 m_pCMap->m_pLeadingBytes = | 416 m_pCMap->m_pLeadingBytes = |
417 FX_Alloc2D(uint8_t, nSegs, sizeof(CMap_CodeRange)); | 417 FX_Alloc2D(uint8_t, nSegs, sizeof(CMap_CodeRange)); |
418 FXSYS_memcpy(m_pCMap->m_pLeadingBytes, m_CodeRanges.GetData(), | 418 FXSYS_memcpy(m_pCMap->m_pLeadingBytes, m_CodeRanges.GetData(), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 : '0'; | 492 : '0'; |
493 range.m_Upper[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); | 493 range.m_Upper[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); |
494 } | 494 } |
495 return true; | 495 return true; |
496 } | 496 } |
497 | 497 |
498 CPDF_CMap::CPDF_CMap() { | 498 CPDF_CMap::CPDF_CMap() { |
499 m_Charset = CIDSET_UNKNOWN; | 499 m_Charset = CIDSET_UNKNOWN; |
500 m_Coding = CIDCODING_UNKNOWN; | 500 m_Coding = CIDCODING_UNKNOWN; |
501 m_CodingScheme = TwoBytes; | 501 m_CodingScheme = TwoBytes; |
502 m_bVertical = 0; | 502 m_bVertical = false; |
503 m_bLoaded = FALSE; | 503 m_bLoaded = FALSE; |
Lei Zhang
2016/09/23 23:52:39
Saving this for later?
| |
504 m_pMapping = nullptr; | 504 m_pMapping = nullptr; |
505 m_pLeadingBytes = nullptr; | 505 m_pLeadingBytes = nullptr; |
506 m_pAddMapping = nullptr; | 506 m_pAddMapping = nullptr; |
507 m_pEmbedMap = nullptr; | 507 m_pEmbedMap = nullptr; |
508 m_nCodeRanges = 0; | 508 m_nCodeRanges = 0; |
509 } | 509 } |
510 CPDF_CMap::~CPDF_CMap() { | 510 CPDF_CMap::~CPDF_CMap() { |
511 FX_Free(m_pMapping); | 511 FX_Free(m_pMapping); |
512 FX_Free(m_pAddMapping); | 512 FX_Free(m_pAddMapping); |
513 FX_Free(m_pLeadingBytes); | 513 FX_Free(m_pLeadingBytes); |
514 } | 514 } |
515 | 515 |
516 FX_BOOL CPDF_CMap::IsLoaded() const { | 516 FX_BOOL CPDF_CMap::IsLoaded() const { |
517 return m_bLoaded; | 517 return m_bLoaded; |
518 } | 518 } |
519 | 519 |
520 FX_BOOL CPDF_CMap::IsVertWriting() const { | 520 bool CPDF_CMap::IsVertWriting() const { |
521 return m_bVertical; | 521 return m_bVertical; |
522 } | 522 } |
523 | 523 |
524 FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, | 524 FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, |
525 const CFX_ByteString& bsName, | 525 const CFX_ByteString& bsName, |
526 FX_BOOL bPromptCJK) { | 526 FX_BOOL bPromptCJK) { |
527 m_PredefinedCMap = bsName; | 527 m_PredefinedCMap = bsName; |
528 if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") { | 528 if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") { |
529 m_Coding = CIDCODING_CID; | 529 m_Coding = CIDCODING_CID; |
530 m_bVertical = bsName[9] == 'V'; | 530 m_bVertical = bsName[9] == 'V'; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; | 780 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; |
781 } | 781 } |
782 | 782 |
783 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { | 783 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { |
784 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { | 784 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { |
785 if (ordering == g_CharsetNames[charset]) | 785 if (ordering == g_CharsetNames[charset]) |
786 return CIDSetFromSizeT(charset); | 786 return CIDSetFromSizeT(charset); |
787 } | 787 } |
788 return CIDSET_UNKNOWN; | 788 return CIDSET_UNKNOWN; |
789 } | 789 } |
OLD | NEW |