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

Side by Side Diff: xfa/fxfa/xfa_fontmgr.h

Issue 2609423003: Properly ref-count CFGAS_GEFont with CFX_RetainPtr. (Closed)
Patch Set: comments Created 3 years, 11 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
« xfa/fgas/font/cfgas_fontmgr.h ('K') | « xfa/fxfa/fxfa_widget.h ('k') | no next file » | 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 #ifndef XFA_FXFA_XFA_FONTMGR_H_ 7 #ifndef XFA_FXFA_XFA_FONTMGR_H_
8 #define XFA_FXFA_XFA_FONTMGR_H_ 8 #define XFA_FXFA_XFA_FONTMGR_H_
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <vector>
12 13
14 #include "core/fxcrt/cfx_retain_ptr.h"
13 #include "core/fxcrt/fx_ext.h" 15 #include "core/fxcrt/fx_ext.h"
14 #include "core/fxcrt/fx_system.h" 16 #include "core/fxcrt/fx_system.h"
15 #include "xfa/fgas/font/cfgas_fontmgr.h" 17 #include "xfa/fgas/font/cfgas_fontmgr.h"
16 #include "xfa/fxfa/fxfa.h" 18 #include "xfa/fxfa/fxfa.h"
17 19
18 class CPDF_Font; 20 class CPDF_Font;
19 21
20 struct XFA_FONTINFO { 22 struct XFA_FONTINFO {
21 uint32_t dwFontNameHash; 23 uint32_t dwFontNameHash;
22 const FX_WCHAR* pPsName; 24 const FX_WCHAR* pPsName;
23 const FX_WCHAR* pReplaceFont; 25 const FX_WCHAR* pReplaceFont;
24 uint16_t dwStyles; 26 uint16_t dwStyles;
25 uint16_t wCodePage; 27 uint16_t wCodePage;
26 }; 28 };
27 29
28 class CXFA_DefFontMgr { 30 class CXFA_DefFontMgr {
29 public: 31 public:
30 CXFA_DefFontMgr(); 32 CXFA_DefFontMgr();
31 ~CXFA_DefFontMgr(); 33 ~CXFA_DefFontMgr();
32 34
33 CFGAS_GEFont* GetFont(CXFA_FFDoc* hDoc, 35 CFX_RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* hDoc,
34 const CFX_WideStringC& wsFontFamily, 36 const CFX_WideStringC& wsFontFamily,
35 uint32_t dwFontStyles, 37 uint32_t dwFontStyles,
36 uint16_t wCodePage = 0xFFFF); 38 uint16_t wCodePage = 0xFFFF);
37 CFGAS_GEFont* GetDefaultFont(CXFA_FFDoc* hDoc, 39 CFX_RetainPtr<CFGAS_GEFont> GetDefaultFont(
38 const CFX_WideStringC& wsFontFamily, 40 CXFA_FFDoc* hDoc,
39 uint32_t dwFontStyles, 41 const CFX_WideStringC& wsFontFamily,
40 uint16_t wCodePage = 0xFFFF); 42 uint32_t dwFontStyles,
43 uint16_t wCodePage = 0xFFFF);
41 44
42 protected: 45 protected:
43 CFX_ArrayTemplate<CFGAS_GEFont*> m_CacheFonts; 46 std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_CacheFonts;
44 }; 47 };
45 48
46 class CXFA_PDFFontMgr { 49 class CXFA_PDFFontMgr {
47 public: 50 public:
48 explicit CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); 51 explicit CXFA_PDFFontMgr(CXFA_FFDoc* pDoc);
49 ~CXFA_PDFFontMgr(); 52 ~CXFA_PDFFontMgr();
50 53
51 CFGAS_GEFont* GetFont(const CFX_WideStringC& wsFontFamily, 54 CFX_RetainPtr<CFGAS_GEFont> GetFont(const CFX_WideStringC& wsFontFamily,
52 uint32_t dwFontStyles, 55 uint32_t dwFontStyles,
53 CPDF_Font** pPDFFont, 56 CPDF_Font** pPDFFont,
54 bool bStrictMatch); 57 bool bStrictMatch);
55 bool GetCharWidth(const CFGAS_GEFont* pFont, 58 bool GetCharWidth(const CFX_RetainPtr<CFGAS_GEFont>& pFont,
56 FX_WCHAR wUnicode, 59 FX_WCHAR wUnicode,
57 bool bCharCode, 60 bool bCharCode,
58 int32_t* pWidth); 61 int32_t* pWidth);
59 void SetFont(const CFGAS_GEFont* pFont, CPDF_Font* pPDFFont); 62 void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont, CPDF_Font* pPDFFont);
60 63
61 protected: 64 protected:
62 CFGAS_GEFont* FindFont(const CFX_ByteString& strFamilyName, 65 CFX_RetainPtr<CFGAS_GEFont> FindFont(const CFX_ByteString& strFamilyName,
63 bool bBold, 66 bool bBold,
64 bool bItalic, 67 bool bItalic,
65 CPDF_Font** pPDFFont, 68 CPDF_Font** pPDFFont,
66 bool bStrictMatch); 69 bool bStrictMatch);
67 CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, 70 CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName,
68 bool bBold, 71 bool bBold,
69 bool bItalic); 72 bool bItalic);
70 bool PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, 73 bool PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
71 bool bBold, 74 bool bBold,
72 bool bItalic, 75 bool bItalic,
73 const CFX_ByteString& bsDRFontName, 76 const CFX_ByteString& bsDRFontName,
74 bool bStrictMatch); 77 bool bStrictMatch);
75 78
76 CXFA_FFDoc* const m_pDoc; 79 CXFA_FFDoc* const m_pDoc;
77 std::map<const CFGAS_GEFont*, CPDF_Font*> m_FDE2PDFFont; 80 std::map<CFX_RetainPtr<CFGAS_GEFont>, CPDF_Font*> m_FDE2PDFFont;
78 std::map<CFX_ByteString, CFGAS_GEFont*> m_FontMap; 81 std::map<CFX_ByteString, CFX_RetainPtr<CFGAS_GEFont>> m_FontMap;
79 }; 82 };
80 83
81 class CXFA_FontMgr { 84 class CXFA_FontMgr {
82 public: 85 public:
83 CXFA_FontMgr(); 86 CXFA_FontMgr();
84 ~CXFA_FontMgr(); 87 ~CXFA_FontMgr();
85 88
86 CFGAS_GEFont* GetFont(CXFA_FFDoc* hDoc, 89 CFX_RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* hDoc,
87 const CFX_WideStringC& wsFontFamily, 90 const CFX_WideStringC& wsFontFamily,
88 uint32_t dwFontStyles, 91 uint32_t dwFontStyles,
89 uint16_t wCodePage = 0xFFFF); 92 uint16_t wCodePage = 0xFFFF);
90 void LoadDocFonts(CXFA_FFDoc* hDoc); 93 void LoadDocFonts(CXFA_FFDoc* hDoc);
91 void ReleaseDocFonts(CXFA_FFDoc* hDoc); 94 void ReleaseDocFonts(CXFA_FFDoc* hDoc);
92 void SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr); 95 void SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr);
93 96
94 protected: 97 protected:
95 std::unique_ptr<CXFA_DefFontMgr> m_pDefFontMgr; 98 std::unique_ptr<CXFA_DefFontMgr> m_pDefFontMgr;
96 std::map<CXFA_FFDoc*, std::unique_ptr<CXFA_PDFFontMgr>> m_PDFFontMgrMap; 99 std::map<CXFA_FFDoc*, std::unique_ptr<CXFA_PDFFontMgr>> m_PDFFontMgrMap;
97 std::map<CFX_ByteString, CFGAS_GEFont*> m_FontMap; 100 std::map<CFX_ByteString, CFX_RetainPtr<CFGAS_GEFont>> m_FontMap;
98 }; 101 };
99 102
100 #endif // XFA_FXFA_XFA_FONTMGR_H_ 103 #endif // XFA_FXFA_XFA_FONTMGR_H_
OLDNEW
« xfa/fgas/font/cfgas_fontmgr.h ('K') | « xfa/fxfa/fxfa_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698