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 "xfa/fxfa/include/xfa_fontmgr.h" | 7 #include "xfa/fxfa/include/xfa_fontmgr.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, | 1831 CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, |
1832 FX_BOOL bBold, | 1832 FX_BOOL bBold, |
1833 FX_BOOL bItalic, | 1833 FX_BOOL bItalic, |
1834 CPDF_Font** pDstPDFFont, | 1834 CPDF_Font** pDstPDFFont, |
1835 FX_BOOL bStrictMatch) { | 1835 FX_BOOL bStrictMatch) { |
1836 CPDF_Document* pDoc = m_pDoc->GetPDFDoc(); | 1836 CPDF_Document* pDoc = m_pDoc->GetPDFDoc(); |
1837 if (!pDoc) { | 1837 if (!pDoc) { |
1838 return nullptr; | 1838 return nullptr; |
1839 } | 1839 } |
1840 CPDF_Dictionary* pFontSetDict = | 1840 CPDF_Dictionary* pFontSetDict = |
1841 pDoc->GetRoot()->GetDictBy("AcroForm")->GetDictBy("DR"); | 1841 pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR"); |
1842 if (!pFontSetDict) { | 1842 if (!pFontSetDict) { |
1843 return nullptr; | 1843 return nullptr; |
1844 } | 1844 } |
1845 pFontSetDict = pFontSetDict->GetDictBy("Font"); | 1845 pFontSetDict = pFontSetDict->GetDictFor("Font"); |
1846 if (!pFontSetDict) { | 1846 if (!pFontSetDict) { |
1847 return nullptr; | 1847 return nullptr; |
1848 } | 1848 } |
1849 strPsName.Remove(' '); | 1849 strPsName.Remove(' '); |
1850 IFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); | 1850 IFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); |
1851 for (const auto& it : *pFontSetDict) { | 1851 for (const auto& it : *pFontSetDict) { |
1852 const CFX_ByteString& key = it.first; | 1852 const CFX_ByteString& key = it.first; |
1853 CPDF_Object* pObj = it.second; | 1853 CPDF_Object* pObj = it.second; |
1854 if (!PsNameMatchDRFontName(strPsName.AsStringC(), bBold, bItalic, key, | 1854 if (!PsNameMatchDRFontName(strPsName.AsStringC(), bBold, bItalic, key, |
1855 bStrictMatch)) { | 1855 bStrictMatch)) { |
1856 continue; | 1856 continue; |
1857 } | 1857 } |
1858 CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect()); | 1858 CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect()); |
1859 if (!pFontDict || pFontDict->GetStringBy("Type") != "Font") { | 1859 if (!pFontDict || pFontDict->GetStringFor("Type") != "Font") { |
1860 return nullptr; | 1860 return nullptr; |
1861 } | 1861 } |
1862 CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); | 1862 CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); |
1863 if (!pPDFFont) { | 1863 if (!pPDFFont) { |
1864 return nullptr; | 1864 return nullptr; |
1865 } | 1865 } |
1866 if (!pPDFFont->IsEmbedded()) { | 1866 if (!pPDFFont->IsEmbedded()) { |
1867 *pDstPDFFont = pPDFFont; | 1867 *pDstPDFFont = pPDFFont; |
1868 return nullptr; | 1868 return nullptr; |
1869 } | 1869 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 m_PDFFontMgrMap[hDoc].reset(new CXFA_PDFFontMgr(hDoc)); | 2053 m_PDFFontMgrMap[hDoc].reset(new CXFA_PDFFontMgr(hDoc)); |
2054 } | 2054 } |
2055 | 2055 |
2056 void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) { | 2056 void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) { |
2057 m_PDFFontMgrMap.erase(hDoc); | 2057 m_PDFFontMgrMap.erase(hDoc); |
2058 } | 2058 } |
2059 | 2059 |
2060 void CXFA_FontMgr::SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr) { | 2060 void CXFA_FontMgr::SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr) { |
2061 m_pDefFontMgr = std::move(pFontMgr); | 2061 m_pDefFontMgr = std::move(pFontMgr); |
2062 } | 2062 } |
OLD | NEW |