OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "font_int.h" | 7 #include "font_int.h" |
8 | 8 |
9 #include "core/src/fpdfapi/fpdf_page/pageint.h" | 9 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
10 #include "core/include/fpdfapi/fpdf_module.h" | 10 #include "core/include/fpdfapi/fpdf_module.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 int dest_pos = 0; | 187 int dest_pos = 0; |
188 for (int src_pos = 0; src_pos < src_len; src_pos++) { | 188 for (int src_pos = 0; src_pos < src_len; src_pos++) { |
189 FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); | 189 FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); |
190 dest_pos += AppendChar(dest_buf + dest_pos, charcode); | 190 dest_pos += AppendChar(dest_buf + dest_pos, charcode); |
191 } | 191 } |
192 result.ReleaseBuffer(dest_pos); | 192 result.ReleaseBuffer(dest_pos); |
193 return result; | 193 return result; |
194 } | 194 } |
195 | 195 |
196 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { | 196 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { |
197 m_Flags = pFontDesc->GetInteger("Flags", PDFFONT_NONSYMBOLIC); | 197 m_Flags = pFontDesc->GetIntegerBy("Flags", PDFFONT_NONSYMBOLIC); |
198 int ItalicAngle = 0; | 198 int ItalicAngle = 0; |
199 FX_BOOL bExistItalicAngle = FALSE; | 199 FX_BOOL bExistItalicAngle = FALSE; |
200 if (pFontDesc->KeyExist("ItalicAngle")) { | 200 if (pFontDesc->KeyExist("ItalicAngle")) { |
201 ItalicAngle = pFontDesc->GetInteger("ItalicAngle"); | 201 ItalicAngle = pFontDesc->GetIntegerBy("ItalicAngle"); |
202 bExistItalicAngle = TRUE; | 202 bExistItalicAngle = TRUE; |
203 } | 203 } |
204 if (ItalicAngle < 0) { | 204 if (ItalicAngle < 0) { |
205 m_Flags |= PDFFONT_ITALIC; | 205 m_Flags |= PDFFONT_ITALIC; |
206 m_ItalicAngle = ItalicAngle; | 206 m_ItalicAngle = ItalicAngle; |
207 } | 207 } |
208 FX_BOOL bExistStemV = FALSE; | 208 FX_BOOL bExistStemV = FALSE; |
209 if (pFontDesc->KeyExist("StemV")) { | 209 if (pFontDesc->KeyExist("StemV")) { |
210 m_StemV = pFontDesc->GetInteger("StemV"); | 210 m_StemV = pFontDesc->GetIntegerBy("StemV"); |
211 bExistStemV = TRUE; | 211 bExistStemV = TRUE; |
212 } | 212 } |
213 FX_BOOL bExistAscent = FALSE; | 213 FX_BOOL bExistAscent = FALSE; |
214 if (pFontDesc->KeyExist("Ascent")) { | 214 if (pFontDesc->KeyExist("Ascent")) { |
215 m_Ascent = pFontDesc->GetInteger("Ascent"); | 215 m_Ascent = pFontDesc->GetIntegerBy("Ascent"); |
216 bExistAscent = TRUE; | 216 bExistAscent = TRUE; |
217 } | 217 } |
218 FX_BOOL bExistDescent = FALSE; | 218 FX_BOOL bExistDescent = FALSE; |
219 if (pFontDesc->KeyExist("Descent")) { | 219 if (pFontDesc->KeyExist("Descent")) { |
220 m_Descent = pFontDesc->GetInteger("Descent"); | 220 m_Descent = pFontDesc->GetIntegerBy("Descent"); |
221 bExistDescent = TRUE; | 221 bExistDescent = TRUE; |
222 } | 222 } |
223 FX_BOOL bExistCapHeight = FALSE; | 223 FX_BOOL bExistCapHeight = FALSE; |
224 if (pFontDesc->KeyExist("CapHeight")) { | 224 if (pFontDesc->KeyExist("CapHeight")) { |
225 bExistCapHeight = TRUE; | 225 bExistCapHeight = TRUE; |
226 } | 226 } |
227 if (bExistItalicAngle && bExistAscent && bExistCapHeight && bExistDescent && | 227 if (bExistItalicAngle && bExistAscent && bExistCapHeight && bExistDescent && |
228 bExistStemV) { | 228 bExistStemV) { |
229 m_Flags |= PDFFONT_USEEXTERNATTR; | 229 m_Flags |= PDFFONT_USEEXTERNATTR; |
230 } | 230 } |
231 if (m_Descent > 10) { | 231 if (m_Descent > 10) { |
232 m_Descent = -m_Descent; | 232 m_Descent = -m_Descent; |
233 } | 233 } |
234 CPDF_Array* pBBox = pFontDesc->GetArray("FontBBox"); | 234 CPDF_Array* pBBox = pFontDesc->GetArrayBy("FontBBox"); |
235 if (pBBox) { | 235 if (pBBox) { |
236 m_FontBBox.left = pBBox->GetInteger(0); | 236 m_FontBBox.left = pBBox->GetIntegerAt(0); |
237 m_FontBBox.bottom = pBBox->GetInteger(1); | 237 m_FontBBox.bottom = pBBox->GetIntegerAt(1); |
238 m_FontBBox.right = pBBox->GetInteger(2); | 238 m_FontBBox.right = pBBox->GetIntegerAt(2); |
239 m_FontBBox.top = pBBox->GetInteger(3); | 239 m_FontBBox.top = pBBox->GetIntegerAt(3); |
240 } | 240 } |
241 | 241 |
242 CPDF_Stream* pFontFile = pFontDesc->GetStream("FontFile"); | 242 CPDF_Stream* pFontFile = pFontDesc->GetStreamBy("FontFile"); |
243 if (!pFontFile) | 243 if (!pFontFile) |
244 pFontFile = pFontDesc->GetStream("FontFile2"); | 244 pFontFile = pFontDesc->GetStreamBy("FontFile2"); |
245 if (!pFontFile) | 245 if (!pFontFile) |
246 pFontFile = pFontDesc->GetStream("FontFile3"); | 246 pFontFile = pFontDesc->GetStreamBy("FontFile3"); |
247 if (!pFontFile) | 247 if (!pFontFile) |
248 return; | 248 return; |
249 | 249 |
250 m_pFontFile = m_pDocument->LoadFontFile(pFontFile); | 250 m_pFontFile = m_pDocument->LoadFontFile(pFontFile); |
251 if (!m_pFontFile) | 251 if (!m_pFontFile) |
252 return; | 252 return; |
253 | 253 |
254 const uint8_t* pFontData = m_pFontFile->GetData(); | 254 const uint8_t* pFontData = m_pFontFile->GetData(); |
255 FX_DWORD dwFontSize = m_pFontFile->GetSize(); | 255 FX_DWORD dwFontSize = m_pFontFile->GetSize(); |
256 if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) { | 256 if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 GetCharBBox('g', rect); | 317 GetCharBBox('g', rect); |
318 if (rect.bottom == rect.top) { | 318 if (rect.bottom == rect.top) { |
319 m_Descent = m_FontBBox.bottom; | 319 m_Descent = m_FontBBox.bottom; |
320 } else { | 320 } else { |
321 m_Descent = rect.bottom; | 321 m_Descent = rect.bottom; |
322 } | 322 } |
323 } | 323 } |
324 } | 324 } |
325 void CPDF_Font::LoadUnicodeMap() { | 325 void CPDF_Font::LoadUnicodeMap() { |
326 m_bToUnicodeLoaded = TRUE; | 326 m_bToUnicodeLoaded = TRUE; |
327 CPDF_Stream* pStream = m_pFontDict->GetStream("ToUnicode"); | 327 CPDF_Stream* pStream = m_pFontDict->GetStreamBy("ToUnicode"); |
328 if (!pStream) { | 328 if (!pStream) { |
329 return; | 329 return; |
330 } | 330 } |
331 m_pToUnicodeMap = new CPDF_ToUnicodeMap; | 331 m_pToUnicodeMap = new CPDF_ToUnicodeMap; |
332 m_pToUnicodeMap->Load(pStream); | 332 m_pToUnicodeMap->Load(pStream); |
333 } | 333 } |
334 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { | 334 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { |
335 int offset = 0; | 335 int offset = 0; |
336 int width = 0; | 336 int width = 0; |
337 while (offset < size) { | 337 while (offset < size) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 pFontGlobals->Set(pDoc, font_id, pFont); | 373 pFontGlobals->Set(pDoc, font_id, pFont); |
374 return pFont; | 374 return pFont; |
375 } | 375 } |
376 const uint8_t ChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, | 376 const uint8_t ChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, |
377 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, | 377 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, |
378 {0xBA, 0xDA, 0xCC, 0xE5, 0x00}, | 378 {0xBA, 0xDA, 0xCC, 0xE5, 0x00}, |
379 {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, | 379 {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, |
380 {0xD0, 0xC2, 0xCB, 0xCE, 0x00}}; | 380 {0xD0, 0xC2, 0xCB, 0xCE, 0x00}}; |
381 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, | 381 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, |
382 CPDF_Dictionary* pFontDict) { | 382 CPDF_Dictionary* pFontDict) { |
383 CFX_ByteString type = pFontDict->GetString("Subtype"); | 383 CFX_ByteString type = pFontDict->GetStringBy("Subtype"); |
384 CPDF_Font* pFont; | 384 CPDF_Font* pFont; |
385 if (type == "TrueType") { | 385 if (type == "TrueType") { |
386 { | 386 { |
387 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \ | 387 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \ |
388 _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ | 388 _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ |
389 _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ || \ | 389 _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ || \ |
390 _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 390 _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
391 CFX_ByteString basefont = pFontDict->GetString("BaseFont"); | 391 CFX_ByteString basefont = pFontDict->GetStringBy("BaseFont"); |
392 CFX_ByteString tag = basefont.Left(4); | 392 CFX_ByteString tag = basefont.Left(4); |
393 int i; | 393 int i; |
394 int count = sizeof(ChineseFontNames) / sizeof(ChineseFontNames[0]); | 394 int count = sizeof(ChineseFontNames) / sizeof(ChineseFontNames[0]); |
395 for (i = 0; i < count; ++i) { | 395 for (i = 0; i < count; ++i) { |
396 if (tag == CFX_ByteString((const FX_CHAR*)ChineseFontNames[i])) { | 396 if (tag == CFX_ByteString((const FX_CHAR*)ChineseFontNames[i])) { |
397 break; | 397 break; |
398 } | 398 } |
399 } | 399 } |
400 if (i < count) { | 400 if (i < count) { |
401 CPDF_Dictionary* pFontDesc = pFontDict->GetDict("FontDescriptor"); | 401 CPDF_Dictionary* pFontDesc = pFontDict->GetDictBy("FontDescriptor"); |
402 if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) { | 402 if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) { |
403 pFont = new CPDF_CIDFont; | 403 pFont = new CPDF_CIDFont; |
404 pFont->m_pFontDict = pFontDict; | 404 pFont->m_pFontDict = pFontDict; |
405 pFont->m_pDocument = pDoc; | 405 pFont->m_pDocument = pDoc; |
406 if (!pFont->Load()) { | 406 if (!pFont->Load()) { |
407 delete pFont; | 407 delete pFont; |
408 return NULL; | 408 return NULL; |
409 } | 409 } |
410 return pFont; | 410 return pFont; |
411 } | 411 } |
(...skipping 13 matching lines...) Expand all Loading... |
425 if (!pFont->Load()) { | 425 if (!pFont->Load()) { |
426 delete pFont; | 426 delete pFont; |
427 return NULL; | 427 return NULL; |
428 } | 428 } |
429 return pFont; | 429 return pFont; |
430 } | 430 } |
431 FX_BOOL CPDF_Font::Load() { | 431 FX_BOOL CPDF_Font::Load() { |
432 if (!m_pFontDict) { | 432 if (!m_pFontDict) { |
433 return FALSE; | 433 return FALSE; |
434 } | 434 } |
435 CFX_ByteString type = m_pFontDict->GetString("Subtype"); | 435 CFX_ByteString type = m_pFontDict->GetStringBy("Subtype"); |
436 m_BaseFont = m_pFontDict->GetString("BaseFont"); | 436 m_BaseFont = m_pFontDict->GetStringBy("BaseFont"); |
437 if (type == "MMType1") { | 437 if (type == "MMType1") { |
438 type = "Type1"; | 438 type = "Type1"; |
439 } | 439 } |
440 return _Load(); | 440 return _Load(); |
441 } | 441 } |
442 static CFX_WideString _FontMap_GetWideString(CFX_CharMap* pMap, | 442 static CFX_WideString _FontMap_GetWideString(CFX_CharMap* pMap, |
443 const CFX_ByteString& bytestr) { | 443 const CFX_ByteString& bytestr) { |
444 return ((CPDF_FontCharMap*)pMap)->m_pFont->DecodeString(bytestr); | 444 return ((CPDF_FontCharMap*)pMap)->m_pFont->DecodeString(bytestr); |
445 } | 445 } |
446 static CFX_ByteString _FontMap_GetByteString(CFX_CharMap* pMap, | 446 static CFX_ByteString _FontMap_GetByteString(CFX_CharMap* pMap, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 GetPredefinedEncoding(iBaseEncoding, bsEncoding); | 705 GetPredefinedEncoding(iBaseEncoding, bsEncoding); |
706 return; | 706 return; |
707 } | 707 } |
708 | 708 |
709 CPDF_Dictionary* pDict = pEncoding->AsDictionary(); | 709 CPDF_Dictionary* pDict = pEncoding->AsDictionary(); |
710 if (!pDict) | 710 if (!pDict) |
711 return; | 711 return; |
712 | 712 |
713 if (iBaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && | 713 if (iBaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && |
714 iBaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) { | 714 iBaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) { |
715 CFX_ByteString bsEncoding = pDict->GetString("BaseEncoding"); | 715 CFX_ByteString bsEncoding = pDict->GetStringBy("BaseEncoding"); |
716 if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) { | 716 if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) { |
717 bsEncoding = "WinAnsiEncoding"; | 717 bsEncoding = "WinAnsiEncoding"; |
718 } | 718 } |
719 GetPredefinedEncoding(iBaseEncoding, bsEncoding); | 719 GetPredefinedEncoding(iBaseEncoding, bsEncoding); |
720 } | 720 } |
721 if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { | 721 if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { |
722 iBaseEncoding = PDFFONT_ENCODING_STANDARD; | 722 iBaseEncoding = PDFFONT_ENCODING_STANDARD; |
723 } | 723 } |
724 CPDF_Array* pDiffs = pDict->GetArray("Differences"); | 724 CPDF_Array* pDiffs = pDict->GetArrayBy("Differences"); |
725 if (!pDiffs) { | 725 if (!pDiffs) { |
726 return; | 726 return; |
727 } | 727 } |
728 pCharNames = new CFX_ByteString[256]; | 728 pCharNames = new CFX_ByteString[256]; |
729 FX_DWORD cur_code = 0; | 729 FX_DWORD cur_code = 0; |
730 for (FX_DWORD i = 0; i < pDiffs->GetCount(); i++) { | 730 for (FX_DWORD i = 0; i < pDiffs->GetCount(); i++) { |
731 CPDF_Object* pElement = pDiffs->GetElementValue(i); | 731 CPDF_Object* pElement = pDiffs->GetElementValue(i); |
732 if (!pElement) | 732 if (!pElement) |
733 continue; | 733 continue; |
734 | 734 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 const FX_CHAR* name = NULL; | 852 const FX_CHAR* name = NULL; |
853 if (pCharNames) { | 853 if (pCharNames) { |
854 name = pCharNames[charcode]; | 854 name = pCharNames[charcode]; |
855 } | 855 } |
856 if ((!name || name[0] == 0) && iBaseEncoding) { | 856 if ((!name || name[0] == 0) && iBaseEncoding) { |
857 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); | 857 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); |
858 } | 858 } |
859 return name && name[0] ? name : nullptr; | 859 return name && name[0] ? name : nullptr; |
860 } | 860 } |
861 FX_BOOL CPDF_SimpleFont::LoadCommon() { | 861 FX_BOOL CPDF_SimpleFont::LoadCommon() { |
862 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor"); | 862 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor"); |
863 if (pFontDesc) { | 863 if (pFontDesc) { |
864 LoadFontDescriptor(pFontDesc); | 864 LoadFontDescriptor(pFontDesc); |
865 } | 865 } |
866 CPDF_Array* pWidthArray = m_pFontDict->GetArray("Widths"); | 866 CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); |
867 int width_start = 0, width_end = -1; | 867 int width_start = 0, width_end = -1; |
868 m_bUseFontWidth = TRUE; | 868 m_bUseFontWidth = TRUE; |
869 if (pWidthArray) { | 869 if (pWidthArray) { |
870 m_bUseFontWidth = FALSE; | 870 m_bUseFontWidth = FALSE; |
871 if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) { | 871 if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) { |
872 int MissingWidth = pFontDesc->GetInteger("MissingWidth"); | 872 int MissingWidth = pFontDesc->GetIntegerBy("MissingWidth"); |
873 for (int i = 0; i < 256; i++) { | 873 for (int i = 0; i < 256; i++) { |
874 m_CharWidth[i] = MissingWidth; | 874 m_CharWidth[i] = MissingWidth; |
875 } | 875 } |
876 } | 876 } |
877 width_start = m_pFontDict->GetInteger("FirstChar", 0); | 877 width_start = m_pFontDict->GetIntegerBy("FirstChar", 0); |
878 width_end = m_pFontDict->GetInteger("LastChar", 0); | 878 width_end = m_pFontDict->GetIntegerBy("LastChar", 0); |
879 if (width_start >= 0 && width_start <= 255) { | 879 if (width_start >= 0 && width_start <= 255) { |
880 if (width_end <= 0 || | 880 if (width_end <= 0 || |
881 width_end >= width_start + (int)pWidthArray->GetCount()) { | 881 width_end >= width_start + (int)pWidthArray->GetCount()) { |
882 width_end = width_start + pWidthArray->GetCount() - 1; | 882 width_end = width_start + pWidthArray->GetCount() - 1; |
883 } | 883 } |
884 if (width_end > 255) { | 884 if (width_end > 255) { |
885 width_end = 255; | 885 width_end = 255; |
886 } | 886 } |
887 for (int i = width_start; i <= width_end; i++) { | 887 for (int i = width_start; i <= width_end; i++) { |
888 m_CharWidth[i] = pWidthArray->GetInteger(i - width_start); | 888 m_CharWidth[i] = pWidthArray->GetIntegerAt(i - width_start); |
889 } | 889 } |
890 } | 890 } |
891 } | 891 } |
892 if (m_pFontFile) { | 892 if (m_pFontFile) { |
893 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { | 893 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { |
894 m_BaseFont = m_BaseFont.Mid(8); | 894 m_BaseFont = m_BaseFont.Mid(8); |
895 } | 895 } |
896 } else { | 896 } else { |
897 LoadSubstFont(); | 897 LoadSubstFont(); |
898 } | 898 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && | 953 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && |
954 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && | 954 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && |
955 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; | 955 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; |
956 } | 956 } |
957 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) { | 957 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) { |
958 m_Base14Font = -1; | 958 m_Base14Font = -1; |
959 } | 959 } |
960 FX_BOOL CPDF_Type1Font::_Load() { | 960 FX_BOOL CPDF_Type1Font::_Load() { |
961 m_Base14Font = PDF_GetStandardFontName(&m_BaseFont); | 961 m_Base14Font = PDF_GetStandardFontName(&m_BaseFont); |
962 if (m_Base14Font >= 0) { | 962 if (m_Base14Font >= 0) { |
963 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor"); | 963 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor"); |
964 if (pFontDesc && pFontDesc->KeyExist("Flags")) { | 964 if (pFontDesc && pFontDesc->KeyExist("Flags")) { |
965 m_Flags = pFontDesc->GetInteger("Flags"); | 965 m_Flags = pFontDesc->GetIntegerBy("Flags"); |
966 } else { | 966 } else { |
967 m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLIC; | 967 m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLIC; |
968 } | 968 } |
969 if (m_Base14Font < 4) | 969 if (m_Base14Font < 4) |
970 for (int i = 0; i < 256; i++) { | 970 for (int i = 0; i < 256; i++) { |
971 m_CharWidth[i] = 600; | 971 m_CharWidth[i] = 600; |
972 } | 972 } |
973 if (m_Base14Font == 12) { | 973 if (m_Base14Font == 12) { |
974 m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; | 974 m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; |
975 } else if (m_Base14Font == 13) { | 975 } else if (m_Base14Font == 13) { |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 baseEncoding = | 1422 baseEncoding = |
1423 bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCODING_BUILTIN; | 1423 bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCODING_BUILTIN; |
1424 } | 1424 } |
1425 } | 1425 } |
1426 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || | 1426 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || |
1427 baseEncoding == PDFFONT_ENCODING_WINANSI) && | 1427 baseEncoding == PDFFONT_ENCODING_WINANSI) && |
1428 !m_pCharNames) || | 1428 !m_pCharNames) || |
1429 (m_Flags & PDFFONT_NONSYMBOLIC)) { | 1429 (m_Flags & PDFFONT_NONSYMBOLIC)) { |
1430 if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) && | 1430 if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) && |
1431 (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) { | 1431 (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) { |
1432 int nStartChar = m_pFontDict->GetInteger("FirstChar"); | 1432 int nStartChar = m_pFontDict->GetIntegerBy("FirstChar"); |
1433 if (nStartChar < 0 || nStartChar > 255) | 1433 if (nStartChar < 0 || nStartChar > 255) |
1434 return; | 1434 return; |
1435 | 1435 |
1436 int charcode = 0; | 1436 int charcode = 0; |
1437 for (; charcode < nStartChar; charcode++) { | 1437 for (; charcode < nStartChar; charcode++) { |
1438 m_GlyphIndex[charcode] = 0; | 1438 m_GlyphIndex[charcode] = 0; |
1439 } | 1439 } |
1440 FX_WORD nGlyph = charcode - nStartChar + 3; | 1440 FX_WORD nGlyph = charcode - nStartChar + 3; |
1441 for (; charcode < 256; charcode++, nGlyph++) { | 1441 for (; charcode < 256; charcode++, nGlyph++) { |
1442 m_GlyphIndex[charcode] = nGlyph; | 1442 m_GlyphIndex[charcode] = nGlyph; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 m_pFontResources(nullptr) { | 1598 m_pFontResources(nullptr) { |
1599 FXSYS_memset(m_CharWidthL, 0, sizeof(m_CharWidthL)); | 1599 FXSYS_memset(m_CharWidthL, 0, sizeof(m_CharWidthL)); |
1600 } | 1600 } |
1601 | 1601 |
1602 CPDF_Type3Font::~CPDF_Type3Font() { | 1602 CPDF_Type3Font::~CPDF_Type3Font() { |
1603 for (auto it : m_CacheMap) | 1603 for (auto it : m_CacheMap) |
1604 delete it.second; | 1604 delete it.second; |
1605 } | 1605 } |
1606 | 1606 |
1607 FX_BOOL CPDF_Type3Font::_Load() { | 1607 FX_BOOL CPDF_Type3Font::_Load() { |
1608 m_pFontResources = m_pFontDict->GetDict("Resources"); | 1608 m_pFontResources = m_pFontDict->GetDictBy("Resources"); |
1609 CPDF_Array* pMatrix = m_pFontDict->GetArray("FontMatrix"); | 1609 CPDF_Array* pMatrix = m_pFontDict->GetArrayBy("FontMatrix"); |
1610 FX_FLOAT xscale = 1.0f, yscale = 1.0f; | 1610 FX_FLOAT xscale = 1.0f, yscale = 1.0f; |
1611 if (pMatrix) { | 1611 if (pMatrix) { |
1612 m_FontMatrix = pMatrix->GetMatrix(); | 1612 m_FontMatrix = pMatrix->GetMatrix(); |
1613 xscale = m_FontMatrix.a; | 1613 xscale = m_FontMatrix.a; |
1614 yscale = m_FontMatrix.d; | 1614 yscale = m_FontMatrix.d; |
1615 } | 1615 } |
1616 CPDF_Array* pBBox = m_pFontDict->GetArray("FontBBox"); | 1616 CPDF_Array* pBBox = m_pFontDict->GetArrayBy("FontBBox"); |
1617 if (pBBox) { | 1617 if (pBBox) { |
1618 m_FontBBox.left = (int32_t)(FXSYS_Mul(pBBox->GetNumber(0), xscale) * 1000); | 1618 m_FontBBox.left = |
| 1619 (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(0), xscale) * 1000); |
1619 m_FontBBox.bottom = | 1620 m_FontBBox.bottom = |
1620 (int32_t)(FXSYS_Mul(pBBox->GetNumber(1), yscale) * 1000); | 1621 (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(1), yscale) * 1000); |
1621 m_FontBBox.right = (int32_t)(FXSYS_Mul(pBBox->GetNumber(2), xscale) * 1000); | 1622 m_FontBBox.right = |
1622 m_FontBBox.top = (int32_t)(FXSYS_Mul(pBBox->GetNumber(3), yscale) * 1000); | 1623 (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(2), xscale) * 1000); |
| 1624 m_FontBBox.top = (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(3), yscale) * 1000); |
1623 } | 1625 } |
1624 int StartChar = m_pFontDict->GetInteger("FirstChar"); | 1626 int StartChar = m_pFontDict->GetIntegerBy("FirstChar"); |
1625 CPDF_Array* pWidthArray = m_pFontDict->GetArray("Widths"); | 1627 CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); |
1626 if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { | 1628 if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { |
1627 FX_DWORD count = pWidthArray->GetCount(); | 1629 FX_DWORD count = pWidthArray->GetCount(); |
1628 if (count > 256) { | 1630 if (count > 256) { |
1629 count = 256; | 1631 count = 256; |
1630 } | 1632 } |
1631 if (StartChar + count > 256) { | 1633 if (StartChar + count > 256) { |
1632 count = 256 - StartChar; | 1634 count = 256 - StartChar; |
1633 } | 1635 } |
1634 for (FX_DWORD i = 0; i < count; i++) { | 1636 for (FX_DWORD i = 0; i < count; i++) { |
1635 m_CharWidthL[StartChar + i] = | 1637 m_CharWidthL[StartChar + i] = |
1636 FXSYS_round(FXSYS_Mul(pWidthArray->GetNumber(i), xscale) * 1000); | 1638 FXSYS_round(FXSYS_Mul(pWidthArray->GetNumberAt(i), xscale) * 1000); |
1637 } | 1639 } |
1638 } | 1640 } |
1639 m_pCharProcs = m_pFontDict->GetDict("CharProcs"); | 1641 m_pCharProcs = m_pFontDict->GetDictBy("CharProcs"); |
1640 CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding"); | 1642 CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding"); |
1641 if (pEncoding) { | 1643 if (pEncoding) { |
1642 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE); | 1644 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE); |
1643 if (m_pCharNames) { | 1645 if (m_pCharNames) { |
1644 for (int i = 0; i < 256; i++) { | 1646 for (int i = 0; i < 256; i++) { |
1645 m_Encoding.m_Unicodes[i] = PDF_UnicodeFromAdobeName(m_pCharNames[i]); | 1647 m_Encoding.m_Unicodes[i] = PDF_UnicodeFromAdobeName(m_pCharNames[i]); |
1646 if (m_Encoding.m_Unicodes[i] == 0) { | 1648 if (m_Encoding.m_Unicodes[i] == 0) { |
1647 m_Encoding.m_Unicodes[i] = i; | 1649 m_Encoding.m_Unicodes[i] = i; |
1648 } | 1650 } |
1649 } | 1651 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1734 rect = pChar->m_BBox; | 1736 rect = pChar->m_BBox; |
1735 } | 1737 } |
1736 | 1738 |
1737 CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm) | 1739 CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm) |
1738 : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {} | 1740 : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {} |
1739 | 1741 |
1740 CPDF_Type3Char::~CPDF_Type3Char() { | 1742 CPDF_Type3Char::~CPDF_Type3Char() { |
1741 delete m_pForm; | 1743 delete m_pForm; |
1742 delete m_pBitmap; | 1744 delete m_pBitmap; |
1743 } | 1745 } |
OLD | NEW |