Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: xfa/fxfa/app/xfa_fontmgr.cpp

Issue 1930533002: More IFX_ interface cleanup. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_ffapp.cpp ('k') | xfa/fxfa/include/xfa_checksum.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 return NULL; 1867 return NULL;
1868 } 1868 }
1869 if (!pPDFFont->IsEmbedded()) { 1869 if (!pPDFFont->IsEmbedded()) {
1870 *pDstPDFFont = pPDFFont; 1870 *pDstPDFFont = pPDFFont;
1871 return NULL; 1871 return NULL;
1872 } 1872 }
1873 return IFX_Font::LoadFont(&pPDFFont->m_Font, pFDEFontMgr); 1873 return IFX_Font::LoadFont(&pPDFFont->m_Font, pFDEFontMgr);
1874 } 1874 }
1875 return NULL; 1875 return NULL;
1876 } 1876 }
1877
1877 IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily, 1878 IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily,
1878 uint32_t dwFontStyles, 1879 uint32_t dwFontStyles,
1879 CPDF_Font** pPDFFont, 1880 CPDF_Font** pPDFFont,
1880 FX_BOOL bStrictMatch) { 1881 FX_BOOL bStrictMatch) {
1881 uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false); 1882 uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
1882 CFX_ByteString strKey; 1883 CFX_ByteString strKey;
1883 strKey.Format("%u%u", dwHashCode, dwFontStyles); 1884 strKey.Format("%u%u", dwHashCode, dwFontStyles);
1884 auto it = m_FontMap.find(strKey); 1885 auto it = m_FontMap.find(strKey);
1885 if (it != m_FontMap.end()) 1886 if (it != m_FontMap.end())
1886 return it->second; 1887 return it->second;
1887 CFX_ByteString bsPsName = CFX_ByteString::FromUnicode(wsFontFamily); 1888 CFX_ByteString bsPsName = CFX_ByteString::FromUnicode(wsFontFamily);
1888 FX_BOOL bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold; 1889 FX_BOOL bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold;
1889 FX_BOOL bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic; 1890 FX_BOOL bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic;
1890 CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic); 1891 CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic);
1891 IFX_Font* pFont = 1892 IFX_Font* pFont =
1892 FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); 1893 FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch);
1893 if (pFont) 1894 if (pFont)
1894 m_FontMap[strKey] = pFont; 1895 m_FontMap[strKey] = pFont;
1895 return pFont; 1896 return pFont;
1896 } 1897 }
1898
1897 CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName( 1899 CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName(
1898 const CFX_ByteString& strPsName, 1900 const CFX_ByteString& strPsName,
1899 FX_BOOL bBold, 1901 FX_BOOL bBold,
1900 FX_BOOL bItalic) { 1902 FX_BOOL bItalic) {
1901 int32_t nCount = sizeof(g_XFAPDFFontName) / sizeof(XFA_PDFFONTNAME); 1903 int32_t nCount = sizeof(g_XFAPDFFontName) / sizeof(XFA_PDFFONTNAME);
1902 for (int32_t i = 0; i < nCount; i++) { 1904 for (int32_t i = 0; i < nCount; i++) {
1903 if (strPsName == g_XFAPDFFontName[i].lpPsName) { 1905 if (strPsName == g_XFAPDFFontName[i].lpPsName) {
1904 int32_t index = 1 + ((bItalic << 1) | bBold); 1906 int32_t index = 1 + ((bItalic << 1) | bBold);
1905 return *(&g_XFAPDFFontName[i].lpPsName + index); 1907 return *(&g_XFAPDFFontName[i].lpPsName + index);
1906 } 1908 }
1907 } 1909 }
1908 return strPsName; 1910 return strPsName;
1909 } 1911 }
1912
1910 FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName( 1913 FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName(
1911 const CFX_ByteStringC& bsPsName, 1914 const CFX_ByteStringC& bsPsName,
1912 FX_BOOL bBold, 1915 FX_BOOL bBold,
1913 FX_BOOL bItalic, 1916 FX_BOOL bItalic,
1914 const CFX_ByteString& bsDRFontName, 1917 const CFX_ByteString& bsDRFontName,
1915 FX_BOOL bStrictMatch) { 1918 FX_BOOL bStrictMatch) {
1916 CFX_ByteString bsDRName = bsDRFontName; 1919 CFX_ByteString bsDRName = bsDRFontName;
1917 bsDRName.Remove('-'); 1920 bsDRName.Remove('-');
1918 int32_t iPsLen = bsPsName.GetLength(); 1921 int32_t iPsLen = bsPsName.GetLength();
1919 int32_t nIndex = bsDRName.Find(bsPsName); 1922 int32_t nIndex = bsDRName.Find(bsPsName);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 return FALSE; 1992 return FALSE;
1990 } 1993 }
1991 CPDF_Font* pPDFFont = (CPDF_Font*)m_FDE2PDFFont.GetValueAt(pFont); 1994 CPDF_Font* pPDFFont = (CPDF_Font*)m_FDE2PDFFont.GetValueAt(pFont);
1992 if (!pPDFFont) { 1995 if (!pPDFFont) {
1993 return FALSE; 1996 return FALSE;
1994 } 1997 }
1995 wUnicode = (FX_WCHAR)pPDFFont->CharCodeFromUnicode(wUnicode); 1998 wUnicode = (FX_WCHAR)pPDFFont->CharCodeFromUnicode(wUnicode);
1996 iWidth = pPDFFont->GetCharWidthF(wUnicode); 1999 iWidth = pPDFFont->GetCharWidthF(wUnicode);
1997 return TRUE; 2000 return TRUE;
1998 } 2001 }
1999 CXFA_FontMgr::CXFA_FontMgr() : m_pDefFontMgr(NULL) {} 2002
2003 CXFA_FontMgr::CXFA_FontMgr() : m_pDefFontMgr(nullptr) {}
2004
2000 CXFA_FontMgr::~CXFA_FontMgr() { 2005 CXFA_FontMgr::~CXFA_FontMgr() {
2001 DelAllMgrMap(); 2006 DelAllMgrMap();
2002 } 2007 }
2008
2003 IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc, 2009 IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
2004 const CFX_WideStringC& wsFontFamily, 2010 const CFX_WideStringC& wsFontFamily,
2005 uint32_t dwFontStyles, 2011 uint32_t dwFontStyles,
2006 uint16_t wCodePage) { 2012 uint16_t wCodePage) {
2007 uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false); 2013 uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false);
2008 CFX_ByteString bsKey; 2014 CFX_ByteString bsKey;
2009 bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); 2015 bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage);
2010 auto it = m_FontMap.find(bsKey); 2016 auto it = m_FontMap.find(bsKey);
2011 if (it != m_FontMap.end()) 2017 if (it != m_FontMap.end())
2012 return it->second; 2018 return it->second;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 CXFA_PDFFontMgr* pMgr = NULL; 2068 CXFA_PDFFontMgr* pMgr = NULL;
2063 m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr); 2069 m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr);
2064 delete pMgr; 2070 delete pMgr;
2065 } 2071 }
2066 m_PDFFontMgrArray.RemoveAll(); 2072 m_PDFFontMgrArray.RemoveAll();
2067 m_FontMap.clear(); 2073 m_FontMap.clear();
2068 } 2074 }
2069 void CXFA_FontMgr::SetDefFontMgr(CXFA_DefFontMgr* pFontMgr) { 2075 void CXFA_FontMgr::SetDefFontMgr(CXFA_DefFontMgr* pFontMgr) {
2070 m_pDefFontMgr = pFontMgr; 2076 m_pDefFontMgr = pFontMgr;
2071 } 2077 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffapp.cpp ('k') | xfa/fxfa/include/xfa_checksum.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698