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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { | 135 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { |
136 m_BaseFont = m_BaseFont.Mid(8); | 136 m_BaseFont = m_BaseFont.Mid(8); |
137 } | 137 } |
138 } else { | 138 } else { |
139 LoadSubstFont(); | 139 LoadSubstFont(); |
140 } | 140 } |
141 if (!(m_Flags & PDFFONT_SYMBOLIC)) { | 141 if (!(m_Flags & PDFFONT_SYMBOLIC)) { |
142 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; | 142 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; |
143 } | 143 } |
144 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); | 144 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); |
145 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL, | 145 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, !!m_pFontFile, |
146 m_Font.IsTTFont()); | 146 m_Font.IsTTFont()); |
147 LoadGlyphMap(); | 147 LoadGlyphMap(); |
148 delete[] m_pCharNames; | 148 delete[] m_pCharNames; |
149 m_pCharNames = NULL; | 149 m_pCharNames = nullptr; |
150 if (!m_Font.GetFace()) | 150 if (!m_Font.GetFace()) |
151 return TRUE; | 151 return TRUE; |
152 | 152 |
153 if (m_Flags & PDFFONT_ALLCAP) { | 153 if (m_Flags & PDFFONT_ALLCAP) { |
154 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; | 154 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; |
155 for (size_t range = 0; range < sizeof lowercases / 2; range++) { | 155 for (size_t range = 0; range < sizeof lowercases / 2; range++) { |
156 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1]; i++) { | 156 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1]; i++) { |
157 if (m_GlyphIndex[i] != 0xffff && m_pFontFile) { | 157 if (m_GlyphIndex[i] != 0xffff && m_pFontFile) { |
158 continue; | 158 continue; |
159 } | 159 } |
(...skipping 22 matching lines...) Expand all Loading... |
182 break; | 182 break; |
183 } | 183 } |
184 } | 184 } |
185 if (i == 256 && width) { | 185 if (i == 256 && width) { |
186 m_Flags |= PDFFONT_FIXEDPITCH; | 186 m_Flags |= PDFFONT_FIXEDPITCH; |
187 } | 187 } |
188 } | 188 } |
189 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); | 189 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); |
190 m_Font.LoadSubst(m_BaseFont, IsTrueTypeFont(), m_Flags, weight, m_ItalicAngle, | 190 m_Font.LoadSubst(m_BaseFont, IsTrueTypeFont(), m_Flags, weight, m_ItalicAngle, |
191 0); | 191 0); |
192 if (m_Font.GetSubstFont()->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { | |
193 } | |
194 } | 192 } |
195 | 193 |
196 FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { | 194 FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { |
197 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && | 195 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && |
198 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && | 196 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && |
199 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; | 197 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; |
200 } | 198 } |
201 | 199 |
202 CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const { | 200 CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const { |
203 CFX_WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode); | 201 CFX_WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode); |
204 if (!unicode.IsEmpty()) | 202 if (!unicode.IsEmpty()) |
205 return unicode; | 203 return unicode; |
206 FX_WCHAR ret = m_Encoding.UnicodeFromCharCode((uint8_t)charcode); | 204 FX_WCHAR ret = m_Encoding.UnicodeFromCharCode((uint8_t)charcode); |
207 if (ret == 0) | 205 if (ret == 0) |
208 return CFX_WideString(); | 206 return CFX_WideString(); |
209 return ret; | 207 return ret; |
210 } | 208 } |
211 | 209 |
212 uint32_t CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const { | 210 uint32_t CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const { |
213 uint32_t ret = CPDF_Font::CharCodeFromUnicode(unicode); | 211 uint32_t ret = CPDF_Font::CharCodeFromUnicode(unicode); |
214 if (ret) | 212 if (ret) |
215 return ret; | 213 return ret; |
216 return m_Encoding.CharCodeFromUnicode(unicode); | 214 return m_Encoding.CharCodeFromUnicode(unicode); |
217 } | 215 } |
OLD | NEW |