| 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 "../../../include/fpdfapi/fpdf_module.h" | 7 #include "../../../include/fpdfapi/fpdf_module.h" |
| 8 #include "../../../include/fpdfapi/fpdf_page.h" | 8 #include "../../../include/fpdfapi/fpdf_page.h" |
| 9 #include "font_int.h" | 9 #include "font_int.h" |
| 10 #include "../fpdf_cmaps/cmap_int.h" | 10 #include "../fpdf_cmaps/cmap_int.h" |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 int err = FXFT_Select_Charmap(face, encoding); | 865 int err = FXFT_Select_Charmap(face, encoding); |
| 866 if (err) { | 866 if (err) { |
| 867 err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); | 867 err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); |
| 868 } | 868 } |
| 869 if (err && FXFT_Get_Face_Charmaps(face)) { | 869 if (err && FXFT_Get_Face_Charmaps(face)) { |
| 870 FXFT_Set_Charmap(face, *FXFT_Get_Face_Charmaps(face)); | 870 FXFT_Set_Charmap(face, *FXFT_Get_Face_Charmaps(face)); |
| 871 } | 871 } |
| 872 } | 872 } |
| 873 FX_BOOL CPDF_CIDFont::_Load() | 873 FX_BOOL CPDF_CIDFont::_Load() |
| 874 { | 874 { |
| 875 if (m_pFontDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("TrueType")) { | 875 if (m_pFontDict->GetStringAt("Subtype") == "TrueType") { |
| 876 return LoadGB2312(); | 876 return LoadGB2312(); |
| 877 } | 877 } |
| 878 CPDF_Array* pFonts = m_pFontDict->GetArray(FX_BSTRC("DescendantFonts")); | 878 CPDF_Array* pFonts = m_pFontDict->GetArray(FX_BSTRC("DescendantFonts")); |
| 879 if (pFonts == NULL) { | 879 if (pFonts == NULL) { |
| 880 return FALSE; | 880 return FALSE; |
| 881 } | 881 } |
| 882 if (pFonts->GetCount() != 1) { | 882 if (pFonts->GetCount() != 1) { |
| 883 return FALSE; | 883 return FALSE; |
| 884 } | 884 } |
| 885 CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0); | 885 CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0); |
| 886 if (pCIDFontDict == NULL) { | 886 if (pCIDFontDict == NULL) { |
| 887 return FALSE; | 887 return FALSE; |
| 888 } | 888 } |
| 889 m_BaseFont = pCIDFontDict->GetString(FX_BSTRC("BaseFont")); | 889 m_BaseFont = pCIDFontDict->GetStringAt("BaseFont"); |
| 890 if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd
-Bold") == 0 | 890 if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd
-Bold") == 0 |
| 891 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || m_BaseFont.C
ompare("CourierStd-Oblique") == 0) | 891 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || m_BaseFont.C
ompare("CourierStd-Oblique") == 0) |
| 892 && !IsEmbedded()) { | 892 && !IsEmbedded()) { |
| 893 m_bAdobeCourierStd = TRUE; | 893 m_bAdobeCourierStd = TRUE; |
| 894 } | 894 } |
| 895 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDict(FX_BSTRC("FontDescriptor"
)); | 895 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDict(FX_BSTRC("FontDescriptor"
)); |
| 896 if (pFontDesc) { | 896 if (pFontDesc) { |
| 897 LoadFontDescriptor(pFontDesc); | 897 LoadFontDescriptor(pFontDesc); |
| 898 } | 898 } |
| 899 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); | 899 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); |
| 900 if (pEncoding == NULL) { | 900 if (pEncoding == NULL) { |
| 901 return FALSE; | 901 return FALSE; |
| 902 } | 902 } |
| 903 CFX_ByteString subtype = pCIDFontDict->GetString(FX_BSTRC("Subtype")); | 903 CFX_ByteString subtype = pCIDFontDict->GetStringAt("Subtype"); |
| 904 m_bType1 = FALSE; | 904 m_bType1 = FALSE; |
| 905 if (subtype == FX_BSTRC("CIDFontType0")) { | 905 if (subtype == FX_BSTRC("CIDFontType0")) { |
| 906 m_bType1 = TRUE; | 906 m_bType1 = TRUE; |
| 907 } | 907 } |
| 908 if (pEncoding->GetType() == PDFOBJ_NAME) { | 908 if (pEncoding->GetType() == PDFOBJ_NAME) { |
| 909 CFX_ByteString cmap = pEncoding->GetString(); | 909 CFX_ByteString cmap = pEncoding->GetString(); |
| 910 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CM
apManager.GetPredefinedCMap(cmap, | 910 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CM
apManager.GetPredefinedCMap(cmap, |
| 911 m_pFontFile && m_bType1); | 911 m_pFontFile && m_bType1); |
| 912 } else if (pEncoding->GetType() == PDFOBJ_STREAM) { | 912 } else if (pEncoding->GetType() == PDFOBJ_STREAM) { |
| 913 m_pAllocatedCMap = m_pCMap = new CPDF_CMap; | 913 m_pAllocatedCMap = m_pCMap = new CPDF_CMap; |
| 914 CPDF_Stream* pStream = (CPDF_Stream*)pEncoding; | 914 CPDF_Stream* pStream = (CPDF_Stream*)pEncoding; |
| 915 CPDF_StreamAcc acc; | 915 CPDF_StreamAcc acc; |
| 916 acc.LoadAllData(pStream, FALSE); | 916 acc.LoadAllData(pStream, FALSE); |
| 917 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); | 917 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); |
| 918 } else { | 918 } else { |
| 919 return FALSE; | 919 return FALSE; |
| 920 } | 920 } |
| 921 if (m_pCMap == NULL) { | 921 if (m_pCMap == NULL) { |
| 922 return FALSE; | 922 return FALSE; |
| 923 } | 923 } |
| 924 m_Charset = m_pCMap->m_Charset; | 924 m_Charset = m_pCMap->m_Charset; |
| 925 if (m_Charset == CIDSET_UNKNOWN) { | 925 if (m_Charset == CIDSET_UNKNOWN) { |
| 926 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDict(FX_BSTRC("CIDSystemInf
o")); | 926 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDict(FX_BSTRC("CIDSystemInf
o")); |
| 927 if (pCIDInfo) { | 927 if (pCIDInfo) { |
| 928 m_Charset = _CharsetFromOrdering(pCIDInfo->GetString(FX_BSTRC("Order
ing"))); | 928 m_Charset = _CharsetFromOrdering(pCIDInfo->GetStringAt("Ordering")); |
| 929 } | 929 } |
| 930 } | 930 } |
| 931 if (m_Charset != CIDSET_UNKNOWN) | 931 if (m_Charset != CIDSET_UNKNOWN) |
| 932 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGloba
ls()->m_CMapManager.GetCID2UnicodeMap(m_Charset, | 932 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGloba
ls()->m_CMapManager.GetCID2UnicodeMap(m_Charset, |
| 933 m_pFontFile == NULL && (m_pCMap->m_Coding == CIDCODI
NG_CID || pCIDFontDict->KeyExist(FX_BSTRC("W")))); | 933 m_pFontFile == NULL && (m_pCMap->m_Coding == CIDCODI
NG_CID || pCIDFontDict->KeyExist(FX_BSTRC("W")))); |
| 934 if (m_Font.GetFace()) { | 934 if (m_Font.GetFace()) { |
| 935 if (m_bType1) { | 935 if (m_bType1) { |
| 936 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); | 936 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); |
| 937 } else { | 937 } else { |
| 938 FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->m_Coding); | 938 FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->m_Coding); |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 iCurElement ++; | 1383 iCurElement ++; |
| 1384 if (iCurElement == nElements) { | 1384 if (iCurElement == nElements) { |
| 1385 width_status = 0; | 1385 width_status = 0; |
| 1386 } | 1386 } |
| 1387 } | 1387 } |
| 1388 } | 1388 } |
| 1389 } | 1389 } |
| 1390 } | 1390 } |
| 1391 FX_BOOL CPDF_CIDFont::LoadGB2312() | 1391 FX_BOOL CPDF_CIDFont::LoadGB2312() |
| 1392 { | 1392 { |
| 1393 m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont")); | 1393 m_BaseFont = m_pFontDict->GetStringAt("BaseFont"); |
| 1394 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")
); | 1394 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")
); |
| 1395 if (pFontDesc) { | 1395 if (pFontDesc) { |
| 1396 LoadFontDescriptor(pFontDesc); | 1396 LoadFontDescriptor(pFontDesc); |
| 1397 } | 1397 } |
| 1398 m_Charset = CIDSET_GB1; | 1398 m_Charset = CIDSET_GB1; |
| 1399 m_bType1 = FALSE; | 1399 m_bType1 = FALSE; |
| 1400 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapMa
nager.GetPredefinedCMap( | 1400 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapMa
nager.GetPredefinedCMap( |
| 1401 FX_BSTRC("GBK-EUC-H"), FALSE); | 1401 FX_BSTRC("GBK-EUC-H"), FALSE); |
| 1402 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()
->m_CMapManager.GetCID2UnicodeMap(m_Charset, FALSE); | 1402 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()
->m_CMapManager.GetCID2UnicodeMap(m_Charset, FALSE); |
| 1403 if (!IsEmbedded()) { | 1403 if (!IsEmbedded()) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1584 if (middlecode > CID) { | 1584 if (middlecode > CID) { |
| 1585 end = middle - 1; | 1585 end = middle - 1; |
| 1586 } else if (middlecode < CID) { | 1586 } else if (middlecode < CID) { |
| 1587 begin = middle + 1; | 1587 begin = middle + 1; |
| 1588 } else { | 1588 } else { |
| 1589 return &Japan1_VertCIDs[middle].a; | 1589 return &Japan1_VertCIDs[middle].a; |
| 1590 } | 1590 } |
| 1591 } | 1591 } |
| 1592 return NULL; | 1592 return NULL; |
| 1593 } | 1593 } |
| OLD | NEW |