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 CFX_GEFont; | |
19 class CXFA_PDFFontMgr; | 20 class CXFA_PDFFontMgr; |
20 class IFX_Font; | |
21 class IFX_FontMgr; | 21 class IFX_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 IFX_Font { | |
54 public: | |
55 static IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, | |
56 uint32_t dwFontStyles, | |
57 uint16_t wCodePage, | |
58 IFX_FontMgr* pFontMgr); | |
59 static IFX_Font* LoadFont(const uint8_t* pBuffer, | |
60 int32_t iLength, | |
61 IFX_FontMgr* pFontMgr); | |
62 static IFX_Font* LoadFont(const FX_WCHAR* pszFileName, IFX_FontMgr* pFontMgr); | |
63 static IFX_Font* LoadFont(IFX_Stream* pFontStream, | |
64 IFX_FontMgr* pFontMgr, | |
65 FX_BOOL bSaveStream = FALSE); | |
66 static IFX_Font* LoadFont(CFX_Font* pExtFont, | |
67 IFX_FontMgr* pFontMgr, | |
68 FX_BOOL bTakeOver = FALSE); | |
69 virtual ~IFX_Font() {} | |
70 virtual void Release() = 0; | |
71 virtual IFX_Font* Retain() = 0; | |
72 virtual IFX_Font* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0) = 0; | |
73 virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0; | |
74 virtual uint32_t GetFontStyles() const = 0; | |
75 virtual uint8_t GetCharSet() const = 0; | |
76 virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, | |
77 int32_t& iWidth, | |
78 FX_BOOL bCharCode = FALSE) = 0; | |
79 virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, | |
80 FX_BOOL bCharCode = FALSE) = 0; | |
81 virtual int32_t GetAscent() const = 0; | |
82 virtual int32_t GetDescent() const = 0; | |
83 virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, | |
84 CFX_Rect& bbox, | |
85 FX_BOOL bCharCode = FALSE) = 0; | |
86 virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0; | |
87 virtual int32_t GetItalicAngle() const = 0; | |
88 virtual void Reset() = 0; | |
89 virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const = 0; | |
90 virtual void* GetDevFont() const = 0; | |
91 virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) = 0; | |
92 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | |
93 virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) = 0; | |
94 #endif | |
95 }; | |
96 | 32 |
97 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 33 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
98 struct FX_FONTMATCHPARAMS { | 34 struct FX_FONTMATCHPARAMS { |
99 const FX_WCHAR* pwsFamily; | 35 const FX_WCHAR* pwsFamily; |
100 uint32_t dwFontStyles; | 36 uint32_t dwFontStyles; |
101 uint32_t dwUSB; | 37 uint32_t dwUSB; |
102 uint32_t dwMatchFlags; | 38 uint32_t dwMatchFlags; |
103 FX_WCHAR wUnicode; | 39 FX_WCHAR wUnicode; |
104 uint16_t wCodePage; | 40 uint16_t wCodePage; |
105 }; | 41 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); | 78 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); |
143 typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)( | 79 typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)( |
144 FX_LPFONTMATCHPARAMS pParams, | 80 FX_LPFONTMATCHPARAMS pParams, |
145 const CFX_FontDescriptors& fonts); | 81 const CFX_FontDescriptors& fonts); |
146 FX_LPMatchFont FX_GetDefFontMatchor(); | 82 FX_LPMatchFont FX_GetDefFontMatchor(); |
147 class IFX_FontMgr { | 83 class IFX_FontMgr { |
148 public: | 84 public: |
149 static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator); | 85 static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator); |
150 virtual ~IFX_FontMgr() {} | 86 virtual ~IFX_FontMgr() {} |
151 virtual void Release() = 0; | 87 virtual void Release() = 0; |
152 virtual IFX_Font* GetDefFontByCodePage( | 88 virtual CFX_GEFont* GetDefFontByCodePage( |
153 uint16_t wCodePage, | 89 uint16_t wCodePage, |
154 uint32_t dwFontStyles, | 90 uint32_t dwFontStyles, |
155 const FX_WCHAR* pszFontFamily = NULL) = 0; | 91 const FX_WCHAR* pszFontFamily = NULL) = 0; |
156 virtual IFX_Font* GetDefFontByCharset( | 92 virtual CFX_GEFont* GetDefFontByCharset( |
157 uint8_t nCharset, | 93 uint8_t nCharset, |
158 uint32_t dwFontStyles, | 94 uint32_t dwFontStyles, |
159 const FX_WCHAR* pszFontFamily = NULL) = 0; | 95 const FX_WCHAR* pszFontFamily = NULL) = 0; |
160 virtual IFX_Font* GetDefFontByUnicode( | 96 virtual CFX_GEFont* GetDefFontByUnicode( |
161 FX_WCHAR wUnicode, | 97 FX_WCHAR wUnicode, |
162 uint32_t dwFontStyles, | 98 uint32_t dwFontStyles, |
163 const FX_WCHAR* pszFontFamily = NULL) = 0; | 99 const FX_WCHAR* pszFontFamily = NULL) = 0; |
164 virtual IFX_Font* GetDefFontByLanguage( | 100 virtual CFX_GEFont* GetDefFontByLanguage( |
165 uint16_t wLanguage, | 101 uint16_t wLanguage, |
166 uint32_t dwFontStyles, | 102 uint32_t dwFontStyles, |
167 const FX_WCHAR* pszFontFamily = NULL) = 0; | 103 const FX_WCHAR* pszFontFamily = NULL) = 0; |
168 virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, | 104 virtual CFX_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
169 uint32_t dwFontStyles, | 105 uint32_t dwFontStyles, |
170 uint16_t wCodePage = 0xFFFF) = 0; | 106 uint16_t wCodePage = 0xFFFF) = 0; |
171 virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; | 107 virtual CFX_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; |
172 virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName) = 0; | 108 virtual CFX_GEFont* LoadFont(const FX_WCHAR* pszFileName) = 0; |
173 virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, | 109 virtual CFX_GEFont* LoadFont(IFX_Stream* pFontStream, |
174 const FX_WCHAR* pszFontAlias = NULL, | 110 const FX_WCHAR* pszFontAlias = NULL, |
175 uint32_t dwFontStyles = 0, | 111 uint32_t dwFontStyles = 0, |
176 uint16_t wCodePage = 0, | 112 uint16_t wCodePage = 0, |
177 FX_BOOL bSaveStream = FALSE) = 0; | 113 FX_BOOL bSaveStream = FALSE) = 0; |
178 virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, | 114 virtual CFX_GEFont* LoadFont(CFX_GEFont* pSrcFont, |
179 uint32_t dwFontStyles, | 115 uint32_t dwFontStyles, |
180 uint16_t wCodePage = 0xFFFF) = 0; | 116 uint16_t wCodePage = 0xFFFF) = 0; |
181 virtual void ClearFontCache() = 0; | 117 virtual void ClearFontCache() = 0; |
182 virtual void RemoveFont(IFX_Font* pFont) = 0; | 118 virtual void RemoveFont(CFX_GEFont* pFont) = 0; |
183 }; | 119 }; |
184 | 120 |
185 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 121 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
186 | 122 |
187 class IFX_FontMgr { | 123 class IFX_FontMgr { |
188 public: | 124 public: |
189 static IFX_FontMgr* Create(CFX_FontSourceEnum_File* pFontEnum); | 125 static IFX_FontMgr* Create(CFX_FontSourceEnum_File* pFontEnum); |
190 virtual ~IFX_FontMgr() {} | 126 virtual ~IFX_FontMgr() {} |
191 virtual void Release() = 0; | 127 virtual void Release() = 0; |
192 virtual IFX_Font* GetDefFontByCodePage( | 128 virtual CFX_GEFont* GetDefFontByCodePage( |
dsinclair
2016/06/02 17:37:38
This version of the class looks very similar to th
Lei Zhang
2016/06/07 01:17:16
I have a follow up CL.
| |
193 uint16_t wCodePage, | 129 uint16_t wCodePage, |
194 uint32_t dwFontStyles, | 130 uint32_t dwFontStyles, |
195 const FX_WCHAR* pszFontFamily = NULL) = 0; | 131 const FX_WCHAR* pszFontFamily = NULL) = 0; |
196 virtual IFX_Font* GetDefFontByCharset( | 132 virtual CFX_GEFont* GetDefFontByCharset( |
197 uint8_t nCharset, | 133 uint8_t nCharset, |
198 uint32_t dwFontStyles, | 134 uint32_t dwFontStyles, |
199 const FX_WCHAR* pszFontFamily = NULL) = 0; | 135 const FX_WCHAR* pszFontFamily = NULL) = 0; |
200 virtual IFX_Font* GetDefFontByUnicode( | 136 virtual CFX_GEFont* GetDefFontByUnicode( |
201 FX_WCHAR wUnicode, | 137 FX_WCHAR wUnicode, |
202 uint32_t dwFontStyles, | 138 uint32_t dwFontStyles, |
203 const FX_WCHAR* pszFontFamily = NULL) = 0; | 139 const FX_WCHAR* pszFontFamily = NULL) = 0; |
204 virtual IFX_Font* GetDefFontByLanguage( | 140 virtual CFX_GEFont* GetDefFontByLanguage( |
205 uint16_t wLanguage, | 141 uint16_t wLanguage, |
206 uint32_t dwFontStyles, | 142 uint32_t dwFontStyles, |
207 const FX_WCHAR* pszFontFamily = NULL) = 0; | 143 const FX_WCHAR* pszFontFamily = NULL) = 0; |
208 virtual IFX_Font* GetFontByCodePage(uint16_t wCodePage, | 144 virtual CFX_GEFont* GetFontByCodePage( |
209 uint32_t dwFontStyles, | 145 uint16_t wCodePage, |
210 const FX_WCHAR* pszFontFamily = NULL) = 0; | 146 uint32_t dwFontStyles, |
211 inline IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, | 147 const FX_WCHAR* pszFontFamily = NULL) = 0; |
212 uint32_t dwFontStyles, | 148 inline CFX_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
213 uint16_t wCodePage) { | 149 uint32_t dwFontStyles, |
150 uint16_t wCodePage) { | |
214 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); | 151 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); |
215 } | 152 } |
216 virtual IFX_Font* GetFontByCharset(uint8_t nCharset, | 153 virtual CFX_GEFont* GetFontByCharset( |
217 uint32_t dwFontStyles, | 154 uint8_t nCharset, |
218 const FX_WCHAR* pszFontFamily = NULL) = 0; | 155 uint32_t dwFontStyles, |
219 virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode, | 156 const FX_WCHAR* pszFontFamily = NULL) = 0; |
220 uint32_t dwFontStyles, | 157 virtual CFX_GEFont* GetFontByUnicode( |
221 const FX_WCHAR* pszFontFamily = NULL) = 0; | 158 FX_WCHAR wUnicode, |
222 virtual IFX_Font* GetFontByLanguage(uint16_t wLanguage, | 159 uint32_t dwFontStyles, |
223 uint32_t dwFontStyles, | 160 const FX_WCHAR* pszFontFamily = NULL) = 0; |
224 const FX_WCHAR* pszFontFamily = NULL) = 0; | 161 virtual CFX_GEFont* GetFontByLanguage( |
225 virtual IFX_Font* LoadFont(const uint8_t* pBuffer, | 162 uint16_t wLanguage, |
226 int32_t iLength, | 163 uint32_t dwFontStyles, |
227 int32_t iFaceIndex, | 164 const FX_WCHAR* pszFontFamily = NULL) = 0; |
228 int32_t* pFaceCount = NULL) = 0; | 165 virtual CFX_GEFont* LoadFont(const uint8_t* pBuffer, |
229 virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName, | 166 int32_t iLength, |
230 int32_t iFaceIndex, | 167 int32_t iFaceIndex, |
231 int32_t* pFaceCount = NULL) = 0; | 168 int32_t* pFaceCount = NULL) = 0; |
232 virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, | 169 virtual CFX_GEFont* LoadFont(const FX_WCHAR* pszFileName, |
233 int32_t iFaceIndex, | 170 int32_t iFaceIndex, |
234 int32_t* pFaceCount = NULL, | 171 int32_t* pFaceCount = NULL) = 0; |
235 FX_BOOL bSaveStream = FALSE) = 0; | 172 virtual CFX_GEFont* LoadFont(IFX_Stream* pFontStream, |
173 int32_t iFaceIndex, | |
174 int32_t* pFaceCount = NULL, | |
175 FX_BOOL bSaveStream = FALSE) = 0; | |
236 | 176 |
237 virtual void ClearFontCache() = 0; | 177 virtual void ClearFontCache() = 0; |
238 virtual void RemoveFont(IFX_Font* pFont) = 0; | 178 virtual void RemoveFont(CFX_GEFont* pFont) = 0; |
239 }; | 179 }; |
240 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 180 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
241 | 181 |
242 #endif // XFA_FGAS_FONT_FGAS_FONT_H_ | 182 #endif // XFA_FGAS_FONT_FGAS_FONT_H_ |
OLD | NEW |