Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1614)

Side by Side Diff: xfa/src/fgas/font/fgas_font.h

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fgas/crt/fgas_utils.cpp ('k') | xfa/src/fgas/font/fgas_fontutils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef XFA_SRC_FGAS_FONT_FGAS_FONT_H_
8 #define XFA_SRC_FGAS_FONT_FGAS_FONT_H_
9
10 #include "core/include/fxge/fx_font.h"
11 #include "xfa/src/fgas/crt/fgas_stream.h"
12
13 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
14 #include "xfa/src/fgas/crt/fgas_memory.h"
15 #include "xfa/src/fgas/crt/fgas_utils.h"
16 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
17
18 class IFX_Font;
19 class IFX_FontMgr;
20
21 #define FX_FONTSTYLE_Normal 0x00
22 #define FX_FONTSTYLE_FixedPitch 0x01
23 #define FX_FONTSTYLE_Serif 0x02
24 #define FX_FONTSTYLE_Symbolic 0x04
25 #define FX_FONTSTYLE_Script 0x08
26 #define FX_FONTSTYLE_Italic 0x40
27 #define FX_FONTSTYLE_Bold 0x40000
28 #define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
29 #define FX_FONTSTYLE_ExactMatch 0x80000000
30 #define FX_FONTDECORATION_Underline 0x00000001
31 #define FX_FONTDECORATION_Strikeout 0x00000002
32 #define FX_FONTDECORATION_Overline 0x00000004
33 #define FX_FONTDECORATION_Emphasis 0x00000008
34 #define FX_FONTDECORATION_Superscript 0x00000010
35 #define FX_FONTDECORATION_Subscript 0x00000020
36 #define FX_FONTDECORATION_SmallCapital 0x00000040
37 #define FX_FONTDECORATION_Capital 0x00000080
38 #define FX_FONTDECORATION_Lowercase 0x000000C0
39 #define FX_FONTDECORATION_Raised 0x00000100
40 #define FX_FONTDECORATION_Sunken 0x00000200
41 #define FX_FONTDECORATION_Shadow 0x00000400
42 #define FX_FONTDECORATION_BoundingShape 0x20000000
43 #define FX_FONTDECORATION_Hide 0x40000000
44 #define FX_FONTDECORATION_StrokeFill 0x80000000
45 #define FX_BOUNDINGSHAPE_None 0
46 #define FX_BOUNDINGSHAPE_Circle 1
47 #define FX_BOUNDINGSHAPE_Square 2
48 #define FX_BOUNDINGSHAPE_Triangle 3
49 #define FX_BOUNDINGSHAPE_Diamond 4
50
51 class IFX_FontProvider {
52 public:
53 virtual ~IFX_FontProvider() {}
54 virtual FX_BOOL GetCharWidth(IFX_Font* pFont,
55 FX_WCHAR wUnicode,
56 int32_t& iWidth,
57 FX_BOOL bCharCode = FALSE) = 0;
58 };
59
60 class IFX_Font {
61 public:
62 static IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
63 FX_DWORD dwFontStyles,
64 FX_WORD wCodePage,
65 IFX_FontMgr* pFontMgr);
66 static IFX_Font* LoadFont(const uint8_t* pBuffer,
67 int32_t iLength,
68 IFX_FontMgr* pFontMgr);
69 static IFX_Font* LoadFont(const FX_WCHAR* pszFileName, IFX_FontMgr* pFontMgr);
70 static IFX_Font* LoadFont(IFX_Stream* pFontStream,
71 IFX_FontMgr* pFontMgr,
72 FX_BOOL bSaveStream = FALSE);
73 static IFX_Font* LoadFont(CFX_Font* pExtFont,
74 IFX_FontMgr* pFontMgr,
75 FX_BOOL bTakeOver = FALSE);
76 virtual ~IFX_Font() {}
77 virtual void Release() = 0;
78 virtual IFX_Font* Retain() = 0;
79 virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0) = 0;
80 virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0;
81 virtual void GetPsName(CFX_WideString& wsName) const = 0;
82 virtual FX_DWORD GetFontStyles() const = 0;
83 virtual uint8_t GetCharSet() const = 0;
84 virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
85 int32_t& iWidth,
86 FX_BOOL bCharCode = FALSE) = 0;
87 virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode,
88 FX_BOOL bCharCode = FALSE) = 0;
89 virtual int32_t GetAscent() const = 0;
90 virtual int32_t GetDescent() const = 0;
91 virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
92 CFX_Rect& bbox,
93 FX_BOOL bCharCode = FALSE) = 0;
94 virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0;
95 virtual int32_t GetItalicAngle() const = 0;
96 virtual void Reset() = 0;
97 virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const = 0;
98 virtual void* GetDevFont() const = 0;
99 virtual void SetFontProvider(IFX_FontProvider* pProvider) = 0;
100 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
101 virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) = 0;
102 #endif
103 };
104 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
105 struct FX_FONTMATCHPARAMS {
106 const FX_WCHAR* pwsFamily;
107 FX_DWORD dwFontStyles;
108 FX_DWORD dwUSB;
109 FX_DWORD dwMatchFlags;
110 FX_WCHAR wUnicode;
111 FX_WORD wCodePage;
112 };
113 typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS;
114 typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS;
115
116 struct FX_FONTSIGNATURE {
117 FX_DWORD fsUsb[4];
118 FX_DWORD fsCsb[2];
119 };
120 inline bool operator==(const FX_FONTSIGNATURE& left,
121 const FX_FONTSIGNATURE& right) {
122 return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
123 left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&
124 left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1];
125 }
126
127 struct FX_FONTDESCRIPTOR {
128 FX_WCHAR wsFontFace[32];
129 FX_DWORD dwFontStyles;
130 uint8_t uCharSet;
131 FX_FONTSIGNATURE FontSignature;
132 };
133 typedef FX_FONTDESCRIPTOR* FX_LPFONTDESCRIPTOR;
134 typedef FX_FONTDESCRIPTOR const* FX_LPCFONTDESCRIPTOR;
135 typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors;
136 inline bool operator==(const FX_FONTDESCRIPTOR& left,
137 const FX_FONTDESCRIPTOR& right) {
138 return left.uCharSet == right.uCharSet &&
139 left.dwFontStyles == right.dwFontStyles &&
140 left.FontSignature == right.FontSignature &&
141 FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0;
142 }
143
144 #define FX_FONTMATCHPARA_MacthStyle 0x01
145 #define FX_FONTMATCHPARA_MacthFamily 0x02
146 #define FX_FONTMATCHPARA_MacthUnicode 0x04
147 typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors& fonts,
148 void* pUserData,
149 const FX_WCHAR* pwsFaceName,
150 FX_WCHAR wUnicode);
151 FX_LPEnumAllFonts FX_GetDefFontEnumerator();
152 typedef FX_LPCFONTDESCRIPTOR (*FX_LPMatchFont)(FX_LPFONTMATCHPARAMS pParams,
153 const CFX_FontDescriptors& fonts,
154 void* pUserData);
155 FX_LPMatchFont FX_GetDefFontMatchor();
156 class IFX_FontMgr {
157 public:
158 static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator,
159 FX_LPMatchFont pMatcher = NULL,
160 void* pUserData = NULL);
161 virtual ~IFX_FontMgr() {}
162 virtual void Release() = 0;
163 virtual IFX_Font* GetDefFontByCodePage(
164 FX_WORD wCodePage,
165 FX_DWORD dwFontStyles,
166 const FX_WCHAR* pszFontFamily = NULL) = 0;
167 virtual IFX_Font* GetDefFontByCharset(
168 uint8_t nCharset,
169 FX_DWORD dwFontStyles,
170 const FX_WCHAR* pszFontFamily = NULL) = 0;
171 virtual IFX_Font* GetDefFontByUnicode(
172 FX_WCHAR wUnicode,
173 FX_DWORD dwFontStyles,
174 const FX_WCHAR* pszFontFamily = NULL) = 0;
175 virtual IFX_Font* GetDefFontByLanguage(
176 FX_WORD wLanguage,
177 FX_DWORD dwFontStyles,
178 const FX_WCHAR* pszFontFamily = NULL) = 0;
179 virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
180 FX_DWORD dwFontStyles,
181 FX_WORD wCodePage = 0xFFFF) = 0;
182 virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0;
183 virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName) = 0;
184 virtual IFX_Font* LoadFont(IFX_Stream* pFontStream,
185 const FX_WCHAR* pszFontAlias = NULL,
186 FX_DWORD dwFontStyles = 0,
187 FX_WORD wCodePage = 0,
188 FX_BOOL bSaveStream = FALSE) = 0;
189 virtual IFX_Font* LoadFont(IFX_Font* pSrcFont,
190 FX_DWORD dwFontStyles,
191 FX_WORD wCodePage = 0xFFFF) = 0;
192 virtual void ClearFontCache() = 0;
193 virtual void RemoveFont(IFX_Font* pFont) = 0;
194 };
195 #else
196 class IFX_FontMgrDelegate {
197 public:
198 virtual ~IFX_FontMgrDelegate() {}
199 virtual IFX_Font* GetDefFontByCodePage(
200 IFX_FontMgr* pFontMgr,
201 FX_WORD wCodePage,
202 FX_DWORD dwFontStyles,
203 const FX_WCHAR* pszFontFamily = NULL) = 0;
204 virtual IFX_Font* GetDefFontByCharset(
205 IFX_FontMgr* pFontMgr,
206 uint8_t nCharset,
207 FX_DWORD dwFontStyles,
208 const FX_WCHAR* pszFontFamily = NULL) = 0;
209 virtual IFX_Font* GetDefFontByUnicode(
210 IFX_FontMgr* pFontMgr,
211 FX_WCHAR wUnicode,
212 FX_DWORD dwFontStyles,
213 const FX_WCHAR* pszFontFamily = NULL) = 0;
214 virtual IFX_Font* GetDefFontByLanguage(
215 IFX_FontMgr* pFontMgr,
216 FX_WORD wLanguage,
217 FX_DWORD dwFontStyles,
218 const FX_WCHAR* pszFontFamily = NULL) = 0;
219 };
220 class IFX_FontSourceEnum {
221 public:
222 virtual ~IFX_FontSourceEnum() {}
223 virtual void Release() = 0;
224 virtual FX_POSITION GetStartPosition(void* pUserData = NULL) = 0;
225 virtual IFX_FileAccess* GetNext(FX_POSITION& pos, void* pUserData = NULL) = 0;
226 };
227 IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum();
228 class IFX_FontMgr {
229 public:
230 static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum,
231 IFX_FontMgrDelegate* pDelegate = NULL,
232 void* pUserData = NULL);
233 virtual ~IFX_FontMgr() {}
234 virtual void Release() = 0;
235 virtual IFX_Font* GetDefFontByCodePage(
236 FX_WORD wCodePage,
237 FX_DWORD dwFontStyles,
238 const FX_WCHAR* pszFontFamily = NULL) = 0;
239 virtual IFX_Font* GetDefFontByCharset(
240 uint8_t nCharset,
241 FX_DWORD dwFontStyles,
242 const FX_WCHAR* pszFontFamily = NULL) = 0;
243 virtual IFX_Font* GetDefFontByUnicode(
244 FX_WCHAR wUnicode,
245 FX_DWORD dwFontStyles,
246 const FX_WCHAR* pszFontFamily = NULL) = 0;
247 virtual IFX_Font* GetDefFontByLanguage(
248 FX_WORD wLanguage,
249 FX_DWORD dwFontStyles,
250 const FX_WCHAR* pszFontFamily = NULL) = 0;
251 virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage,
252 FX_DWORD dwFontStyles,
253 const FX_WCHAR* pszFontFamily = NULL) = 0;
254 inline IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
255 FX_DWORD dwFontStyles,
256 FX_WORD wCodePage) {
257 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
258 }
259 virtual IFX_Font* GetFontByCharset(uint8_t nCharset,
260 FX_DWORD dwFontStyles,
261 const FX_WCHAR* pszFontFamily = NULL) = 0;
262 virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode,
263 FX_DWORD dwFontStyles,
264 const FX_WCHAR* pszFontFamily = NULL) = 0;
265 virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage,
266 FX_DWORD dwFontStyles,
267 const FX_WCHAR* pszFontFamily = NULL) = 0;
268 virtual IFX_Font* LoadFont(const uint8_t* pBuffer,
269 int32_t iLength,
270 int32_t iFaceIndex,
271 int32_t* pFaceCount = NULL) = 0;
272 virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName,
273 int32_t iFaceIndex,
274 int32_t* pFaceCount = NULL) = 0;
275 virtual IFX_Font* LoadFont(IFX_Stream* pFontStream,
276 int32_t iFaceIndex,
277 int32_t* pFaceCount = NULL,
278 FX_BOOL bSaveStream = FALSE) = 0;
279
280 virtual void ClearFontCache() = 0;
281 virtual void RemoveFont(IFX_Font* pFont) = 0;
282 };
283 #endif
284
285 #endif // XFA_SRC_FGAS_FONT_FGAS_FONT_H_
OLDNEW
« no previous file with comments | « xfa/src/fgas/crt/fgas_utils.cpp ('k') | xfa/src/fgas/font/fgas_fontutils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698