windowscodecs: Fix ICO palette size calculation.
[wine/multimedia.git] / dlls / wineps.drv / psdrv.h
blob854cdd284c5f3aba4d5e4d5246463a73679d115b
1 /*
2 * PostScript driver definitions
4 * Copyright 1998 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_PSDRV_H
22 #define __WINE_PSDRV_H
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winspool.h"
31 #include "wine/list.h"
33 typedef struct {
34 INT index;
35 LPCSTR sz;
36 } GLYPHNAME;
38 typedef struct {
39 LONG UV;
40 const GLYPHNAME *name;
41 } UNICODEGLYPH;
43 typedef struct {
44 float llx, lly, urx, ury;
45 } AFMBBOX;
47 typedef struct _tagAFMLIGS {
48 char *successor;
49 char *ligature;
50 struct _tagAFMLIGS *next;
51 } AFMLIGS;
53 typedef struct {
54 int C; /* character */
55 LONG UV;
56 float WX;
57 const GLYPHNAME *N; /* name */
58 AFMBBOX B;
59 const AFMLIGS *L; /* Ligatures */
60 } OLD_AFMMETRICS;
62 typedef struct {
63 INT C; /* AFM encoding (or -1) */
64 LONG UV; /* Unicode value */
65 FLOAT WX; /* Advance width */
66 const GLYPHNAME *N; /* Glyph name */
67 } AFMMETRICS;
69 typedef struct {
70 USHORT usUnitsPerEm; /* head:unitsPerEm */
71 SHORT sAscender; /* hhea:Ascender */
72 SHORT sDescender; /* hhea:Descender */
73 SHORT sLineGap; /* hhea:LineGap */
74 SHORT sAvgCharWidth; /* OS/2:xAvgCharWidth */
75 SHORT sTypoAscender; /* OS/2:sTypoAscender */
76 SHORT sTypoDescender; /* OS/2:sTypoDescender */
77 SHORT sTypoLineGap; /* OS/2:sTypeLineGap */
78 USHORT usWinAscent; /* OS/2:usWinAscent */
79 USHORT usWinDescent; /* OS/2:usWinDescent */
80 } WINMETRICS;
82 typedef struct _tagAFM {
83 LPCSTR FontName;
84 LPCSTR FullName;
85 LPCSTR FamilyName;
86 LPCSTR EncodingScheme;
87 LONG Weight; /* FW_NORMAL etc. */
88 float ItalicAngle;
89 BOOL IsFixedPitch;
90 float UnderlinePosition;
91 float UnderlineThickness;
92 AFMBBOX FontBBox;
93 float Ascender;
94 float Descender;
95 WINMETRICS WinMetrics;
96 int NumofMetrics;
97 const AFMMETRICS *Metrics;
98 } AFM;
100 /* Note no 'next' in AFM. Use AFMLISTENTRY as a container. This allow more than
101 one list to exist without having to reallocate the entire AFM structure. We
102 keep a global list of all afms (PSDRV_AFMFontList) plus a list of available
103 fonts for each DC (dc->physDev->Fonts) */
105 typedef struct _tagAFMLISTENTRY {
106 const AFM *afm;
107 struct _tagAFMLISTENTRY *next;
108 } AFMLISTENTRY;
110 typedef struct _tagFONTFAMILY {
111 char *FamilyName; /* family name */
112 AFMLISTENTRY *afmlist; /* list of afms for this family */
113 struct _tagFONTFAMILY *next; /* next family */
114 } FONTFAMILY;
116 extern FONTFAMILY *PSDRV_AFMFontList;
117 extern const AFM *const PSDRV_BuiltinAFMs[]; /* last element is NULL */
119 typedef struct _tagFONTNAME {
120 char *Name;
121 struct _tagFONTNAME *next;
122 } FONTNAME;
124 typedef struct {
125 float llx, lly, urx, ury;
126 } IMAGEABLEAREA;
128 typedef struct {
129 float x, y;
130 } PAPERDIMENSION;
132 /* Solaris kludge */
133 #undef PAGESIZE
134 typedef struct _tagPAGESIZE {
135 struct list entry;
136 char *Name;
137 char *FullName;
138 char *InvocationString;
139 IMAGEABLEAREA *ImageableArea;
140 PAPERDIMENSION *PaperDimension;
141 WORD WinPage; /*eg DMPAPER_A4. Doesn't really belong here */
142 } PAGESIZE;
145 /* For BANDINFO Escape */
146 typedef struct _BANDINFOSTRUCT
148 BOOL GraphicsFlag;
149 BOOL TextFlag;
150 RECT GraphicsRect;
151 } BANDINFOSTRUCT, *PBANDINFOSTRUCT;
153 typedef struct _tagOPTIONENTRY {
154 char *Name; /* eg "True" */
155 char *FullName; /* eg "Installed" */
156 char *InvocationString; /* Often NULL */
157 struct _tagOPTIONENTRY *next;
158 } OPTIONENTRY;
160 typedef struct _tagOPTION { /* Treat bool as a special case of pickone */
161 char *OptionName; /* eg "*Option1" */
162 char *FullName; /* eg "Envelope Feeder" */
163 char *DefaultOption; /* eg "False" */
164 OPTIONENTRY *Options;
165 struct _tagOPTION *next;
166 } OPTION;
168 typedef struct _tagCONSTRAINT {
169 char *Feature1;
170 char *Value1;
171 char *Feature2;
172 char *Value2;
173 struct _tagCONSTRAINT *next;
174 } CONSTRAINT;
176 typedef struct _tagINPUTSLOT {
177 const char *Name;
178 const char *FullName;
179 char *InvocationString;
180 WORD WinBin; /* eg DMBIN_LOWER */
181 struct _tagINPUTSLOT *next;
182 } INPUTSLOT;
184 typedef enum _RASTERIZEROPTION
185 {RO_None, RO_Accept68K, RO_Type42, RO_TrueImage} RASTERIZEROPTION;
187 typedef struct _tagDUPLEX {
188 char *Name;
189 char *FullName;
190 char *InvocationString;
191 WORD WinDuplex; /* eg DMDUP_SIMPLEX */
192 struct _tagDUPLEX *next;
193 } DUPLEX;
195 /* Many Mac OS X based ppd files don't include a *ColorDevice line, so
196 we use a tristate here rather than a boolean. Code that
197 cares is expected to treat these as if they were colour. */
198 typedef enum {
199 CD_NotSpecified,
200 CD_False,
201 CD_True
202 } COLORDEVICE;
204 typedef struct {
205 char *NickName;
206 int LanguageLevel;
207 COLORDEVICE ColorDevice;
208 int DefaultResolution;
209 signed int LandscapeOrientation;
210 char *JCLBegin;
211 char *JCLToPSInterpreter;
212 char *JCLEnd;
213 char *DefaultFont;
214 FONTNAME *InstalledFonts; /* ptr to a list of FontNames */
215 struct list PageSizes;
216 PAGESIZE *DefaultPageSize;
217 OPTION *InstalledOptions;
218 CONSTRAINT *Constraints;
219 INPUTSLOT *InputSlots;
220 RASTERIZEROPTION TTRasterizer;
221 DUPLEX *Duplexes;
222 DUPLEX *DefaultDuplex;
223 } PPD;
225 typedef struct {
226 DEVMODEA dmPublic;
227 struct _tagdocprivate {
228 int dummy;
229 } dmDocPrivate;
230 struct _tagdrvprivate {
231 UINT numInstalledOptions; /* Options at end of struct */
232 } dmDrvPrivate;
234 /* Now comes:
236 numInstalledOptions of OPTIONs
240 } PSDRV_DEVMODEA;
242 typedef struct _tagPI {
243 char *FriendlyName;
244 PPD *ppd;
245 PSDRV_DEVMODEA *Devmode;
246 FONTFAMILY *Fonts;
247 PPRINTER_ENUM_VALUESA FontSubTable;
248 DWORD FontSubTableSize;
249 struct _tagPI *next;
250 } PRINTERINFO;
252 typedef struct {
253 float r, g, b;
254 } PSRGB;
256 typedef struct {
257 float i;
258 } PSGRAY;
261 /* def's for PSCOLOR.type */
262 #define PSCOLOR_GRAY 0
263 #define PSCOLOR_RGB 1
265 typedef struct {
266 int type;
267 union {
268 PSRGB rgb;
269 PSGRAY gray;
270 } value;
271 } PSCOLOR;
273 typedef struct {
274 const AFM *afm;
275 float scale;
276 TEXTMETRICW tm;
277 } BUILTIN;
279 typedef struct tagTYPE42 TYPE42;
281 typedef struct tagTYPE1 TYPE1;
283 enum downloadtype {
284 Type1, Type42
287 typedef struct _tagDOWNLOAD {
288 enum downloadtype type;
289 union {
290 TYPE1 *Type1;
291 TYPE42 *Type42;
292 } typeinfo;
293 char *ps_name;
294 struct _tagDOWNLOAD *next;
295 } DOWNLOAD;
297 enum fontloc {
298 Builtin, Download
301 typedef struct
303 INT xx, xy, yx, yy;
304 } matrix;
306 typedef struct {
307 enum fontloc fontloc;
308 union {
309 BUILTIN Builtin;
310 DOWNLOAD *Download;
311 } fontinfo;
313 matrix size;
314 PSCOLOR color;
315 BOOL set; /* Have we done a setfont yet */
317 /* These are needed by PSDRV_ExtTextOut */
318 int escapement;
319 int underlineThickness;
320 int underlinePosition;
321 int strikeoutThickness;
322 int strikeoutPosition;
324 } PSFONT;
326 typedef struct {
327 PSCOLOR color;
328 BOOL set;
329 } PSBRUSH;
331 typedef struct {
332 INT style;
333 INT width;
334 BYTE join;
335 BYTE endcap;
336 const char* dash;
337 PSCOLOR color;
338 BOOL set;
339 } PSPEN;
341 typedef struct {
342 DWORD id; /* Job id */
343 LPSTR output; /* Output file/port */
344 LPSTR DocName; /* Document Name */
345 BOOL banding; /* Have we received a NEXTBAND */
346 BOOL OutOfPage; /* Page header not sent yet */
347 INT PageNo;
348 BOOL quiet; /* Don't actually output anything */
349 BOOL in_passthrough; /* In PASSTHROUGH mode */
350 BOOL had_passthrough_rect; /* See the comment in PSDRV_Rectangle */
351 } JOB;
353 typedef struct {
354 HDC hdc;
355 PSFONT font; /* Current PS font */
356 DOWNLOAD *downloaded_fonts;
357 PSPEN pen;
358 PSBRUSH brush;
359 PSCOLOR bkColor;
360 PSCOLOR inkColor; /* Last colour set */
361 JOB job;
362 PSDRV_DEVMODEA *Devmode;
363 PRINTERINFO *pi;
364 SIZE PageSize; /* Physical page size in device units */
365 RECT ImageableArea; /* Imageable area in device units */
366 /* NB both PageSize and ImageableArea
367 are not rotated in landscape mode,
368 so PageSize.cx is generally
369 < PageSize.cy */
370 int horzRes; /* device caps */
371 int vertRes;
372 int horzSize;
373 int vertSize;
374 int logPixelsX;
375 int logPixelsY;
377 int pathdepth;
378 } PSDRV_PDEVICE;
380 typedef struct {
381 PRINTERINFO *pi;
382 PSDRV_DEVMODEA *dlgdm;
383 } PSDRV_DLGINFO;
387 * Every glyph name in the Adobe Glyph List and the 35 core PostScript fonts
390 extern const INT PSDRV_AGLGlyphNamesSize;
391 extern GLYPHNAME PSDRV_AGLGlyphNames[];
395 * The AGL encoding vector
398 extern const INT PSDRV_AGLbyNameSize; /* sorted by name - */
399 extern const UNICODEGLYPH PSDRV_AGLbyName[]; /* duplicates omitted */
401 extern const INT PSDRV_AGLbyUVSize; /* sorted by UV - */
402 extern const UNICODEGLYPH PSDRV_AGLbyUV[]; /* duplicates included */
404 extern HINSTANCE PSDRV_hInstance;
405 extern HANDLE PSDRV_Heap;
406 extern char *PSDRV_ANSIVector[256];
408 extern void PSDRV_MergeDevmodes(PSDRV_DEVMODEA *dm1, PSDRV_DEVMODEA *dm2,
409 PRINTERINFO *pi);
410 extern BOOL PSDRV_GetFontMetrics(void);
411 extern PPD *PSDRV_ParsePPD(char *fname);
412 extern PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name);
413 extern const AFM *PSDRV_FindAFMinList(FONTFAMILY *head, LPCSTR name);
414 extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, const AFM *afm,
415 BOOL *p_added);
416 extern void PSDRV_FreeAFMList( FONTFAMILY *head );
418 extern INT PSDRV_XWStoDS( PSDRV_PDEVICE *physDev, INT width );
419 extern INT PSDRV_YWStoDS( PSDRV_PDEVICE *physDev, INT height );
421 extern BOOL PSDRV_Brush(PSDRV_PDEVICE *physDev, BOOL EO);
422 extern BOOL PSDRV_SetFont( PSDRV_PDEVICE *physDev );
423 extern BOOL PSDRV_SetPen( PSDRV_PDEVICE *physDev );
425 extern void PSDRV_SetClip(PSDRV_PDEVICE* phyDev);
426 extern void PSDRV_ResetClip(PSDRV_PDEVICE* phyDev);
428 extern BOOL PSDRV_CopyColor(PSCOLOR *col1, PSCOLOR *col2);
429 extern void PSDRV_CreateColor( PSDRV_PDEVICE *physDev, PSCOLOR *pscolor,
430 COLORREF wincolor );
431 extern char PSDRV_UnicodeToANSI(int u);
433 extern INT PSDRV_WriteHeader( PSDRV_PDEVICE *physDev, LPCSTR title );
434 extern INT PSDRV_WriteFooter( PSDRV_PDEVICE *physDev );
435 extern INT PSDRV_WriteNewPage( PSDRV_PDEVICE *physDev );
436 extern INT PSDRV_WriteEndPage( PSDRV_PDEVICE *physDev );
437 extern BOOL PSDRV_WriteMoveTo(PSDRV_PDEVICE *physDev, INT x, INT y);
438 extern BOOL PSDRV_WriteLineTo(PSDRV_PDEVICE *physDev, INT x, INT y);
439 extern BOOL PSDRV_WriteStroke(PSDRV_PDEVICE *physDev);
440 extern BOOL PSDRV_WriteRectangle(PSDRV_PDEVICE *physDev, INT x, INT y, INT width,
441 INT height);
442 extern BOOL PSDRV_WriteRRectangle(PSDRV_PDEVICE *physDev, INT x, INT y, INT width,
443 INT height);
444 extern BOOL PSDRV_WriteSetFont(PSDRV_PDEVICE *physDev, const char *name, matrix size,
445 INT escapement);
446 extern BOOL PSDRV_WriteGlyphShow(PSDRV_PDEVICE *physDev, LPCSTR g_name);
447 extern BOOL PSDRV_WriteSetPen(PSDRV_PDEVICE *physDev);
448 extern BOOL PSDRV_WriteArc(PSDRV_PDEVICE *physDev, INT x, INT y, INT w, INT h,
449 double ang1, double ang2);
450 extern BOOL PSDRV_WriteSetColor(PSDRV_PDEVICE *physDev, PSCOLOR *color);
451 extern BOOL PSDRV_WriteSetBrush(PSDRV_PDEVICE *physDev);
452 extern BOOL PSDRV_WriteFill(PSDRV_PDEVICE *physDev);
453 extern BOOL PSDRV_WriteEOFill(PSDRV_PDEVICE *physDev);
454 extern BOOL PSDRV_WriteGSave(PSDRV_PDEVICE *physDev);
455 extern BOOL PSDRV_WriteGRestore(PSDRV_PDEVICE *physDev);
456 extern BOOL PSDRV_WriteNewPath(PSDRV_PDEVICE *physDev);
457 extern BOOL PSDRV_WriteClosePath(PSDRV_PDEVICE *physDev);
458 extern BOOL PSDRV_WriteClip(PSDRV_PDEVICE *physDev);
459 extern BOOL PSDRV_WriteRectClip(PSDRV_PDEVICE *physDev, INT x, INT y, INT w, INT h);
460 extern BOOL PSDRV_WriteRectClip2(PSDRV_PDEVICE *physDev, CHAR *pszArrayName);
461 extern BOOL PSDRV_WriteEOClip(PSDRV_PDEVICE *physDev);
462 extern BOOL PSDRV_WriteHatch(PSDRV_PDEVICE *physDev);
463 extern BOOL PSDRV_WriteRotate(PSDRV_PDEVICE *physDev, float ang);
464 extern BOOL PSDRV_WriteIndexColorSpaceBegin(PSDRV_PDEVICE *physDev, int size);
465 extern BOOL PSDRV_WriteIndexColorSpaceEnd(PSDRV_PDEVICE *physDev);
466 extern BOOL PSDRV_WriteRGB(PSDRV_PDEVICE *physDev, COLORREF *map, int number);
467 extern BOOL PSDRV_WriteImage(PSDRV_PDEVICE *physDev, WORD depth, INT xDst, INT yDst,
468 INT widthDst, INT heightDst, INT widthSrc,
469 INT heightSrc, BOOL mask);
470 extern BOOL PSDRV_WriteBytes(PSDRV_PDEVICE *physDev, const BYTE *bytes, DWORD number);
471 extern BOOL PSDRV_WriteData(PSDRV_PDEVICE *physDev, const BYTE *byte, DWORD number);
472 extern DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch);
473 extern BOOL PSDRV_WritePatternDict(PSDRV_PDEVICE *physDev, BITMAP *bm, BYTE *bits);
474 extern BOOL PSDRV_WriteDIBPatternDict(PSDRV_PDEVICE *physDev, BITMAPINFO *bmi, UINT usage);
475 extern BOOL PSDRV_WriteArrayPut(PSDRV_PDEVICE *physDev, CHAR *pszArrayName, INT nIndex, LONG lCoord);
476 extern BOOL PSDRV_WriteArrayDef(PSDRV_PDEVICE *physDev, CHAR *pszArrayName, INT nSize);
478 extern INT CDECL PSDRV_StartPage( PSDRV_PDEVICE *physDev );
480 INT PSDRV_GlyphListInit(void);
481 const GLYPHNAME *PSDRV_GlyphName(LPCSTR szName);
482 VOID PSDRV_IndexGlyphList(void);
483 BOOL PSDRV_GetTrueTypeMetrics(void);
484 BOOL PSDRV_GetType1Metrics(void);
485 const AFMMETRICS *PSDRV_UVMetrics(LONG UV, const AFM *afm);
486 SHORT PSDRV_CalcAvgCharWidth(const AFM *afm);
488 extern BOOL PSDRV_SelectBuiltinFont(PSDRV_PDEVICE *physDev, HFONT hfont,
489 LOGFONTW *plf, LPSTR FaceName);
490 extern BOOL PSDRV_WriteSetBuiltinFont(PSDRV_PDEVICE *physDev);
491 extern BOOL PSDRV_WriteBuiltinGlyphShow(PSDRV_PDEVICE *physDev, LPCWSTR str, INT count);
493 extern BOOL PSDRV_SelectDownloadFont(PSDRV_PDEVICE *physDev);
494 extern BOOL PSDRV_WriteSetDownloadFont(PSDRV_PDEVICE *physDev);
495 extern BOOL PSDRV_WriteDownloadGlyphShow(PSDRV_PDEVICE *physDev, WORD *glpyhs,
496 UINT count);
497 extern BOOL PSDRV_EmptyDownloadList(PSDRV_PDEVICE *physDev, BOOL write_undef);
499 extern DWORD write_spool( PSDRV_PDEVICE *physDev, const void *data, DWORD num );
501 #define MAX_G_NAME 31 /* max length of PS glyph name */
502 extern void get_glyph_name(HDC hdc, WORD index, char *name);
504 extern TYPE1 *T1_download_header(PSDRV_PDEVICE *physDev, char *ps_name,
505 RECT *bbox, UINT emsize);
506 extern BOOL T1_download_glyph(PSDRV_PDEVICE *physDev, DOWNLOAD *pdl,
507 DWORD index, char *glyph_name);
508 extern void T1_free(TYPE1 *t1);
510 extern TYPE42 *T42_download_header(PSDRV_PDEVICE *physDev, char *ps_name,
511 RECT *bbox, UINT emsize);
512 extern BOOL T42_download_glyph(PSDRV_PDEVICE *physDev, DOWNLOAD *pdl,
513 DWORD index, char *glyph_name);
514 extern void T42_free(TYPE42 *t42);
516 extern DWORD RLE_encode(BYTE *in_buf, DWORD len, BYTE *out_buf);
517 extern DWORD ASCII85_encode(BYTE *in_buf, DWORD len, BYTE *out_buf);
519 #define push_lc_numeric(x) do { \
520 const char *tmplocale = setlocale(LC_NUMERIC,NULL); \
521 setlocale(LC_NUMERIC,x);
523 #define pop_lc_numeric() \
524 setlocale(LC_NUMERIC,tmplocale); \
525 } while (0)
528 #endif