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

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

Issue 2524493002: Clean up CFGAS_GEFont (Closed)
Patch Set: Rebase? Created 4 years 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/fgas/font/cfgas_gefont.cpp ('k') | 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
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef XFA_FGAS_FONT_FGAS_GEFONT_H_
8 #define XFA_FGAS_FONT_FGAS_GEFONT_H_
9
10 #include <map>
11 #include <memory>
12
13 #include "core/fxcrt/fx_memory.h"
14 #include "xfa/fgas/crt/fgas_utils.h"
15 #include "xfa/fgas/font/cfgas_fontmgr.h"
16
17 #define FXFONT_SUBST_ITALIC 0x02
18
19 class CFX_UnicodeEncoding;
20 class CXFA_PDFFontMgr;
21
22 class CFGAS_GEFont {
23 public:
24 static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
25 uint32_t dwFontStyles,
26 uint16_t wCodePage,
27 CFGAS_FontMgr* pFontMgr);
28 static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont,
29 CFGAS_FontMgr* pFontMgr);
30 static CFGAS_GEFont* LoadFont(std::unique_ptr<CFX_Font> pInternalFont,
31 CFGAS_FontMgr* pFontMgr);
32 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
33 static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
34 int32_t iLength,
35 CFGAS_FontMgr* pFontMgr);
36 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
37 CFGAS_FontMgr* pFontMgr,
38 bool bSaveStream);
39 #endif
40
41 ~CFGAS_GEFont();
42
43 void Release();
44 CFGAS_GEFont* Retain();
45 CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0);
46 void GetFamilyName(CFX_WideString& wsFamily) const;
47 uint32_t GetFontStyles() const;
48 bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode);
49 int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false);
50 int32_t GetAscent() const;
51 int32_t GetDescent() const;
52 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false);
53 bool GetBBox(CFX_Rect& bbox);
54 int32_t GetItalicAngle() const;
55 void Reset();
56 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const;
57 CFX_Font* GetDevFont() const { return m_pFont; }
58 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; }
59 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
60 void SetLogicalFontStyle(uint32_t dwLogFontStyle) {
61 m_bUseLogFontStyle = true;
62 m_dwLogFontStyle = dwLogFontStyle;
63 }
64 #endif
65
66 protected:
67 explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr);
68 CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles);
69
70 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
71 bool LoadFontInternal(const FX_WCHAR* pszFontFamily,
72 uint32_t dwFontStyles,
73 uint16_t wCodePage);
74 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length);
75 bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream);
76 #endif
77 bool LoadFontInternal(CFX_Font* pExternalFont);
78 bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont);
79 bool InitFont();
80 bool GetCharBBoxInternal(FX_WCHAR wUnicode,
81 CFX_Rect& bbox,
82 bool bRecursive,
83 bool bCharCode = false);
84 bool GetCharWidthInternal(FX_WCHAR wUnicode,
85 int32_t& iWidth,
86 bool bRecursive,
87 bool bCharCode);
88 int32_t GetGlyphIndex(FX_WCHAR wUnicode,
89 bool bRecursive,
90 CFGAS_GEFont** ppFont,
91 bool bCharCode = false);
92
93 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
94 bool m_bUseLogFontStyle;
95 uint32_t m_dwLogFontStyle;
96 #endif
97 CFX_Font* m_pFont;
98 CFGAS_GEFont* const m_pSrcFont;
99 CFGAS_FontMgr* const m_pFontMgr;
100 int32_t m_iRefCount;
101 bool m_bExternalFont;
102 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream;
103 std::unique_ptr<IFX_SeekableReadStream,
104 ReleaseDeleter<IFX_SeekableReadStream>>
105 m_pFileRead;
106 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
107 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;
108 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray;
109 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap;
110 CXFA_PDFFontMgr* m_pProvider; // not owned.
111 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts;
112 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper;
113 };
114
115 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_
OLDNEW
« no previous file with comments | « xfa/fgas/font/cfgas_gefont.cpp ('k') | xfa/fgas/font/fgas_gefont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698