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