From 5b4930967676088f2f0e5ce3b25aed77831d678c Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 29 Sep 2016 20:20:24 -0700 Subject: Move xfa/fxfa/include to xfa/fxfa BUG=pdfium:611 Review-Url: https://codereview.chromium.org/2383593002 --- xfa/fxfa/xfa_fontmgr.h | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 xfa/fxfa/xfa_fontmgr.h (limited to 'xfa/fxfa/xfa_fontmgr.h') diff --git a/xfa/fxfa/xfa_fontmgr.h b/xfa/fxfa/xfa_fontmgr.h new file mode 100644 index 0000000000..8838bbcd0c --- /dev/null +++ b/xfa/fxfa/xfa_fontmgr.h @@ -0,0 +1,100 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_XFA_FONTMGR_H_ +#define XFA_FXFA_XFA_FONTMGR_H_ + +#include +#include + +#include "core/fxcrt/fx_ext.h" +#include "core/fxcrt/fx_system.h" +#include "xfa/fgas/font/fgas_font.h" +#include "xfa/fxfa/fxfa.h" + +class CPDF_Font; + +struct XFA_FONTINFO { + uint32_t dwFontNameHash; + const FX_WCHAR* pPsName; + const FX_WCHAR* pReplaceFont; + uint16_t dwStyles; + uint16_t wCodePage; +}; + +class CXFA_DefFontMgr { + public: + CXFA_DefFontMgr(); + ~CXFA_DefFontMgr(); + + CFGAS_GEFont* GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + CFGAS_GEFont* GetDefaultFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + + protected: + CFX_ArrayTemplate m_CacheFonts; +}; + +class CXFA_PDFFontMgr { + public: + explicit CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); + ~CXFA_PDFFontMgr(); + + CFGAS_GEFont* GetFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + CPDF_Font** pPDFFont, + bool bStrictMatch); + bool GetCharWidth(const CFGAS_GEFont* pFont, + FX_WCHAR wUnicode, + bool bCharCode, + int32_t* pWidth); + void SetFont(const CFGAS_GEFont* pFont, CPDF_Font* pPDFFont); + + protected: + CFGAS_GEFont* FindFont(const CFX_ByteString& strFamilyName, + bool bBold, + bool bItalic, + CPDF_Font** pPDFFont, + bool bStrictMatch); + CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, + bool bBold, + bool bItalic); + bool PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, + bool bBold, + bool bItalic, + const CFX_ByteString& bsDRFontName, + bool bStrictMatch); + + CXFA_FFDoc* const m_pDoc; + std::map m_FDE2PDFFont; + std::map m_FontMap; +}; + +class CXFA_FontMgr { + public: + CXFA_FontMgr(); + ~CXFA_FontMgr(); + + CFGAS_GEFont* GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + void LoadDocFonts(CXFA_FFDoc* hDoc); + void ReleaseDocFonts(CXFA_FFDoc* hDoc); + void SetDefFontMgr(std::unique_ptr pFontMgr); + + protected: + std::unique_ptr m_pDefFontMgr; + std::map> m_PDFFontMgrMap; + std::map m_FontMap; +}; + +#endif // XFA_FXFA_XFA_FONTMGR_H_ -- cgit v1.2.3