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_FONT_H_ | 7 #ifndef XFA_FGAS_FONT_FGAS_FONT_H_ |
8 #define XFA_FGAS_FONT_FGAS_FONT_H_ | 8 #define XFA_FGAS_FONT_FGAS_FONT_H_ |
9 | 9 |
10 #include "core/fxge/include/fx_font.h" | 10 #include "core/fxge/include/fx_font.h" |
11 #include "xfa/fgas/crt/fgas_stream.h" | 11 #include "xfa/fgas/crt/fgas_stream.h" |
12 | 12 |
13 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 13 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
14 #include "xfa/fgas/crt/fgas_memory.h" | 14 #include "xfa/fgas/crt/fgas_memory.h" |
15 #include "xfa/fgas/crt/fgas_utils.h" | 15 #include "xfa/fgas/crt/fgas_utils.h" |
16 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 16 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
17 | 17 |
18 class CFX_FontSourceEnum_File; | 18 class CFX_FontSourceEnum_File; |
| 19 class CFGAS_GEFont; |
19 class CXFA_PDFFontMgr; | 20 class CXFA_PDFFontMgr; |
20 class IFGAS_Font; | |
21 class IFGAS_FontMgr; | 21 class IFGAS_FontMgr; |
22 | 22 |
23 #define FX_FONTSTYLE_Normal 0x00 | 23 #define FX_FONTSTYLE_Normal 0x00 |
24 #define FX_FONTSTYLE_FixedPitch 0x01 | 24 #define FX_FONTSTYLE_FixedPitch 0x01 |
25 #define FX_FONTSTYLE_Serif 0x02 | 25 #define FX_FONTSTYLE_Serif 0x02 |
26 #define FX_FONTSTYLE_Symbolic 0x04 | 26 #define FX_FONTSTYLE_Symbolic 0x04 |
27 #define FX_FONTSTYLE_Script 0x08 | 27 #define FX_FONTSTYLE_Script 0x08 |
28 #define FX_FONTSTYLE_Italic 0x40 | 28 #define FX_FONTSTYLE_Italic 0x40 |
29 #define FX_FONTSTYLE_Bold 0x40000 | 29 #define FX_FONTSTYLE_Bold 0x40000 |
30 #define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic) | 30 #define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic) |
31 #define FX_FONTSTYLE_ExactMatch 0x80000000 | 31 #define FX_FONTSTYLE_ExactMatch 0x80000000 |
32 #define FX_FONTDECORATION_Underline 0x00000001 | |
33 #define FX_FONTDECORATION_Strikeout 0x00000002 | |
34 #define FX_FONTDECORATION_Overline 0x00000004 | |
35 #define FX_FONTDECORATION_Emphasis 0x00000008 | |
36 #define FX_FONTDECORATION_Superscript 0x00000010 | |
37 #define FX_FONTDECORATION_Subscript 0x00000020 | |
38 #define FX_FONTDECORATION_SmallCapital 0x00000040 | |
39 #define FX_FONTDECORATION_Capital 0x00000080 | |
40 #define FX_FONTDECORATION_Lowercase 0x000000C0 | |
41 #define FX_FONTDECORATION_Raised 0x00000100 | |
42 #define FX_FONTDECORATION_Sunken 0x00000200 | |
43 #define FX_FONTDECORATION_Shadow 0x00000400 | |
44 #define FX_FONTDECORATION_BoundingShape 0x20000000 | |
45 #define FX_FONTDECORATION_Hide 0x40000000 | |
46 #define FX_FONTDECORATION_StrokeFill 0x80000000 | |
47 #define FX_BOUNDINGSHAPE_None 0 | |
48 #define FX_BOUNDINGSHAPE_Circle 1 | |
49 #define FX_BOUNDINGSHAPE_Square 2 | |
50 #define FX_BOUNDINGSHAPE_Triangle 3 | |
51 #define FX_BOUNDINGSHAPE_Diamond 4 | |
52 | |
53 class IFGAS_Font { | |
54 public: | |
55 static IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily, | |
56 uint32_t dwFontStyles, | |
57 uint16_t wCodePage, | |
58 IFGAS_FontMgr* pFontMgr); | |
59 static IFGAS_Font* LoadFont(const uint8_t* pBuffer, | |
60 int32_t iLength, | |
61 IFGAS_FontMgr* pFontMgr); | |
62 static IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName, | |
63 IFGAS_FontMgr* pFontMgr); | |
64 static IFGAS_Font* LoadFont(IFX_Stream* pFontStream, | |
65 IFGAS_FontMgr* pFontMgr, | |
66 FX_BOOL bSaveStream = FALSE); | |
67 static IFGAS_Font* LoadFont(CFX_Font* pExtFont, | |
68 IFGAS_FontMgr* pFontMgr, | |
69 FX_BOOL bTakeOver = FALSE); | |
70 virtual ~IFGAS_Font() {} | |
71 virtual void Release() = 0; | |
72 virtual IFGAS_Font* Retain() = 0; | |
73 virtual IFGAS_Font* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0) = 0; | |
74 virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0; | |
75 virtual uint32_t GetFontStyles() const = 0; | |
76 virtual uint8_t GetCharSet() const = 0; | |
77 virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, | |
78 int32_t& iWidth, | |
79 FX_BOOL bCharCode = FALSE) = 0; | |
80 virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, | |
81 FX_BOOL bCharCode = FALSE) = 0; | |
82 virtual int32_t GetAscent() const = 0; | |
83 virtual int32_t GetDescent() const = 0; | |
84 virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, | |
85 CFX_Rect& bbox, | |
86 FX_BOOL bCharCode = FALSE) = 0; | |
87 virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0; | |
88 virtual int32_t GetItalicAngle() const = 0; | |
89 virtual void Reset() = 0; | |
90 virtual IFGAS_Font* GetSubstFont(int32_t iGlyphIndex) const = 0; | |
91 virtual CFX_Font* GetDevFont() const = 0; | |
92 virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) = 0; | |
93 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | |
94 virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) = 0; | |
95 #endif | |
96 }; | |
97 | 32 |
98 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 33 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
99 struct FX_FONTMATCHPARAMS { | 34 struct FX_FONTMATCHPARAMS { |
100 const FX_WCHAR* pwsFamily; | 35 const FX_WCHAR* pwsFamily; |
101 uint32_t dwFontStyles; | 36 uint32_t dwFontStyles; |
102 uint32_t dwUSB; | 37 uint32_t dwUSB; |
103 uint32_t dwMatchFlags; | 38 uint32_t dwMatchFlags; |
104 FX_WCHAR wUnicode; | 39 FX_WCHAR wUnicode; |
105 uint16_t wCodePage; | 40 uint16_t wCodePage; |
106 }; | 41 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); | 78 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); |
144 typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)( | 79 typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)( |
145 FX_LPFONTMATCHPARAMS pParams, | 80 FX_LPFONTMATCHPARAMS pParams, |
146 const CFX_FontDescriptors& fonts); | 81 const CFX_FontDescriptors& fonts); |
147 FX_LPMatchFont FX_GetDefFontMatchor(); | 82 FX_LPMatchFont FX_GetDefFontMatchor(); |
148 class IFGAS_FontMgr { | 83 class IFGAS_FontMgr { |
149 public: | 84 public: |
150 static IFGAS_FontMgr* Create(FX_LPEnumAllFonts pEnumerator); | 85 static IFGAS_FontMgr* Create(FX_LPEnumAllFonts pEnumerator); |
151 virtual ~IFGAS_FontMgr() {} | 86 virtual ~IFGAS_FontMgr() {} |
152 virtual void Release() = 0; | 87 virtual void Release() = 0; |
153 virtual IFGAS_Font* GetDefFontByCodePage( | 88 virtual CFGAS_GEFont* GetDefFontByCodePage( |
154 uint16_t wCodePage, | 89 uint16_t wCodePage, |
155 uint32_t dwFontStyles, | 90 uint32_t dwFontStyles, |
156 const FX_WCHAR* pszFontFamily = NULL) = 0; | 91 const FX_WCHAR* pszFontFamily = NULL) = 0; |
157 virtual IFGAS_Font* GetDefFontByCharset( | 92 virtual CFGAS_GEFont* GetDefFontByCharset( |
158 uint8_t nCharset, | 93 uint8_t nCharset, |
159 uint32_t dwFontStyles, | 94 uint32_t dwFontStyles, |
160 const FX_WCHAR* pszFontFamily = NULL) = 0; | 95 const FX_WCHAR* pszFontFamily = NULL) = 0; |
161 virtual IFGAS_Font* GetDefFontByUnicode( | 96 virtual CFGAS_GEFont* GetDefFontByUnicode( |
162 FX_WCHAR wUnicode, | 97 FX_WCHAR wUnicode, |
163 uint32_t dwFontStyles, | 98 uint32_t dwFontStyles, |
164 const FX_WCHAR* pszFontFamily = NULL) = 0; | 99 const FX_WCHAR* pszFontFamily = NULL) = 0; |
165 virtual IFGAS_Font* GetDefFontByLanguage( | 100 virtual CFGAS_GEFont* GetDefFontByLanguage( |
166 uint16_t wLanguage, | 101 uint16_t wLanguage, |
167 uint32_t dwFontStyles, | 102 uint32_t dwFontStyles, |
168 const FX_WCHAR* pszFontFamily = NULL) = 0; | 103 const FX_WCHAR* pszFontFamily = NULL) = 0; |
169 virtual IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily, | 104 virtual CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
170 uint32_t dwFontStyles, | 105 uint32_t dwFontStyles, |
171 uint16_t wCodePage = 0xFFFF) = 0; | 106 uint16_t wCodePage = 0xFFFF) = 0; |
172 virtual IFGAS_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; | 107 virtual CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; |
173 virtual IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName) = 0; | 108 virtual CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName) = 0; |
174 virtual IFGAS_Font* LoadFont(IFX_Stream* pFontStream, | 109 virtual CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
175 const FX_WCHAR* pszFontAlias = NULL, | 110 const FX_WCHAR* pszFontAlias = NULL, |
176 uint32_t dwFontStyles = 0, | 111 uint32_t dwFontStyles = 0, |
177 uint16_t wCodePage = 0, | 112 uint16_t wCodePage = 0, |
178 FX_BOOL bSaveStream = FALSE) = 0; | 113 FX_BOOL bSaveStream = FALSE) = 0; |
179 virtual IFGAS_Font* LoadFont(IFGAS_Font* pSrcFont, | 114 virtual CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont, |
180 uint32_t dwFontStyles, | 115 uint32_t dwFontStyles, |
181 uint16_t wCodePage = 0xFFFF) = 0; | 116 uint16_t wCodePage = 0xFFFF) = 0; |
182 virtual void ClearFontCache() = 0; | 117 virtual void ClearFontCache() = 0; |
183 virtual void RemoveFont(IFGAS_Font* pFont) = 0; | 118 virtual void RemoveFont(CFGAS_GEFont* pFont) = 0; |
184 }; | 119 }; |
185 | 120 |
186 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 121 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
187 | 122 |
188 class IFGAS_FontMgr { | 123 class IFGAS_FontMgr { |
189 public: | 124 public: |
190 static IFGAS_FontMgr* Create(CFX_FontSourceEnum_File* pFontEnum); | 125 static IFGAS_FontMgr* Create(CFX_FontSourceEnum_File* pFontEnum); |
191 virtual ~IFGAS_FontMgr() {} | 126 virtual ~IFGAS_FontMgr() {} |
192 virtual void Release() = 0; | 127 virtual void Release() = 0; |
193 virtual IFGAS_Font* GetDefFontByCodePage( | 128 virtual CFGAS_GEFont* GetDefFontByCodePage( |
194 uint16_t wCodePage, | 129 uint16_t wCodePage, |
195 uint32_t dwFontStyles, | 130 uint32_t dwFontStyles, |
196 const FX_WCHAR* pszFontFamily = NULL) = 0; | 131 const FX_WCHAR* pszFontFamily = NULL) = 0; |
197 virtual IFGAS_Font* GetDefFontByCharset( | 132 virtual CFGAS_GEFont* GetDefFontByCharset( |
198 uint8_t nCharset, | 133 uint8_t nCharset, |
199 uint32_t dwFontStyles, | 134 uint32_t dwFontStyles, |
200 const FX_WCHAR* pszFontFamily = NULL) = 0; | 135 const FX_WCHAR* pszFontFamily = NULL) = 0; |
201 virtual IFGAS_Font* GetDefFontByUnicode( | 136 virtual CFGAS_GEFont* GetDefFontByUnicode( |
202 FX_WCHAR wUnicode, | 137 FX_WCHAR wUnicode, |
203 uint32_t dwFontStyles, | 138 uint32_t dwFontStyles, |
204 const FX_WCHAR* pszFontFamily = NULL) = 0; | 139 const FX_WCHAR* pszFontFamily = NULL) = 0; |
205 virtual IFGAS_Font* GetDefFontByLanguage( | 140 virtual CFGAS_GEFont* GetDefFontByLanguage( |
206 uint16_t wLanguage, | 141 uint16_t wLanguage, |
207 uint32_t dwFontStyles, | 142 uint32_t dwFontStyles, |
208 const FX_WCHAR* pszFontFamily = NULL) = 0; | 143 const FX_WCHAR* pszFontFamily = NULL) = 0; |
209 virtual IFGAS_Font* GetFontByCodePage( | 144 virtual CFGAS_GEFont* GetFontByCodePage( |
210 uint16_t wCodePage, | 145 uint16_t wCodePage, |
211 uint32_t dwFontStyles, | 146 uint32_t dwFontStyles, |
212 const FX_WCHAR* pszFontFamily = NULL) = 0; | 147 const FX_WCHAR* pszFontFamily = NULL) = 0; |
213 inline IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily, | 148 inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
214 uint32_t dwFontStyles, | 149 uint32_t dwFontStyles, |
215 uint16_t wCodePage) { | 150 uint16_t wCodePage) { |
216 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); | 151 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); |
217 } | 152 } |
218 virtual IFGAS_Font* GetFontByCharset( | 153 virtual CFGAS_GEFont* GetFontByCharset( |
219 uint8_t nCharset, | 154 uint8_t nCharset, |
220 uint32_t dwFontStyles, | 155 uint32_t dwFontStyles, |
221 const FX_WCHAR* pszFontFamily = NULL) = 0; | 156 const FX_WCHAR* pszFontFamily = NULL) = 0; |
222 virtual IFGAS_Font* GetFontByUnicode( | 157 virtual CFGAS_GEFont* GetFontByUnicode( |
223 FX_WCHAR wUnicode, | 158 FX_WCHAR wUnicode, |
224 uint32_t dwFontStyles, | 159 uint32_t dwFontStyles, |
225 const FX_WCHAR* pszFontFamily = NULL) = 0; | 160 const FX_WCHAR* pszFontFamily = NULL) = 0; |
226 virtual IFGAS_Font* GetFontByLanguage( | 161 virtual CFGAS_GEFont* GetFontByLanguage( |
227 uint16_t wLanguage, | 162 uint16_t wLanguage, |
228 uint32_t dwFontStyles, | 163 uint32_t dwFontStyles, |
229 const FX_WCHAR* pszFontFamily = NULL) = 0; | 164 const FX_WCHAR* pszFontFamily = NULL) = 0; |
230 virtual IFGAS_Font* LoadFont(const uint8_t* pBuffer, | 165 virtual CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, |
231 int32_t iLength, | 166 int32_t iLength, |
232 int32_t iFaceIndex, | 167 int32_t iFaceIndex, |
233 int32_t* pFaceCount = NULL) = 0; | 168 int32_t* pFaceCount = NULL) = 0; |
234 virtual IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName, | 169 virtual CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName, |
235 int32_t iFaceIndex, | 170 int32_t iFaceIndex, |
236 int32_t* pFaceCount = NULL) = 0; | 171 int32_t* pFaceCount = NULL) = 0; |
237 virtual IFGAS_Font* LoadFont(IFX_Stream* pFontStream, | 172 virtual CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
238 int32_t iFaceIndex, | 173 int32_t iFaceIndex, |
239 int32_t* pFaceCount = NULL, | 174 int32_t* pFaceCount = NULL, |
240 FX_BOOL bSaveStream = FALSE) = 0; | 175 FX_BOOL bSaveStream = FALSE) = 0; |
241 | 176 |
242 virtual void ClearFontCache() = 0; | 177 virtual void ClearFontCache() = 0; |
243 virtual void RemoveFont(IFGAS_Font* pFont) = 0; | 178 virtual void RemoveFont(CFGAS_GEFont* pFont) = 0; |
244 }; | 179 }; |
245 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 180 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
246 | 181 |
247 #endif // XFA_FGAS_FONT_FGAS_FONT_H_ | 182 #endif // XFA_FGAS_FONT_FGAS_FONT_H_ |
OLD | NEW |