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_cidfont.h" | 7 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" | 9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" |
10 #include "core/fpdfapi/fpdf_font/font_int.h" | 10 #include "core/fpdfapi/fpdf_font/font_int.h" |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 m_BaseFont.Compare("CourierStd-Bold") == 0 || | 366 m_BaseFont.Compare("CourierStd-Bold") == 0 || |
367 m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || | 367 m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || |
368 m_BaseFont.Compare("CourierStd-Oblique") == 0) && | 368 m_BaseFont.Compare("CourierStd-Oblique") == 0) && |
369 !IsEmbedded()) { | 369 !IsEmbedded()) { |
370 m_bAdobeCourierStd = TRUE; | 370 m_bAdobeCourierStd = TRUE; |
371 } | 371 } |
372 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDictBy("FontDescriptor"); | 372 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDictBy("FontDescriptor"); |
373 if (pFontDesc) { | 373 if (pFontDesc) { |
374 LoadFontDescriptor(pFontDesc); | 374 LoadFontDescriptor(pFontDesc); |
375 } | 375 } |
376 CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding"); | 376 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); |
377 if (!pEncoding) { | 377 if (!pEncoding) { |
378 return FALSE; | 378 return FALSE; |
379 } | 379 } |
380 CFX_ByteString subtype = pCIDFontDict->GetStringBy("Subtype"); | 380 CFX_ByteString subtype = pCIDFontDict->GetStringBy("Subtype"); |
381 m_bType1 = (subtype == "CIDFontType0"); | 381 m_bType1 = (subtype == "CIDFontType0"); |
382 | 382 |
383 if (pEncoding->IsName()) { | 383 if (pEncoding->IsName()) { |
384 CFX_ByteString cmap = pEncoding->GetString(); | 384 CFX_ByteString cmap = pEncoding->GetString(); |
385 m_pCMap = | 385 m_pCMap = |
386 CPDF_ModuleMgr::Get() | 386 CPDF_ModuleMgr::Get() |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 m_DefaultWidth = pCIDFontDict->GetIntegerBy("DW", 1000); | 424 m_DefaultWidth = pCIDFontDict->GetIntegerBy("DW", 1000); |
425 CPDF_Array* pWidthArray = pCIDFontDict->GetArrayBy("W"); | 425 CPDF_Array* pWidthArray = pCIDFontDict->GetArrayBy("W"); |
426 if (pWidthArray) { | 426 if (pWidthArray) { |
427 LoadMetricsArray(pWidthArray, m_WidthList, 1); | 427 LoadMetricsArray(pWidthArray, m_WidthList, 1); |
428 } | 428 } |
429 if (!IsEmbedded()) { | 429 if (!IsEmbedded()) { |
430 LoadSubstFont(); | 430 LoadSubstFont(); |
431 } | 431 } |
432 if (1) { | 432 if (1) { |
433 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { | 433 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { |
434 CPDF_Object* pmap = pCIDFontDict->GetElementValue("CIDToGIDMap"); | 434 CPDF_Object* pmap = pCIDFontDict->GetDirectObjectBy("CIDToGIDMap"); |
435 if (pmap) { | 435 if (pmap) { |
436 if (CPDF_Stream* pStream = pmap->AsStream()) { | 436 if (CPDF_Stream* pStream = pmap->AsStream()) { |
437 m_pCIDToGIDMap = new CPDF_StreamAcc; | 437 m_pCIDToGIDMap = new CPDF_StreamAcc; |
438 m_pCIDToGIDMap->LoadAllData(pStream, FALSE); | 438 m_pCIDToGIDMap->LoadAllData(pStream, FALSE); |
439 } else if (pmap->GetString() == "Identity") { | 439 } else if (pmap->GetString() == "Identity") { |
440 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 440 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
441 if (m_pFontFile) { | 441 if (m_pFontFile) { |
442 m_bCIDIsGID = TRUE; | 442 m_bCIDIsGID = TRUE; |
443 } | 443 } |
444 #else | 444 #else |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 } | 813 } |
814 void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, | 814 void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, |
815 CFX_ArrayTemplate<uint32_t>& result, | 815 CFX_ArrayTemplate<uint32_t>& result, |
816 int nElements) { | 816 int nElements) { |
817 int width_status = 0; | 817 int width_status = 0; |
818 int iCurElement = 0; | 818 int iCurElement = 0; |
819 int first_code = 0; | 819 int first_code = 0; |
820 int last_code = 0; | 820 int last_code = 0; |
821 uint32_t count = pArray->GetCount(); | 821 uint32_t count = pArray->GetCount(); |
822 for (uint32_t i = 0; i < count; i++) { | 822 for (uint32_t i = 0; i < count; i++) { |
823 CPDF_Object* pObj = pArray->GetElementValue(i); | 823 CPDF_Object* pObj = pArray->GetDirectObjectAt(i); |
824 if (!pObj) | 824 if (!pObj) |
825 continue; | 825 continue; |
826 | 826 |
827 if (CPDF_Array* pArray = pObj->AsArray()) { | 827 if (CPDF_Array* pArray = pObj->AsArray()) { |
828 if (width_status != 1) | 828 if (width_status != 1) |
829 return; | 829 return; |
830 | 830 |
831 uint32_t count = pArray->GetCount(); | 831 uint32_t count = pArray->GetCount(); |
832 for (uint32_t j = 0; j < count; j += nElements) { | 832 for (uint32_t j = 0; j < count; j += nElements) { |
833 result.Add(first_code); | 833 result.Add(first_code); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 | 899 |
900 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { | 900 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { |
901 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) | 901 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) |
902 return nullptr; | 902 return nullptr; |
903 | 903 |
904 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( | 904 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( |
905 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), | 905 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), |
906 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); | 906 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); |
907 return found ? &found->a : nullptr; | 907 return found ? &found->a : nullptr; |
908 } | 908 } |
OLD | NEW |