OLD | NEW |
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/fx_memory.h" | 12 #include "core/fxcrt/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/cfgas_fontmgr.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 CFGAS_FontMgr* pFontMgr); |
27 static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont, | 27 static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont, |
28 IFGAS_FontMgr* pFontMgr); | 28 CFGAS_FontMgr* pFontMgr); |
29 static CFGAS_GEFont* LoadFont(std::unique_ptr<CFX_Font> pInternalFont, | 29 static CFGAS_GEFont* LoadFont(std::unique_ptr<CFX_Font> pInternalFont, |
30 IFGAS_FontMgr* pFontMgr); | 30 CFGAS_FontMgr* pFontMgr); |
31 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 31 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
32 static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, | 32 static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, |
33 int32_t iLength, | 33 int32_t iLength, |
34 IFGAS_FontMgr* pFontMgr); | 34 CFGAS_FontMgr* pFontMgr); |
35 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, | 35 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
36 IFGAS_FontMgr* pFontMgr, | 36 CFGAS_FontMgr* pFontMgr, |
37 bool bSaveStream); | 37 bool bSaveStream); |
38 #endif | 38 #endif |
39 | 39 |
40 ~CFGAS_GEFont(); | 40 ~CFGAS_GEFont(); |
41 | 41 |
42 void Release(); | 42 void Release(); |
43 CFGAS_GEFont* Retain(); | 43 CFGAS_GEFont* Retain(); |
44 CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); | 44 CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); |
45 void GetFamilyName(CFX_WideString& wsFamily) const; | 45 void GetFamilyName(CFX_WideString& wsFamily) const; |
46 uint32_t GetFontStyles() const; | 46 uint32_t GetFontStyles() const; |
47 bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); | 47 bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); |
48 int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); | 48 int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); |
49 int32_t GetAscent() const; | 49 int32_t GetAscent() const; |
50 int32_t GetDescent() const; | 50 int32_t GetDescent() const; |
51 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); | 51 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); |
52 bool GetBBox(CFX_Rect& bbox); | 52 bool GetBBox(CFX_Rect& bbox); |
53 int32_t GetItalicAngle() const; | 53 int32_t GetItalicAngle() const; |
54 void Reset(); | 54 void Reset(); |
55 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; | 55 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; |
56 CFX_Font* GetDevFont() const { return m_pFont; } | 56 CFX_Font* GetDevFont() const { return m_pFont; } |
57 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } | 57 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } |
58 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 58 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
59 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { | 59 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { |
60 m_bUseLogFontStyle = true; | 60 m_bUseLogFontStyle = true; |
61 m_dwLogFontStyle = dwLogFontStyle; | 61 m_dwLogFontStyle = dwLogFontStyle; |
62 } | 62 } |
63 #endif | 63 #endif |
64 | 64 |
65 protected: | 65 protected: |
66 explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr); | 66 explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); |
67 CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); | 67 CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); |
68 | 68 |
69 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 69 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
70 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, | 70 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, |
71 uint32_t dwFontStyles, | 71 uint32_t dwFontStyles, |
72 uint16_t wCodePage); | 72 uint16_t wCodePage); |
73 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); | 73 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); |
74 bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream); | 74 bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream); |
75 #endif | 75 #endif |
76 bool LoadFontInternal(CFX_Font* pExternalFont); | 76 bool LoadFontInternal(CFX_Font* pExternalFont); |
(...skipping 11 matching lines...) Expand all Loading... |
88 bool bRecursive, | 88 bool bRecursive, |
89 CFGAS_GEFont** ppFont, | 89 CFGAS_GEFont** ppFont, |
90 bool bCharCode = false); | 90 bool bCharCode = false); |
91 | 91 |
92 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 92 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
93 bool m_bUseLogFontStyle; | 93 bool m_bUseLogFontStyle; |
94 uint32_t m_dwLogFontStyle; | 94 uint32_t m_dwLogFontStyle; |
95 #endif | 95 #endif |
96 CFX_Font* m_pFont; | 96 CFX_Font* m_pFont; |
97 CFGAS_GEFont* const m_pSrcFont; | 97 CFGAS_GEFont* const m_pSrcFont; |
98 IFGAS_FontMgr* const m_pFontMgr; | 98 CFGAS_FontMgr* const m_pFontMgr; |
99 int32_t m_iRefCount; | 99 int32_t m_iRefCount; |
100 bool m_bExternalFont; | 100 bool m_bExternalFont; |
101 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream; | 101 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream; |
102 std::unique_ptr<IFX_SeekableReadStream, | 102 std::unique_ptr<IFX_SeekableReadStream, |
103 ReleaseDeleter<IFX_SeekableReadStream>> | 103 ReleaseDeleter<IFX_SeekableReadStream>> |
104 m_pFileRead; | 104 m_pFileRead; |
105 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; | 105 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; |
106 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; | 106 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; |
107 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; | 107 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; |
108 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; | 108 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; |
109 CXFA_PDFFontMgr* m_pProvider; // not owned. | 109 CXFA_PDFFontMgr* m_pProvider; // not owned. |
110 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; | 110 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; |
111 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; | 111 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; |
112 }; | 112 }; |
113 | 113 |
114 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ | 114 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ |
OLD | NEW |