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

Side by Side Diff: xfa/fgas/font/fgas_gefont.h

Issue 2297303004: Fix leaked internal font (Closed)
Patch Set: address comments Created 4 years, 3 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 | « no previous file | xfa/fgas/font/fgas_gefont.cpp » ('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 #ifndef XFA_FGAS_FONT_FGAS_GEFONT_H_ 7 #ifndef XFA_FGAS_FONT_FGAS_GEFONT_H_
8 #define XFA_FGAS_FONT_FGAS_GEFONT_H_ 8 #define XFA_FGAS_FONT_FGAS_GEFONT_H_
9 9
10 #include <map> 10 #include <map>
11 11
12 #include "core/fxcrt/include/fx_memory.h" 12 #include "core/fxcrt/include/fx_memory.h"
13 #include "xfa/fgas/crt/fgas_utils.h" 13 #include "xfa/fgas/crt/fgas_utils.h"
14 #include "xfa/fgas/font/fgas_font.h" 14 #include "xfa/fgas/font/fgas_font.h"
15 15
16 #define FXFONT_SUBST_ITALIC 0x02 16 #define FXFONT_SUBST_ITALIC 0x02
17 17
18 class CFX_UnicodeEncoding; 18 class CFX_UnicodeEncoding;
19 class CXFA_PDFFontMgr; 19 class CXFA_PDFFontMgr;
20 20
21 class CFGAS_GEFont { 21 class CFGAS_GEFont {
22 public: 22 public:
23 static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, 23 static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
24 uint32_t dwFontStyles, 24 uint32_t dwFontStyles,
25 uint16_t wCodePage, 25 uint16_t wCodePage,
26 IFGAS_FontMgr* pFontMgr); 26 IFGAS_FontMgr* pFontMgr);
27 static CFGAS_GEFont* LoadFont(CFX_Font* pExtFont, IFGAS_FontMgr* pFontMgr); 27 static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont,
28 IFGAS_FontMgr* pFontMgr);
29 static CFGAS_GEFont* LoadFont(std::unique_ptr<CFX_Font> pInternalFont,
30 IFGAS_FontMgr* pFontMgr);
28 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 31 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
29 static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, 32 static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
30 int32_t iLength, 33 int32_t iLength,
31 IFGAS_FontMgr* pFontMgr); 34 IFGAS_FontMgr* pFontMgr);
32 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, 35 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
33 IFGAS_FontMgr* pFontMgr, 36 IFGAS_FontMgr* pFontMgr,
34 FX_BOOL bSaveStream); 37 FX_BOOL bSaveStream);
35 #endif 38 #endif
36 39
37 ~CFGAS_GEFont(); 40 ~CFGAS_GEFont();
(...skipping 29 matching lines...) Expand all
67 explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr); 70 explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr);
68 CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles); 71 CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles);
69 72
70 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 73 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
71 FX_BOOL LoadFontInternal(const FX_WCHAR* pszFontFamily, 74 FX_BOOL LoadFontInternal(const FX_WCHAR* pszFontFamily,
72 uint32_t dwFontStyles, 75 uint32_t dwFontStyles,
73 uint16_t wCodePage); 76 uint16_t wCodePage);
74 FX_BOOL LoadFontInternal(const uint8_t* pBuffer, int32_t length); 77 FX_BOOL LoadFontInternal(const uint8_t* pBuffer, int32_t length);
75 FX_BOOL LoadFontInternal(IFX_Stream* pFontStream, FX_BOOL bSaveStream); 78 FX_BOOL LoadFontInternal(IFX_Stream* pFontStream, FX_BOOL bSaveStream);
76 #endif 79 #endif
77 FX_BOOL LoadFontInternal(CFX_Font* pExtFont); 80 FX_BOOL LoadFontInternal(CFX_Font* pExternalFont);
81 FX_BOOL LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont);
78 FX_BOOL InitFont(); 82 FX_BOOL InitFont();
79 FX_BOOL GetCharBBoxInternal(FX_WCHAR wUnicode, 83 FX_BOOL GetCharBBoxInternal(FX_WCHAR wUnicode,
80 CFX_Rect& bbox, 84 CFX_Rect& bbox,
81 FX_BOOL bRecursive, 85 FX_BOOL bRecursive,
82 FX_BOOL bCharCode = FALSE); 86 FX_BOOL bCharCode = FALSE);
83 FX_BOOL GetCharWidthInternal(FX_WCHAR wUnicode, 87 FX_BOOL GetCharWidthInternal(FX_WCHAR wUnicode,
84 int32_t& iWidth, 88 int32_t& iWidth,
85 FX_BOOL bRecursive, 89 FX_BOOL bRecursive,
86 FX_BOOL bCharCode = FALSE); 90 FX_BOOL bCharCode = FALSE);
87 int32_t GetGlyphIndex(FX_WCHAR wUnicode, 91 int32_t GetGlyphIndex(FX_WCHAR wUnicode,
88 FX_BOOL bRecursive, 92 FX_BOOL bRecursive,
89 CFGAS_GEFont** ppFont, 93 CFGAS_GEFont** ppFont,
90 FX_BOOL bCharCode = FALSE); 94 FX_BOOL bCharCode = FALSE);
91 95
92 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 96 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
93 FX_BOOL m_bUseLogFontStyle; 97 FX_BOOL m_bUseLogFontStyle;
94 uint32_t m_dwLogFontStyle; 98 uint32_t m_dwLogFontStyle;
95 #endif 99 #endif
96 CFX_Font* m_pFont; 100 CFX_Font* m_pFont;
97 IFGAS_FontMgr* const m_pFontMgr; 101 IFGAS_FontMgr* const m_pFontMgr;
98 int32_t m_iRefCount; 102 int32_t m_iRefCount;
99 FX_BOOL m_bExtFont; 103 bool m_bExternalFont;
100 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream; 104 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream;
101 std::unique_ptr<IFX_FileRead, ReleaseDeleter<IFX_FileRead>> m_pFileRead; 105 std::unique_ptr<IFX_FileRead, ReleaseDeleter<IFX_FileRead>> m_pFileRead;
102 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; 106 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
103 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; 107 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;
104 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; 108 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray;
105 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; 109 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap;
106 CXFA_PDFFontMgr* m_pProvider; // not owned. 110 CXFA_PDFFontMgr* m_pProvider; // not owned.
107 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; 111 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts;
108 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; 112 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper;
109 }; 113 };
110 114
111 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ 115 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_
OLDNEW
« no previous file with comments | « no previous file | xfa/fgas/font/fgas_gefont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698