- Make most of the the video stack compile with msvc
[reactos.git] / reactos / drivers / video / font / bmfd / bmfd.h
1 /*
2 * PROJECT: ReactOS win32 subsystem
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: GDI font driver for bitmap fonts
5 * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
6 */
7
8 #include <stdarg.h>
9 #include <windef.h>
10 #include <wingdi.h>
11 #include <winddi.h>
12
13 #if defined(_M_IX86) || defined(_M_AMD64)
14 /* on x86 and x64, unaligned access is allowed, byteorder is LE */
15 #define GETVAL(x) (x)
16 #else
17 // FIXME: BE
18 #define GETVAL(x) \
19 sizeof(x) == 1 ? (x) : \
20 sizeof(x) == 2 ? (((PCHAR)&(x))[0] + (((PCHAR)&(x))[1] << 8)) : \
21 (((PCHAR)&(x))[0] + (((PCHAR)&(x))[1] << 8) + (((PCHAR)&(x))[2] << 16) + \
22 (((PCHAR)&(x))[3] << 24))
23
24 #endif
25
26 #define FDM_MASK \
27 FDM_TYPE_CONST_BEARINGS | FDM_TYPE_ZERO_BEARINGS | \
28 FDM_TYPE_CHAR_INC_EQUAL_BM_BASE | FDM_TYPE_MAXEXT_EQUAL_BM_SIDE | \
29 FDM_TYPE_BM_SIDE_CONST
30
31 #define FM_INFO_MASK \
32 FM_INFO_TECH_BITMAP | FM_INFO_1BPP | FM_INFO_INTEGER_WIDTH | \
33 FM_INFO_RETURNS_BITMAPS | FM_INFO_RIGHT_HANDED | FM_INFO_INTEGRAL_SCALING |\
34 FM_INFO_90DEGREE_ROTATIONS | FM_INFO_OPTICALLY_FIXED_PITCH | FM_INFO_NONNEGATIVE_AC
35
36 #define FLOATL_1 0x3f800000
37
38 #define TAG_PDEV 'veDP'
39 #define TAG_GLYPHSET 'GlSt'
40 #define TAG_IFIMETRICS 'Ifim'
41 #define TAG_FONTINFO 'Font'
42
43
44 /** FON / FNT specific types **************************************************/
45
46 #define IMAGE_DOS_MAGIC 0x594D // FIXME: hack hack hack
47
48 #include <pshpack1.h>
49 typedef struct
50 {
51 WORD offset;
52 WORD length;
53 WORD flags;
54 WORD id;
55 WORD handle;
56 WORD usage;
57 } NE_NAMEINFO, *PNE_NAMEINFO;
58
59 #define NE_RSCTYPE_FONT 0x8008
60 #define NE_RSCTYPE_FONTDIR 0x8007
61 typedef struct
62 {
63 WORD type_id;
64 WORD count;
65 DWORD resloader;
66 NE_NAMEINFO nameinfo[1];
67 } NE_TYPEINFO, *PNE_TYPEINFO;
68
69 typedef struct
70 {
71 WORD size_shift;
72 NE_TYPEINFO typeinfo[1];
73 } NE_RESTABLE, *PNE_RESTABLE;
74
75 // Values of dfFlags:
76 #define DFF_FIXED 0x0001
77 #define DFF_PROPORTIONAL 0x0002
78 #define DFF_ABCFIXED 0x0004
79 #define DFF_ABCPROPORTIONAL 0x0008
80 #define DFF_1COLOR 0x0010
81 #define DFF_16COLOR 0x0020
82 #define DFF_256COLOR 0x0040
83 #define DFF_RGBCOLOR 0x0080
84
85 // see http://msdn.microsoft.com/en-us/library/ms648014(VS.85).aspx
86 typedef struct _FONTDIRENTRY
87 {
88 WORD dfVersion;
89 DWORD dfSize;
90 char dfCopyright[60];
91 WORD dfType;
92 WORD dfPoints;
93 WORD dfVertRes;
94 WORD dfHorizRes;
95 WORD dfAscent;
96 WORD dfInternalLeading;
97 WORD dfExternalLeading;
98 BYTE dfItalic;
99 BYTE dfUnderline;
100 BYTE dfStrikeOut;
101 WORD dfWeight;
102 BYTE dfCharSet;
103 WORD dfPixWidth;
104 WORD dfPixHeight;
105 BYTE dfPitchAndFamily;
106 WORD dfAvgWidth;
107 WORD dfMaxWidth;
108 BYTE dfFirstChar;
109 BYTE dfLastChar;
110 BYTE dfDefaultChar;
111 BYTE dfBreakChar;
112 WORD dfWidthBytes;
113 DWORD dfDevice;
114 DWORD dfFace;
115 DWORD dfReserved;
116 char szDeviceName[1];
117 char szFaceName[1];
118 } FONTDIRENTRY, *PFONTDIRENTRY;
119
120 typedef struct _DIRENTRY
121 {
122 WORD fontOrdinal;
123 FONTDIRENTRY fde;
124 } DIRENTRY, *PDIRENTRY;
125
126 typedef struct _FONTGROUPHDR
127 {
128 WORD NumberOfFonts;
129 DIRENTRY ade[1];
130 } FONTGROUPHDR, *PFONTGROUPHDR;
131
132 typedef struct
133 {
134 WORD dfVersion;
135 DWORD dfSize;
136 CHAR dfCopyright[60];
137 WORD dfType;
138 WORD dfPoints;
139 WORD dfVertRes;
140 WORD dfHorizRes;
141 WORD dfAscent;
142 WORD dfInternalLeading;
143 WORD dfExternalLeading;
144 BYTE dfItalic;
145 BYTE dfUnderline;
146 BYTE dfStrikeOut;
147 WORD dfWeight;
148 BYTE dfCharSet;
149 WORD dfPixWidth;
150 WORD dfPixHeight;
151 BYTE dfPitchAndFamily;
152 WORD dfAvgWidth;
153 WORD dfMaxWidth;
154 BYTE dfFirstChar;
155 BYTE dfLastChar;
156 BYTE dfDefaultChar;
157 BYTE dfBreakChar;
158 WORD dfWidthBytes;
159 DWORD dfDevice;
160 DWORD dfFace;
161 DWORD dfBitsPointer;
162 DWORD dfBitsOffset;
163 BYTE dfReserved;
164 /* Version 3.00: */
165 DWORD dfFlags;
166 WORD dfAspace;
167 WORD dfBspace;
168 WORD dfCspace;
169 DWORD dfColorPointer;
170 DWORD dfReserved1[4];
171 BYTE dfCharTable[1];
172 } FONTINFO16, *LPFONTINFO16, *PFONTINFO16;
173
174 typedef struct
175 {
176 WORD geWidth;
177 WORD geOffset;
178 } GLYPHENTRY20, *PGLYPHENTRY20;
179
180 typedef struct
181 {
182 WORD geWidth;
183 DWORD geOffset;
184 } GLYPHENTRY30, *PGLYPHENTRY30;
185
186 typedef union
187 {
188 GLYPHENTRY20 ge20;
189 GLYPHENTRY30 ge30;
190 } GLYPHENTRY, *PGLYPHENTRY;
191
192 #include <poppack.h>
193
194
195 /** Driver specific types *****************************************************/
196
197 typedef enum
198 {
199 FONTTYPE_FON,
200 FONTTYPE_FNT,
201 } FONTTYPE;
202
203 typedef struct
204 {
205 PFONTDIRENTRY pFontDirEntry;
206 PFONTINFO16 pFontInfo;
207 PBYTE pCharTable;
208 ULONG cjEntrySize;
209 ULONG ulVersion;
210 PCHAR pszFaceName;
211 PCHAR pszCopyright;
212 ULONG cGlyphs;
213 CHAR chFirstChar;
214 CHAR chLastChar;
215 WCHAR wcFirstChar;
216 WCHAR wcLastChar;
217 WCHAR wcDefaultChar;
218 WCHAR wcBreakChar;
219 WORD wPixHeight;
220 WORD wPixWidth;
221 WORD wWidthBytes;
222 WORD wA;
223 WORD wB;
224 WORD wC;
225 WORD wAscent;
226 WORD wDescent;
227 FLONG flInfo;
228 } BMFD_FACE, *PBMFD_FACE;
229
230 typedef struct
231 {
232 PVOID pvView;
233 ULONG_PTR iFile;
234 PFONTGROUPHDR pFontDir;
235 FONTTYPE ulFontType;
236 ULONG cNumFaces;
237 BMFD_FACE aface[1];
238 } BMFD_FILE, *PBMFD_FILE;
239
240 typedef struct
241 {
242 FONTOBJ *pfo;
243 PBMFD_FACE pface;
244 ULONG xScale;
245 ULONG yScale;
246 ULONG ulAngle;
247 } BMFD_FONT, *PBMFD_FONT;
248
249 //"Bold Italic Underline Strikeout"
250 #define MAX_STYLESIZE 35
251 typedef struct
252 {
253 IFIMETRICS ifim;
254 BYTE ajCharSet[16];
255 WCHAR wszFamilyName[LF_FACESIZE];
256 WCHAR wszFaceName[LF_FACESIZE];
257 WCHAR wszStyleName[MAX_STYLESIZE];
258 } BMFD_IFIMETRICS, *PBMFD_IFIMETRICS;
259
260
261 /** Function prototypes *******************************************************/
262
263 ULONG
264 DbgPrint(IN PCHAR Format, IN ...);
265
266 FORCEINLINE
267 VOID
268 DbgBreakPoint(VOID)
269 {
270 #ifdef __GNUC__
271 asm volatile ("int $3");
272 #else
273 __asm int 3;
274 #endif
275 }
276
277 DHPDEV
278 APIENTRY
279 BmfdEnablePDEV(
280 IN DEVMODEW *pdm,
281 IN LPWSTR pwszLogAddress,
282 IN ULONG cPat,
283 OUT HSURF *phsurfPatterns,
284 IN ULONG cjCaps,
285 OUT ULONG *pdevcaps,
286 IN ULONG cjDevInfo,
287 OUT DEVINFO *pdi,
288 IN HDEV hdev,
289 IN LPWSTR pwszDeviceName,
290 IN HANDLE hDriver);
291
292 VOID
293 APIENTRY
294 BmfdCompletePDEV(
295 IN DHPDEV dhpdev,
296 IN HDEV hdev);
297
298 VOID
299 APIENTRY
300 BmfdDisablePDEV(
301 IN DHPDEV dhpdev);
302
303 ULONG_PTR
304 APIENTRY
305 BmfdLoadFontFile(
306 ULONG cFiles,
307 ULONG_PTR *piFile,
308 PVOID *ppvView,
309 ULONG *pcjView,
310 DESIGNVECTOR *pdv,
311 ULONG ulLangID,
312 ULONG ulFastCheckSum);
313
314 BOOL
315 APIENTRY
316 BmfdUnloadFontFile(
317 IN ULONG_PTR iFile);
318
319 LONG
320 APIENTRY
321 BmfdQueryFontFile(
322 ULONG_PTR iFile,
323 ULONG ulMode,
324 ULONG cjBuf,
325 ULONG *pulBuf);
326
327 LONG
328 APIENTRY
329 BmfdQueryFontCaps(
330 ULONG culCaps,
331 ULONG *pulCaps);
332
333 PVOID
334 APIENTRY
335 BmfdQueryFontTree(
336 DHPDEV dhpdev,
337 ULONG_PTR iFile,
338 ULONG iFace,
339 ULONG iMode,
340 ULONG_PTR *pid);
341
342 PIFIMETRICS
343 APIENTRY
344 BmfdQueryFont(
345 IN DHPDEV dhpdev,
346 IN ULONG_PTR iFile,
347 IN ULONG iFace,
348 IN ULONG_PTR *pid);
349
350 VOID
351 APIENTRY
352 BmfdFree(
353 PVOID pv,
354 ULONG_PTR id);
355
356 PFD_GLYPHATTR
357 APIENTRY
358 BmfdQueryGlyphAttrs(
359 FONTOBJ *pfo,
360 ULONG iMode);
361
362 LONG
363 APIENTRY
364 BmfdQueryFontData(
365 DHPDEV dhpdev,
366 FONTOBJ *pfo,
367 ULONG iMode,
368 HGLYPH hg,
369 OUT GLYPHDATA *pgd,
370 PVOID pv,
371 ULONG cjSize);
372
373 VOID
374 APIENTRY
375 BmfdDestroyFont(
376 IN FONTOBJ *pfo);
377