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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 CPDF_CMap::CPDF_CMap() { | 505 CPDF_CMap::CPDF_CMap() { |
506 m_Charset = CIDSET_UNKNOWN; | 506 m_Charset = CIDSET_UNKNOWN; |
507 m_Coding = CIDCODING_UNKNOWN; | 507 m_Coding = CIDCODING_UNKNOWN; |
508 m_CodingScheme = TwoBytes; | 508 m_CodingScheme = TwoBytes; |
509 m_bVertical = 0; | 509 m_bVertical = 0; |
510 m_bLoaded = FALSE; | 510 m_bLoaded = FALSE; |
511 m_pMapping = nullptr; | 511 m_pMapping = nullptr; |
512 m_pLeadingBytes = nullptr; | 512 m_pLeadingBytes = nullptr; |
513 m_pAddMapping = nullptr; | 513 m_pAddMapping = nullptr; |
514 m_pEmbedMap = nullptr; | 514 m_pEmbedMap = nullptr; |
515 m_pUseMap = nullptr; | |
516 m_nCodeRanges = 0; | 515 m_nCodeRanges = 0; |
517 } | 516 } |
518 CPDF_CMap::~CPDF_CMap() { | 517 CPDF_CMap::~CPDF_CMap() { |
519 FX_Free(m_pMapping); | 518 FX_Free(m_pMapping); |
520 FX_Free(m_pAddMapping); | 519 FX_Free(m_pAddMapping); |
521 FX_Free(m_pLeadingBytes); | 520 FX_Free(m_pLeadingBytes); |
522 delete m_pUseMap; | |
523 } | 521 } |
524 void CPDF_CMap::Release() { | 522 void CPDF_CMap::Release() { |
525 if (m_PredefinedCMap.IsEmpty()) { | 523 if (m_PredefinedCMap.IsEmpty()) { |
526 delete this; | 524 delete this; |
527 } | 525 } |
528 } | 526 } |
529 | 527 |
530 FX_BOOL CPDF_CMap::IsLoaded() const { | 528 FX_BOOL CPDF_CMap::IsLoaded() const { |
531 return m_bLoaded; | 529 return m_bLoaded; |
532 } | 530 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 if (m_pEmbedMap) { | 607 if (m_pEmbedMap) { |
610 return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode); | 608 return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode); |
611 } | 609 } |
612 if (!m_pMapping) { | 610 if (!m_pMapping) { |
613 return (uint16_t)charcode; | 611 return (uint16_t)charcode; |
614 } | 612 } |
615 if (charcode >> 16) { | 613 if (charcode >> 16) { |
616 if (m_pAddMapping) { | 614 if (m_pAddMapping) { |
617 void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4, | 615 void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4, |
618 *(uint32_t*)m_pAddMapping, 8, CompareCID); | 616 *(uint32_t*)m_pAddMapping, 8, CompareCID); |
619 if (!found) { | 617 if (!found) |
620 if (m_pUseMap) { | |
621 return m_pUseMap->CIDFromCharCode(charcode); | |
622 } | |
623 return 0; | 618 return 0; |
624 } | |
625 return (uint16_t)(((uint32_t*)found)[1] % 65536 + charcode - | 619 return (uint16_t)(((uint32_t*)found)[1] % 65536 + charcode - |
626 *(uint32_t*)found); | 620 *(uint32_t*)found); |
627 } | 621 } |
628 if (m_pUseMap) | |
629 return m_pUseMap->CIDFromCharCode(charcode); | |
630 return 0; | 622 return 0; |
631 } | 623 } |
632 uint32_t CID = m_pMapping[charcode]; | 624 return m_pMapping[charcode]; |
633 if (!CID && m_pUseMap) | |
634 return m_pUseMap->CIDFromCharCode(charcode); | |
635 return (uint16_t)CID; | |
636 } | 625 } |
637 | 626 |
638 uint32_t CPDF_CMap::GetNextChar(const FX_CHAR* pString, | 627 uint32_t CPDF_CMap::GetNextChar(const FX_CHAR* pString, |
639 int nStrLen, | 628 int nStrLen, |
640 int& offset) const { | 629 int& offset) const { |
641 switch (m_CodingScheme) { | 630 switch (m_CodingScheme) { |
642 case OneByte: | 631 case OneByte: |
643 return ((uint8_t*)pString)[offset++]; | 632 return ((uint8_t*)pString)[offset++]; |
644 case TwoBytes: | 633 case TwoBytes: |
645 offset += 2; | 634 offset += 2; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; | 791 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; |
803 } | 792 } |
804 | 793 |
805 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { | 794 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { |
806 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { | 795 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { |
807 if (ordering == g_CharsetNames[charset]) | 796 if (ordering == g_CharsetNames[charset]) |
808 return CIDSetFromSizeT(charset); | 797 return CIDSetFromSizeT(charset); |
809 } | 798 } |
810 return CIDSET_UNKNOWN; | 799 return CIDSET_UNKNOWN; |
811 } | 800 } |
OLD | NEW |