| 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_simplefont.h" | 7 #include "core/fpdfapi/fpdf_font/cpdf_simplefont.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_font/font_int.h" | 9 #include "core/fpdfapi/fpdf_font/font_int.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 return FX_RECT(m_CharBBox[charcode]); | 105 return FX_RECT(m_CharBBox[charcode]); |
| 106 } | 106 } |
| 107 | 107 |
| 108 FX_BOOL CPDF_SimpleFont::LoadCommon() { | 108 FX_BOOL CPDF_SimpleFont::LoadCommon() { |
| 109 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor"); | 109 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor"); |
| 110 if (pFontDesc) { | 110 if (pFontDesc) { |
| 111 LoadFontDescriptor(pFontDesc); | 111 LoadFontDescriptor(pFontDesc); |
| 112 } | 112 } |
| 113 CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); | 113 CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); |
| 114 int width_start = 0, width_end = -1; | |
| 115 m_bUseFontWidth = TRUE; | 114 m_bUseFontWidth = TRUE; |
| 116 if (pWidthArray) { | 115 if (pWidthArray) { |
| 117 m_bUseFontWidth = FALSE; | 116 m_bUseFontWidth = FALSE; |
| 118 if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) { | 117 if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) { |
| 119 int MissingWidth = pFontDesc->GetIntegerBy("MissingWidth"); | 118 int MissingWidth = pFontDesc->GetIntegerBy("MissingWidth"); |
| 120 for (int i = 0; i < 256; i++) { | 119 for (int i = 0; i < 256; i++) { |
| 121 m_CharWidth[i] = MissingWidth; | 120 m_CharWidth[i] = MissingWidth; |
| 122 } | 121 } |
| 123 } | 122 } |
| 124 width_start = m_pFontDict->GetIntegerBy("FirstChar", 0); | 123 size_t width_start = m_pFontDict->GetIntegerBy("FirstChar", 0); |
| 125 width_end = m_pFontDict->GetIntegerBy("LastChar", 0); | 124 size_t width_end = m_pFontDict->GetIntegerBy("LastChar", 0); |
| 126 if (width_start >= 0 && width_start <= 255) { | 125 if (width_start <= 255) { |
| 127 if (width_end <= 0 || | 126 if (width_end == 0 || width_end >= width_start + pWidthArray->GetCount()) |
| 128 width_end >= width_start + (int)pWidthArray->GetCount()) { | |
| 129 width_end = width_start + pWidthArray->GetCount() - 1; | 127 width_end = width_start + pWidthArray->GetCount() - 1; |
| 130 } | 128 if (width_end > 255) |
| 131 if (width_end > 255) { | |
| 132 width_end = 255; | 129 width_end = 255; |
| 133 } | 130 for (size_t i = width_start; i <= width_end; i++) |
| 134 for (int i = width_start; i <= width_end; i++) { | |
| 135 m_CharWidth[i] = pWidthArray->GetIntegerAt(i - width_start); | 131 m_CharWidth[i] = pWidthArray->GetIntegerAt(i - width_start); |
| 136 } | |
| 137 } | 132 } |
| 138 } | 133 } |
| 139 if (m_pFontFile) { | 134 if (m_pFontFile) { |
| 140 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { | 135 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { |
| 141 m_BaseFont = m_BaseFont.Mid(8); | 136 m_BaseFont = m_BaseFont.Mid(8); |
| 142 } | 137 } |
| 143 } else { | 138 } else { |
| 144 LoadSubstFont(); | 139 LoadSubstFont(); |
| 145 } | 140 } |
| 146 if (!(m_Flags & PDFFONT_SYMBOLIC)) { | 141 if (!(m_Flags & PDFFONT_SYMBOLIC)) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return CFX_WideString(); | 208 return CFX_WideString(); |
| 214 return ret; | 209 return ret; |
| 215 } | 210 } |
| 216 | 211 |
| 217 uint32_t CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const { | 212 uint32_t CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const { |
| 218 uint32_t ret = CPDF_Font::CharCodeFromUnicode(unicode); | 213 uint32_t ret = CPDF_Font::CharCodeFromUnicode(unicode); |
| 219 if (ret) | 214 if (ret) |
| 220 return ret; | 215 return ret; |
| 221 return m_Encoding.CharCodeFromUnicode(unicode); | 216 return m_Encoding.CharCodeFromUnicode(unicode); |
| 222 } | 217 } |
| OLD | NEW |