| 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> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 const CPDF_Type3Font* CPDF_Type3Font::AsType3Font() const { | 32 const CPDF_Type3Font* CPDF_Type3Font::AsType3Font() const { |
| 33 return this; | 33 return this; |
| 34 } | 34 } |
| 35 | 35 |
| 36 CPDF_Type3Font* CPDF_Type3Font::AsType3Font() { | 36 CPDF_Type3Font* CPDF_Type3Font::AsType3Font() { |
| 37 return this; | 37 return this; |
| 38 } | 38 } |
| 39 | 39 |
| 40 FX_BOOL CPDF_Type3Font::Load() { | 40 bool CPDF_Type3Font::Load() { |
| 41 m_pFontResources = m_pFontDict->GetDictFor("Resources"); | 41 m_pFontResources = m_pFontDict->GetDictFor("Resources"); |
| 42 CPDF_Array* pMatrix = m_pFontDict->GetArrayFor("FontMatrix"); | 42 CPDF_Array* pMatrix = m_pFontDict->GetArrayFor("FontMatrix"); |
| 43 FX_FLOAT xscale = 1.0f, yscale = 1.0f; | 43 FX_FLOAT xscale = 1.0f, yscale = 1.0f; |
| 44 if (pMatrix) { | 44 if (pMatrix) { |
| 45 m_FontMatrix = pMatrix->GetMatrix(); | 45 m_FontMatrix = pMatrix->GetMatrix(); |
| 46 xscale = m_FontMatrix.a; | 46 xscale = m_FontMatrix.a; |
| 47 yscale = m_FontMatrix.d; | 47 yscale = m_FontMatrix.d; |
| 48 } | 48 } |
| 49 CPDF_Array* pBBox = m_pFontDict->GetArrayFor("FontBBox"); | 49 CPDF_Array* pBBox = m_pFontDict->GetArrayFor("FontBBox"); |
| 50 if (pBBox) { | 50 if (pBBox) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 62 if (StartChar + count > 256) | 62 if (StartChar + count > 256) |
| 63 count = 256 - StartChar; | 63 count = 256 - StartChar; |
| 64 for (size_t i = 0; i < count; i++) { | 64 for (size_t i = 0; i < count; i++) { |
| 65 m_CharWidthL[StartChar + i] = | 65 m_CharWidthL[StartChar + i] = |
| 66 FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000); | 66 FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 m_pCharProcs = m_pFontDict->GetDictFor("CharProcs"); | 69 m_pCharProcs = m_pFontDict->GetDictFor("CharProcs"); |
| 70 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); | 70 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); |
| 71 if (pEncoding) { | 71 if (pEncoding) { |
| 72 LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, FALSE, FALSE); | 72 LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, false, false); |
| 73 if (!m_CharNames.empty()) { | 73 if (!m_CharNames.empty()) { |
| 74 for (int i = 0; i < 256; i++) { | 74 for (int i = 0; i < 256; i++) { |
| 75 m_Encoding.m_Unicodes[i] = | 75 m_Encoding.m_Unicodes[i] = |
| 76 PDF_UnicodeFromAdobeName(m_CharNames[i].c_str()); | 76 PDF_UnicodeFromAdobeName(m_CharNames[i].c_str()); |
| 77 if (m_Encoding.m_Unicodes[i] == 0) { | 77 if (m_Encoding.m_Unicodes[i] == 0) { |
| 78 m_Encoding.m_Unicodes[i] = i; | 78 m_Encoding.m_Unicodes[i] = i; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 return TRUE; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void CPDF_Type3Font::CheckType3FontMetrics() { | 86 void CPDF_Type3Font::CheckType3FontMetrics() { |
| 87 CheckFontMetrics(); | 87 CheckFontMetrics(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) { | 90 CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) { |
| 91 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) | 91 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) |
| 92 return nullptr; | 92 return nullptr; |
| 93 | 93 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return m_CharWidthL[charcode]; | 147 return m_CharWidthL[charcode]; |
| 148 | 148 |
| 149 const CPDF_Type3Char* pChar = LoadChar(charcode, level); | 149 const CPDF_Type3Char* pChar = LoadChar(charcode, level); |
| 150 return pChar ? pChar->m_Width : 0; | 150 return pChar ? pChar->m_Width : 0; |
| 151 } | 151 } |
| 152 | 152 |
| 153 FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) { | 153 FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) { |
| 154 const CPDF_Type3Char* pChar = LoadChar(charcode, level); | 154 const CPDF_Type3Char* pChar = LoadChar(charcode, level); |
| 155 return pChar ? pChar->m_BBox : FX_RECT(); | 155 return pChar ? pChar->m_BBox : FX_RECT(); |
| 156 } | 156 } |
| OLD | NEW |