| 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/cpdf_type3font.h" | 7 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" |
| 8 | 8 |
| 9 #include <utility> |
| 10 |
| 9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" | 11 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" |
| 10 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" | 12 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
| 11 #include "core/fpdfapi/fpdf_page/pageint.h" | 13 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| 14 #include "core/fxcrt/include/fx_system.h" | 16 #include "core/fxcrt/include/fx_system.h" |
| 15 #include "third_party/base/stl_util.h" | 17 #include "third_party/base/stl_util.h" |
| 16 | 18 |
| 17 CPDF_Type3Font::CPDF_Type3Font() | 19 CPDF_Type3Font::CPDF_Type3Font() |
| 18 : m_pCharProcs(nullptr), | 20 : m_pCharProcs(nullptr), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 if (StartChar + count > 256) | 62 if (StartChar + count > 256) |
| 61 count = 256 - StartChar; | 63 count = 256 - StartChar; |
| 62 for (size_t i = 0; i < count; i++) { | 64 for (size_t i = 0; i < count; i++) { |
| 63 m_CharWidthL[StartChar + i] = | 65 m_CharWidthL[StartChar + i] = |
| 64 FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000); | 66 FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000); |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 m_pCharProcs = m_pFontDict->GetDictBy("CharProcs"); | 69 m_pCharProcs = m_pFontDict->GetDictBy("CharProcs"); |
| 68 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); | 70 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); |
| 69 if (pEncoding) { | 71 if (pEncoding) { |
| 70 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE); | 72 LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, FALSE, FALSE); |
| 71 if (m_pCharNames) { | 73 if (!m_CharNames.empty()) { |
| 72 for (int i = 0; i < 256; i++) { | 74 for (int i = 0; i < 256; i++) { |
| 73 m_Encoding.m_Unicodes[i] = | 75 m_Encoding.m_Unicodes[i] = |
| 74 PDF_UnicodeFromAdobeName(m_pCharNames[i].c_str()); | 76 PDF_UnicodeFromAdobeName(m_CharNames[i].c_str()); |
| 75 if (m_Encoding.m_Unicodes[i] == 0) { | 77 if (m_Encoding.m_Unicodes[i] == 0) { |
| 76 m_Encoding.m_Unicodes[i] = i; | 78 m_Encoding.m_Unicodes[i] = i; |
| 77 } | 79 } |
| 78 } | 80 } |
| 79 } | 81 } |
| 80 } | 82 } |
| 81 return TRUE; | 83 return TRUE; |
| 82 } | 84 } |
| 83 | 85 |
| 84 void CPDF_Type3Font::CheckType3FontMetrics() { | 86 void CPDF_Type3Font::CheckType3FontMetrics() { |
| 85 CheckFontMetrics(); | 87 CheckFontMetrics(); |
| 86 } | 88 } |
| 87 | 89 |
| 88 CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) { | 90 CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) { |
| 89 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) | 91 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) |
| 90 return nullptr; | 92 return nullptr; |
| 91 | 93 |
| 92 auto it = m_CacheMap.find(charcode); | 94 auto it = m_CacheMap.find(charcode); |
| 93 if (it != m_CacheMap.end()) | 95 if (it != m_CacheMap.end()) |
| 94 return it->second.get(); | 96 return it->second.get(); |
| 95 | 97 |
| 96 const FX_CHAR* name = | 98 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode); |
| 97 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | |
| 98 if (!name) | 99 if (!name) |
| 99 return nullptr; | 100 return nullptr; |
| 100 | 101 |
| 101 CPDF_Stream* pStream = | 102 CPDF_Stream* pStream = |
| 102 ToStream(m_pCharProcs ? m_pCharProcs->GetDirectObjectBy(name) : nullptr); | 103 ToStream(m_pCharProcs ? m_pCharProcs->GetDirectObjectBy(name) : nullptr); |
| 103 if (!pStream) | 104 if (!pStream) |
| 104 return nullptr; | 105 return nullptr; |
| 105 | 106 |
| 106 std::unique_ptr<CPDF_Type3Char> pNewChar(new CPDF_Type3Char(new CPDF_Form( | 107 std::unique_ptr<CPDF_Type3Char> pNewChar(new CPDF_Type3Char(new CPDF_Form( |
| 107 m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources, | 108 m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return m_CharWidthL[charcode]; | 147 return m_CharWidthL[charcode]; |
| 147 | 148 |
| 148 const CPDF_Type3Char* pChar = LoadChar(charcode, level); | 149 const CPDF_Type3Char* pChar = LoadChar(charcode, level); |
| 149 return pChar ? pChar->m_Width : 0; | 150 return pChar ? pChar->m_Width : 0; |
| 150 } | 151 } |
| 151 | 152 |
| 152 FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) { | 153 FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) { |
| 153 const CPDF_Type3Char* pChar = LoadChar(charcode, level); | 154 const CPDF_Type3Char* pChar = LoadChar(charcode, level); |
| 154 return pChar ? pChar->m_BBox : FX_RECT(); | 155 return pChar ? pChar->m_BBox : FX_RECT(); |
| 155 } | 156 } |
| OLD | NEW |