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 | 10 |
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 | 1759 |
1760 IFX_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc, | 1760 IFX_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc, |
1761 const CFX_WideStringC& wsFontFamily, | 1761 const CFX_WideStringC& wsFontFamily, |
1762 uint32_t dwFontStyles, | 1762 uint32_t dwFontStyles, |
1763 uint16_t wCodePage) { | 1763 uint16_t wCodePage) { |
1764 CFX_WideString wsFontName = wsFontFamily; | 1764 CFX_WideString wsFontName = wsFontFamily; |
1765 IFX_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); | 1765 IFX_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); |
1766 IFX_Font* pFont = pFDEFontMgr->LoadFont(wsFontName, dwFontStyles, wCodePage); | 1766 IFX_Font* pFont = pFDEFontMgr->LoadFont(wsFontName, dwFontStyles, wCodePage); |
1767 if (!pFont) { | 1767 if (!pFont) { |
1768 const XFA_FONTINFO* pCurFont = | 1768 const XFA_FONTINFO* pCurFont = |
1769 XFA_GetFontINFOByFontName(wsFontName.AsWideStringC()); | 1769 XFA_GetFontINFOByFontName(wsFontName.AsStringC()); |
1770 if (pCurFont && pCurFont->pReplaceFont) { | 1770 if (pCurFont && pCurFont->pReplaceFont) { |
1771 uint32_t dwStyle = 0; | 1771 uint32_t dwStyle = 0; |
1772 if (dwFontStyles & FX_FONTSTYLE_Bold) { | 1772 if (dwFontStyles & FX_FONTSTYLE_Bold) { |
1773 dwStyle |= FX_FONTSTYLE_Bold; | 1773 dwStyle |= FX_FONTSTYLE_Bold; |
1774 } | 1774 } |
1775 if (dwFontStyles & FX_FONTSTYLE_Italic) { | 1775 if (dwFontStyles & FX_FONTSTYLE_Italic) { |
1776 dwStyle |= FX_FONTSTYLE_Italic; | 1776 dwStyle |= FX_FONTSTYLE_Italic; |
1777 } | 1777 } |
1778 const FX_WCHAR* pReplace = pCurFont->pReplaceFont; | 1778 const FX_WCHAR* pReplace = pCurFont->pReplaceFont; |
1779 int32_t iLength = FXSYS_wcslen(pReplace); | 1779 int32_t iLength = FXSYS_wcslen(pReplace); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 } | 1855 } |
1856 pFontSetDict = (CPDF_Dictionary*)pFontSetDict->GetDictBy("Font"); | 1856 pFontSetDict = (CPDF_Dictionary*)pFontSetDict->GetDictBy("Font"); |
1857 if (!pFontSetDict) { | 1857 if (!pFontSetDict) { |
1858 return NULL; | 1858 return NULL; |
1859 } | 1859 } |
1860 strPsName.Remove(' '); | 1860 strPsName.Remove(' '); |
1861 IFX_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); | 1861 IFX_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); |
1862 for (const auto& it : *pFontSetDict) { | 1862 for (const auto& it : *pFontSetDict) { |
1863 const CFX_ByteString& key = it.first; | 1863 const CFX_ByteString& key = it.first; |
1864 CPDF_Object* pObj = it.second; | 1864 CPDF_Object* pObj = it.second; |
1865 if (!PsNameMatchDRFontName(strPsName.AsByteStringC(), bBold, bItalic, key, | 1865 if (!PsNameMatchDRFontName(strPsName.AsStringC(), bBold, bItalic, key, |
1866 bStrictMatch)) { | 1866 bStrictMatch)) { |
1867 continue; | 1867 continue; |
1868 } | 1868 } |
1869 CPDF_Object* pDirect = pObj->GetDirect(); | 1869 CPDF_Object* pDirect = pObj->GetDirect(); |
1870 if (!pDirect || !pDirect->IsDictionary()) { | 1870 if (!pDirect || !pDirect->IsDictionary()) { |
1871 return NULL; | 1871 return NULL; |
1872 } | 1872 } |
1873 CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)pDirect; | 1873 CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)pDirect; |
1874 if (pFontDict->GetStringBy("Type") != "Font") { | 1874 if (pFontDict->GetStringBy("Type") != "Font") { |
1875 return NULL; | 1875 return NULL; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); | 2023 bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); |
2024 auto it = m_FontMap.find(bsKey); | 2024 auto it = m_FontMap.find(bsKey); |
2025 if (it != m_FontMap.end()) | 2025 if (it != m_FontMap.end()) |
2026 return it->second; | 2026 return it->second; |
2027 CFX_WideString wsEnglishName; | 2027 CFX_WideString wsEnglishName; |
2028 XFA_LocalFontNameToEnglishName(wsFontFamily, wsEnglishName); | 2028 XFA_LocalFontNameToEnglishName(wsFontFamily, wsEnglishName); |
2029 CXFA_PDFFontMgr* pMgr = (CXFA_PDFFontMgr*)m_PDFFontMgrArray.GetValueAt(hDoc); | 2029 CXFA_PDFFontMgr* pMgr = (CXFA_PDFFontMgr*)m_PDFFontMgrArray.GetValueAt(hDoc); |
2030 CPDF_Font* pPDFFont = NULL; | 2030 CPDF_Font* pPDFFont = NULL; |
2031 IFX_Font* pFont = NULL; | 2031 IFX_Font* pFont = NULL; |
2032 if (pMgr) { | 2032 if (pMgr) { |
2033 pFont = | 2033 pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont); |
2034 pMgr->GetFont(wsEnglishName.AsWideStringC(), dwFontStyles, &pPDFFont); | |
2035 if (pFont) | 2034 if (pFont) |
2036 return pFont; | 2035 return pFont; |
2037 } | 2036 } |
2038 if (!pFont && m_pDefFontMgr) { | 2037 if (!pFont && m_pDefFontMgr) { |
2039 pFont = m_pDefFontMgr->GetFont(hDoc, wsFontFamily, dwFontStyles, wCodePage); | 2038 pFont = m_pDefFontMgr->GetFont(hDoc, wsFontFamily, dwFontStyles, wCodePage); |
2040 } | 2039 } |
2041 if (!pFont && pMgr) { | 2040 if (!pFont && pMgr) { |
2042 pPDFFont = NULL; | 2041 pPDFFont = NULL; |
2043 pFont = pMgr->GetFont(wsEnglishName.AsWideStringC(), dwFontStyles, | 2042 pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont, |
2044 &pPDFFont, FALSE); | 2043 FALSE); |
2045 if (pFont) | 2044 if (pFont) |
2046 return pFont; | 2045 return pFont; |
2047 } | 2046 } |
2048 if (!pFont && m_pDefFontMgr) { | 2047 if (!pFont && m_pDefFontMgr) { |
2049 pFont = m_pDefFontMgr->GetDefaultFont(hDoc, wsFontFamily, dwFontStyles, | 2048 pFont = m_pDefFontMgr->GetDefaultFont(hDoc, wsFontFamily, dwFontStyles, |
2050 wCodePage); | 2049 wCodePage); |
2051 } | 2050 } |
2052 if (pFont) { | 2051 if (pFont) { |
2053 if (pPDFFont) { | 2052 if (pPDFFont) { |
2054 pMgr->m_FDE2PDFFont.SetAt(pFont, pPDFFont); | 2053 pMgr->m_FDE2PDFFont.SetAt(pFont, pPDFFont); |
(...skipping 22 matching lines...) Expand all Loading... |
2077 CXFA_PDFFontMgr* pMgr = NULL; | 2076 CXFA_PDFFontMgr* pMgr = NULL; |
2078 m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr); | 2077 m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr); |
2079 delete pMgr; | 2078 delete pMgr; |
2080 } | 2079 } |
2081 m_PDFFontMgrArray.RemoveAll(); | 2080 m_PDFFontMgrArray.RemoveAll(); |
2082 m_FontMap.clear(); | 2081 m_FontMap.clear(); |
2083 } | 2082 } |
2084 void CXFA_FontMgr::SetDefFontMgr(CXFA_DefFontMgr* pFontMgr) { | 2083 void CXFA_FontMgr::SetDefFontMgr(CXFA_DefFontMgr* pFontMgr) { |
2085 m_pDefFontMgr = pFontMgr; | 2084 m_pDefFontMgr = pFontMgr; |
2086 } | 2085 } |
OLD | NEW |