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> |
(...skipping 16 matching lines...) Expand all Loading... |
27 static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont, | 27 static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont, |
28 IFGAS_FontMgr* pFontMgr); | 28 IFGAS_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 IFGAS_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 IFGAS_FontMgr* pFontMgr); |
35 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, | 35 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
36 IFGAS_FontMgr* pFontMgr, | 36 IFGAS_FontMgr* pFontMgr, |
37 FX_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 FX_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, FX_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 FX_BOOL GetCharBBox(FX_WCHAR wUnicode, | 51 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); |
52 CFX_Rect& bbox, | 52 bool GetBBox(CFX_Rect& bbox); |
53 FX_BOOL bCharCode = FALSE); | |
54 FX_BOOL GetBBox(CFX_Rect& bbox); | |
55 int32_t GetItalicAngle() const; | 53 int32_t GetItalicAngle() const; |
56 void Reset(); | 54 void Reset(); |
57 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; | 55 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; |
58 CFX_Font* GetDevFont() const { return m_pFont; } | 56 CFX_Font* GetDevFont() const { return m_pFont; } |
59 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } | 57 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } |
60 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 58 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
61 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { | 59 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { |
62 m_bUseLogFontStyle = TRUE; | 60 m_bUseLogFontStyle = true; |
63 m_dwLogFontStyle = dwLogFontStyle; | 61 m_dwLogFontStyle = dwLogFontStyle; |
64 } | 62 } |
65 #endif | 63 #endif |
66 | 64 |
67 protected: | 65 protected: |
68 explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr); | 66 explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr); |
69 CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); | 67 CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); |
70 | 68 |
71 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 69 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
72 FX_BOOL LoadFontInternal(const FX_WCHAR* pszFontFamily, | 70 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, |
73 uint32_t dwFontStyles, | 71 uint32_t dwFontStyles, |
74 uint16_t wCodePage); | 72 uint16_t wCodePage); |
75 FX_BOOL LoadFontInternal(const uint8_t* pBuffer, int32_t length); | 73 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); |
76 FX_BOOL LoadFontInternal(IFX_Stream* pFontStream, FX_BOOL bSaveStream); | 74 bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream); |
77 #endif | 75 #endif |
78 FX_BOOL LoadFontInternal(CFX_Font* pExternalFont); | 76 bool LoadFontInternal(CFX_Font* pExternalFont); |
79 FX_BOOL LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont); | 77 bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont); |
80 FX_BOOL InitFont(); | 78 bool InitFont(); |
81 FX_BOOL GetCharBBoxInternal(FX_WCHAR wUnicode, | 79 bool GetCharBBoxInternal(FX_WCHAR wUnicode, |
82 CFX_Rect& bbox, | 80 CFX_Rect& bbox, |
83 FX_BOOL bRecursive, | 81 bool bRecursive, |
84 FX_BOOL bCharCode = FALSE); | 82 bool bCharCode = false); |
85 FX_BOOL GetCharWidthInternal(FX_WCHAR wUnicode, | 83 bool GetCharWidthInternal(FX_WCHAR wUnicode, |
86 int32_t& iWidth, | 84 int32_t& iWidth, |
87 bool bRecursive, | 85 bool bRecursive, |
88 bool bCharCode); | 86 bool bCharCode); |
89 int32_t GetGlyphIndex(FX_WCHAR wUnicode, | 87 int32_t GetGlyphIndex(FX_WCHAR wUnicode, |
90 FX_BOOL bRecursive, | 88 bool bRecursive, |
91 CFGAS_GEFont** ppFont, | 89 CFGAS_GEFont** ppFont, |
92 FX_BOOL bCharCode = FALSE); | 90 bool bCharCode = false); |
93 | 91 |
94 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 92 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
95 FX_BOOL m_bUseLogFontStyle; | 93 bool m_bUseLogFontStyle; |
96 uint32_t m_dwLogFontStyle; | 94 uint32_t m_dwLogFontStyle; |
97 #endif | 95 #endif |
98 CFX_Font* m_pFont; | 96 CFX_Font* m_pFont; |
99 CFGAS_GEFont* const m_pSrcFont; | 97 CFGAS_GEFont* const m_pSrcFont; |
100 IFGAS_FontMgr* const m_pFontMgr; | 98 IFGAS_FontMgr* const m_pFontMgr; |
101 int32_t m_iRefCount; | 99 int32_t m_iRefCount; |
102 bool m_bExternalFont; | 100 bool m_bExternalFont; |
103 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream; | 101 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream; |
104 std::unique_ptr<IFX_SeekableReadStream, | 102 std::unique_ptr<IFX_SeekableReadStream, |
105 ReleaseDeleter<IFX_SeekableReadStream>> | 103 ReleaseDeleter<IFX_SeekableReadStream>> |
106 m_pFileRead; | 104 m_pFileRead; |
107 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; | 105 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; |
108 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; | 106 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; |
109 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; | 107 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; |
110 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; | 108 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; |
111 CXFA_PDFFontMgr* m_pProvider; // not owned. | 109 CXFA_PDFFontMgr* m_pProvider; // not owned. |
112 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; | 110 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; |
113 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; | 111 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; |
114 }; | 112 }; |
115 | 113 |
116 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ | 114 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ |
OLD | NEW |