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 "xfa/fgas/crt/fgas_utils.h" | 12 #include "xfa/fgas/crt/fgas_utils.h" |
13 #include "xfa/fgas/font/fgas_font.h" | 13 #include "xfa/fgas/font/fgas_font.h" |
14 | 14 |
15 #define FXFONT_SUBST_ITALIC 0x02 | 15 #define FXFONT_SUBST_ITALIC 0x02 |
16 | 16 |
17 class CXFA_PDFFontMgr; | 17 class CXFA_PDFFontMgr; |
18 | 18 |
19 class CFGAS_GEFont : public IFGAS_Font { | 19 class CFGAS_GEFont { |
20 public: | 20 public: |
21 CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles); | 21 static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
22 explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr); | 22 uint32_t dwFontStyles, |
| 23 uint16_t wCodePage, |
| 24 IFGAS_FontMgr* pFontMgr); |
| 25 static CFGAS_GEFont* LoadFont(CFX_Font* pExtFont, |
| 26 IFGAS_FontMgr* pFontMgr, |
| 27 FX_BOOL bTakeOver); |
| 28 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 29 static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, |
| 30 int32_t iLength, |
| 31 IFGAS_FontMgr* pFontMgr); |
| 32 static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName); |
| 33 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
| 34 IFGAS_FontMgr* pFontMgr, |
| 35 FX_BOOL bSaveStream); |
| 36 #endif |
| 37 |
23 ~CFGAS_GEFont(); | 38 ~CFGAS_GEFont(); |
24 | 39 |
25 // IFGAS_Font: | 40 void Release(); |
26 virtual void Release(); | 41 CFGAS_GEFont* Retain(); |
27 virtual IFGAS_Font* Retain(); | 42 CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); |
28 FX_BOOL LoadFont(const FX_WCHAR* pszFontFamily, | 43 void GetFamilyName(CFX_WideString& wsFamily) const; |
29 uint32_t dwFontStyles, | 44 uint32_t GetFontStyles() const; |
30 uint16_t wCodePage); | 45 uint8_t GetCharSet() const; |
31 FX_BOOL LoadFont(const uint8_t* pBuffer, int32_t length); | 46 FX_BOOL GetCharWidth(FX_WCHAR wUnicode, |
32 FX_BOOL LoadFont(const FX_WCHAR* pszFileName); | 47 int32_t& iWidth, |
33 FX_BOOL LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream); | 48 FX_BOOL bCharCode = FALSE); |
34 FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver = FALSE); | 49 int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE); |
35 virtual IFGAS_Font* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); | 50 int32_t GetAscent() const; |
36 virtual void GetFamilyName(CFX_WideString& wsFamily) const; | 51 int32_t GetDescent() const; |
37 virtual uint32_t GetFontStyles() const; | 52 FX_BOOL GetCharBBox(FX_WCHAR wUnicode, |
38 virtual uint8_t GetCharSet() const; | 53 CFX_Rect& bbox, |
39 virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, | 54 FX_BOOL bCharCode = FALSE); |
40 int32_t& iWidth, | 55 FX_BOOL GetBBox(CFX_Rect& bbox); |
41 FX_BOOL bCharCode = FALSE); | 56 int32_t GetItalicAngle() const; |
42 virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE); | 57 void Reset(); |
43 virtual int32_t GetAscent() const; | 58 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; |
44 virtual int32_t GetDescent() const; | 59 CFX_Font* GetDevFont() const { return m_pFont; } |
45 virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, | 60 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } |
46 CFX_Rect& bbox, | |
47 FX_BOOL bCharCode = FALSE); | |
48 virtual FX_BOOL GetBBox(CFX_Rect& bbox); | |
49 virtual int32_t GetItalicAngle() const; | |
50 virtual void Reset(); | |
51 virtual IFGAS_Font* GetSubstFont(int32_t iGlyphIndex) const; | |
52 virtual CFX_Font* GetDevFont() const { return m_pFont; } | |
53 virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) { | |
54 m_pProvider = pProvider; | |
55 } | |
56 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 61 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
57 virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) { | 62 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { |
58 m_bUseLogFontStyle = TRUE; | 63 m_bUseLogFontStyle = TRUE; |
59 m_dwLogFontStyle = dwLogFontStyle; | 64 m_dwLogFontStyle = dwLogFontStyle; |
60 } | 65 } |
61 #endif | 66 #endif |
62 | 67 |
63 protected: | 68 protected: |
| 69 explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr); |
| 70 CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles); |
| 71 |
| 72 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 73 FX_BOOL LoadFont(const FX_WCHAR* pszFontFamily, |
| 74 uint32_t dwFontStyles, |
| 75 uint16_t wCodePage); |
| 76 FX_BOOL LoadFont(const uint8_t* pBuffer, int32_t length); |
| 77 FX_BOOL LoadFontInternal(const FX_WCHAR* pszFileName); |
| 78 FX_BOOL LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream); |
| 79 #endif |
| 80 FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver); |
| 81 FX_BOOL InitFont(); |
| 82 FX_BOOL GetCharBBoxInternal(FX_WCHAR wUnicode, |
| 83 CFX_Rect& bbox, |
| 84 FX_BOOL bRecursive, |
| 85 FX_BOOL bCharCode = FALSE); |
| 86 FX_BOOL GetCharWidthInternal(FX_WCHAR wUnicode, |
| 87 int32_t& iWidth, |
| 88 FX_BOOL bRecursive, |
| 89 FX_BOOL bCharCode = FALSE); |
| 90 int32_t GetGlyphIndex(FX_WCHAR wUnicode, |
| 91 FX_BOOL bRecursive, |
| 92 CFGAS_GEFont** ppFont, |
| 93 FX_BOOL bCharCode = FALSE); |
| 94 |
64 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 95 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
65 FX_BOOL m_bUseLogFontStyle; | 96 FX_BOOL m_bUseLogFontStyle; |
66 uint32_t m_dwLogFontStyle; | 97 uint32_t m_dwLogFontStyle; |
67 #endif | 98 #endif |
68 CFX_Font* m_pFont; | 99 CFX_Font* m_pFont; |
69 IFGAS_FontMgr* m_pFontMgr; | 100 IFGAS_FontMgr* m_pFontMgr; |
70 int32_t m_iRefCount; | 101 int32_t m_iRefCount; |
71 FX_BOOL m_bExtFont; | 102 FX_BOOL m_bExtFont; |
72 IFX_Stream* m_pStream; | 103 IFX_Stream* m_pStream; |
73 IFX_FileRead* m_pFileRead; | 104 IFX_FileRead* m_pFileRead; |
74 CFX_UnicodeEncoding* m_pFontEncoding; | 105 CFX_UnicodeEncoding* m_pFontEncoding; |
75 CFX_WordDiscreteArray* m_pCharWidthMap; | 106 CFX_WordDiscreteArray* m_pCharWidthMap; |
76 CFX_MassArrayTemplate<CFX_Rect>* m_pRectArray; | 107 CFX_MassArrayTemplate<CFX_Rect>* m_pRectArray; |
77 CFX_MapPtrToPtr* m_pBBoxMap; | 108 CFX_MapPtrToPtr* m_pBBoxMap; |
78 CXFA_PDFFontMgr* m_pProvider; | 109 CXFA_PDFFontMgr* m_pProvider; |
79 uint16_t m_wCharSet; | 110 uint16_t m_wCharSet; |
80 CFX_ArrayTemplate<IFGAS_Font*> m_SubstFonts; | 111 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; |
81 std::map<FX_WCHAR, IFGAS_Font*> m_FontMapper; | 112 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; |
82 FX_BOOL InitFont(); | |
83 FX_BOOL GetCharBBox(FX_WCHAR wUnicode, | |
84 CFX_Rect& bbox, | |
85 FX_BOOL bRecursive, | |
86 FX_BOOL bCharCode = FALSE); | |
87 FX_BOOL GetCharWidth(FX_WCHAR wUnicode, | |
88 int32_t& iWidth, | |
89 FX_BOOL bRecursive, | |
90 FX_BOOL bCharCode = FALSE); | |
91 int32_t GetGlyphIndex(FX_WCHAR wUnicode, | |
92 FX_BOOL bRecursive, | |
93 IFGAS_Font** ppFont, | |
94 FX_BOOL bCharCode = FALSE); | |
95 }; | 113 }; |
96 | 114 |
97 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ | 115 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ |
OLD | NEW |