| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/include/cpdf_fontencoding.h" | 7 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| (...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 for (int i = 0; i < 256; i++) | 1663 for (int i = 0; i < 256; i++) |
| 1664 m_Unicodes[i] = pSrc[i]; | 1664 m_Unicodes[i] = pSrc[i]; |
| 1665 } | 1665 } |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 FX_BOOL CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const { | 1668 FX_BOOL CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const { |
| 1669 return FXSYS_memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) == | 1669 return FXSYS_memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) == |
| 1670 0; | 1670 0; |
| 1671 } | 1671 } |
| 1672 | 1672 |
| 1673 CPDF_Object* CPDF_FontEncoding::Realize() { | 1673 CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool) { |
| 1674 int predefined = 0; | 1674 int predefined = 0; |
| 1675 for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS; | 1675 for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS; |
| 1676 cs++) { | 1676 cs++) { |
| 1677 const uint16_t* pSrc = PDF_UnicodesForPredefinedCharSet(cs); | 1677 const uint16_t* pSrc = PDF_UnicodesForPredefinedCharSet(cs); |
| 1678 FX_BOOL match = TRUE; | 1678 FX_BOOL match = TRUE; |
| 1679 for (int i = 0; i < 256; ++i) { | 1679 for (int i = 0; i < 256; ++i) { |
| 1680 if (m_Unicodes[i] != pSrc[i]) { | 1680 if (m_Unicodes[i] != pSrc[i]) { |
| 1681 match = FALSE; | 1681 match = FALSE; |
| 1682 break; | 1682 break; |
| 1683 } | 1683 } |
| 1684 } | 1684 } |
| 1685 if (match) { | 1685 if (match) { |
| 1686 predefined = cs; | 1686 predefined = cs; |
| 1687 break; | 1687 break; |
| 1688 } | 1688 } |
| 1689 } | 1689 } |
| 1690 if (predefined) { | 1690 if (predefined) { |
| 1691 if (predefined == PDFFONT_ENCODING_WINANSI) { | 1691 if (predefined == PDFFONT_ENCODING_WINANSI) { |
| 1692 return new CPDF_Name("WinAnsiEncoding"); | 1692 return new CPDF_Name(pPool->Intern("WinAnsiEncoding")); |
| 1693 } | 1693 } |
| 1694 if (predefined == PDFFONT_ENCODING_MACROMAN) { | 1694 if (predefined == PDFFONT_ENCODING_MACROMAN) { |
| 1695 return new CPDF_Name("MacRomanEncoding"); | 1695 return new CPDF_Name(pPool->Intern("MacRomanEncoding")); |
| 1696 } | 1696 } |
| 1697 if (predefined == PDFFONT_ENCODING_MACEXPERT) { | 1697 if (predefined == PDFFONT_ENCODING_MACEXPERT) { |
| 1698 return new CPDF_Name("MacExpertEncoding"); | 1698 return new CPDF_Name(pPool->Intern("MacExpertEncoding")); |
| 1699 } | 1699 } |
| 1700 return nullptr; | 1700 return nullptr; |
| 1701 } | 1701 } |
| 1702 const uint16_t* pStandard = | 1702 const uint16_t* pStandard = |
| 1703 PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI); | 1703 PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI); |
| 1704 CPDF_Array* pDiff = new CPDF_Array; | 1704 CPDF_Array* pDiff = new CPDF_Array; |
| 1705 for (int i = 0; i < 256; i++) { | 1705 for (int i = 0; i < 256; i++) { |
| 1706 if (pStandard[i] == m_Unicodes[i]) { | 1706 if (pStandard[i] == m_Unicodes[i]) { |
| 1707 continue; | 1707 continue; |
| 1708 } | 1708 } |
| 1709 pDiff->Add(new CPDF_Number(i)); | 1709 pDiff->Add(new CPDF_Number(i)); |
| 1710 pDiff->Add(new CPDF_Name(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); | 1710 pDiff->Add(new CPDF_Name(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 CPDF_Dictionary* pDict = new CPDF_Dictionary; | 1713 CPDF_Dictionary* pDict = new CPDF_Dictionary(pPool); |
| 1714 pDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); | 1714 pDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); |
| 1715 pDict->SetFor("Differences", pDiff); | 1715 pDict->SetFor("Differences", pDiff); |
| 1716 return pDict; | 1716 return pDict; |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 uint32_t FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode) { | 1719 uint32_t FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode) { |
| 1720 switch (encoding) { | 1720 switch (encoding) { |
| 1721 case FXFT_ENCODING_UNICODE: | 1721 case FXFT_ENCODING_UNICODE: |
| 1722 return unicode; | 1722 return unicode; |
| 1723 case FXFT_ENCODING_ADOBE_STANDARD: | 1723 case FXFT_ENCODING_ADOBE_STANDARD: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 return MacExpertEncoding[(uint8_t)charcode]; | 1809 return MacExpertEncoding[(uint8_t)charcode]; |
| 1810 case FXFT_ENCODING_ADOBE_LATIN_1: | 1810 case FXFT_ENCODING_ADOBE_LATIN_1: |
| 1811 return AdobeWinAnsiEncoding[(uint8_t)charcode]; | 1811 return AdobeWinAnsiEncoding[(uint8_t)charcode]; |
| 1812 case FXFT_ENCODING_APPLE_ROMAN: | 1812 case FXFT_ENCODING_APPLE_ROMAN: |
| 1813 return MacRomanEncoding[(uint8_t)charcode]; | 1813 return MacRomanEncoding[(uint8_t)charcode]; |
| 1814 case PDFFONT_ENCODING_PDFDOC: | 1814 case PDFFONT_ENCODING_PDFDOC: |
| 1815 return PDFDocEncoding[(uint8_t)charcode]; | 1815 return PDFDocEncoding[(uint8_t)charcode]; |
| 1816 } | 1816 } |
| 1817 return 0; | 1817 return 0; |
| 1818 } | 1818 } |
| OLD | NEW |