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
33 #include "wine/list.h"
35 struct ps_bitblt_coords
37 int log_x
; /* original position and size, in logical coords */
41 int x
; /* mapped position and size, in device coords */
45 RECT visrect
; /* rectangle clipped to the visible part, in device coords */
46 DWORD layout
; /* DC layout */
51 void *ptr
; /* pointer to the bits */
52 BOOL is_copy
; /* whether this is a copy of the bits that can be modified */
53 void (*free
)(struct ps_image_bits
*); /* callback for freeing the bits */
56 struct ps_brush_pattern
58 BITMAPINFO
*info
; /* DIB info */
59 struct ps_image_bits bits
; /* DIB bits */
60 UINT usage
; /* color usage for DIB info */
70 const GLYPHNAME
*name
;
74 float llx
, lly
, urx
, ury
;
77 typedef struct _tagAFMLIGS
{
80 struct _tagAFMLIGS
*next
;
84 int C
; /* character */
87 const GLYPHNAME
*N
; /* name */
89 const AFMLIGS
*L
; /* Ligatures */
93 INT C
; /* AFM encoding (or -1) */
94 LONG UV
; /* Unicode value */
95 FLOAT WX
; /* Advance width */
96 const GLYPHNAME
*N
; /* Glyph name */
100 USHORT usUnitsPerEm
; /* head:unitsPerEm */
101 SHORT sAscender
; /* hhea:Ascender */
102 SHORT sDescender
; /* hhea:Descender */
103 SHORT sLineGap
; /* hhea:LineGap */
104 SHORT sAvgCharWidth
; /* OS/2:xAvgCharWidth */
105 SHORT sTypoAscender
; /* OS/2:sTypoAscender */
106 SHORT sTypoDescender
; /* OS/2:sTypoDescender */
107 SHORT sTypoLineGap
; /* OS/2:sTypeLineGap */
108 USHORT usWinAscent
; /* OS/2:usWinAscent */
109 USHORT usWinDescent
; /* OS/2:usWinDescent */
112 typedef struct _tagAFM
{
113 const char *FontName
;
114 const WCHAR
*FullName
;
115 const WCHAR
*FamilyName
;
116 const WCHAR
*EncodingScheme
;
117 LONG Weight
; /* FW_NORMAL etc. */
120 float UnderlinePosition
;
121 float UnderlineThickness
;
125 WINMETRICS WinMetrics
;
127 const AFMMETRICS
*Metrics
;
130 /* Note no 'next' in AFM. Use AFMLISTENTRY as a container. This allows more than
131 one list to exist without having to reallocate the entire AFM structure. We
132 keep a global list of all afms (PSDRV_AFMFontList) plus a list of available
133 fonts for each DC (dc->physDev->Fonts) */
135 typedef struct _tagAFMLISTENTRY
{
137 struct _tagAFMLISTENTRY
*next
;
140 typedef struct _tagFONTFAMILY
{
141 WCHAR
*FamilyName
; /* family name */
142 AFMLISTENTRY
*afmlist
; /* list of afms for this family */
143 struct _tagFONTFAMILY
*next
; /* next family */
146 extern FONTFAMILY
*PSDRV_AFMFontList
;
147 extern const AFM
*const PSDRV_BuiltinAFMs
[]; /* last element is NULL */
156 float llx
, lly
, urx
, ury
;
165 typedef struct _tagPAGESIZE
{
169 char *InvocationString
;
170 IMAGEABLEAREA
*ImageableArea
;
171 PAPERDIMENSION
*PaperDimension
;
172 WORD WinPage
; /*eg DMPAPER_A4. Doesn't really belong here */
188 const char *FullName
;
189 char *InvocationString
;
190 WORD WinBin
; /* eg DMBIN_LOWER */
193 typedef enum _RASTERIZEROPTION
194 {RO_None
, RO_Accept68K
, RO_Type42
, RO_TrueImage
} RASTERIZEROPTION
;
201 char *InvocationString
;
202 WORD WinDuplex
; /* eg DMDUP_SIMPLEX */
209 char *InvocationString
;
212 /* Many Mac OS X based ppd files don't include a *ColorDevice line, so
213 we use a tristate here rather than a boolean. Code that
214 cares is expected to treat these as if they were colour. */
224 COLORDEVICE ColorDevice
;
225 struct list Resolutions
;
226 int DefaultResolution
;
227 signed int LandscapeOrientation
;
229 char *JCLToPSInterpreter
;
232 struct list InstalledFonts
;
233 struct list PageSizes
;
234 PAGESIZE
*DefaultPageSize
;
235 struct list Constraints
;
236 struct list InputSlots
;
237 RASTERIZEROPTION TTRasterizer
;
238 struct list Duplexes
;
239 DUPLEX
*DefaultDuplex
;
245 WCHAR
*friendly_name
;
247 PSDRV_DEVMODE
*Devmode
;
249 PPRINTER_ENUM_VALUESW FontSubTable
;
250 DWORD FontSubTableSize
;
262 /* def's for PSCOLOR.type */
263 #define PSCOLOR_GRAY 0
264 #define PSCOLOR_RGB 1
280 typedef struct tagTYPE42 TYPE42
;
282 typedef struct tagTYPE1 TYPE1
;
288 typedef struct _tagDOWNLOAD
{
289 enum downloadtype type
;
295 struct _tagDOWNLOAD
*next
;
307 enum fontset
{ UNSET
= 0, HORIZONTAL_SET
, VERTICAL_SET
};
310 enum fontloc fontloc
;
318 enum fontset set
; /* Have we done a setfont yet */
324 struct ps_brush_pattern pattern
;
327 #define MAX_DASHLEN 16
334 DWORD dash
[MAX_DASHLEN
];
344 passthrough_had_rect
, /* See the comment in PSDRV_Rectangle */
348 DWORD id
; /* Job id */
349 HANDLE hprinter
; /* Printer handle */
350 LPWSTR doc_name
; /* Document Name */
351 BOOL OutOfPage
; /* Page header not sent yet */
353 BOOL quiet
; /* Don't actually output anything */
354 enum passthrough passthrough_state
;
362 PSFONT font
; /* Current PS font */
363 DOWNLOAD
*downloaded_fonts
;
368 PSDRV_DEVMODE
*Devmode
;
373 extern print_ctx
*create_print_ctx( HDC hdc
, const WCHAR
*device
,
374 const DEVMODEW
*devmode
);
377 * Every glyph name in the Adobe Glyph List and the 35 core PostScript fonts
380 extern const INT PSDRV_AGLGlyphNamesSize
;
381 extern GLYPHNAME PSDRV_AGLGlyphNames
[];
385 * The AGL encoding vector
388 extern const INT PSDRV_AGLbyNameSize
; /* sorted by name */
389 extern const UNICODEGLYPH PSDRV_AGLbyName
[]; /* duplicates omitted */
391 extern const INT PSDRV_AGLbyUVSize
; /* sorted by UV */
392 extern const UNICODEGLYPH PSDRV_AGLbyUV
[]; /* duplicates included */
394 extern HINSTANCE PSDRV_hInstance
;
395 extern HANDLE PSDRV_Heap
;
396 extern char *PSDRV_ANSIVector
[256];
398 extern INPUTSLOT
*find_slot( PPD
*ppd
, const DEVMODEW
*dm
);
399 extern PAGESIZE
*find_pagesize( PPD
*ppd
, const DEVMODEW
*dm
);
400 extern DUPLEX
*find_duplex( PPD
*ppd
, const DEVMODEW
*dm
);
402 /* GDI driver functions */
403 extern BOOL
PSDRV_Arc( print_ctx
*ctx
, INT left
, INT top
, INT right
, INT bottom
,
404 INT xstart
, INT ystart
, INT xend
, INT yend
);
405 extern BOOL
PSDRV_Chord( print_ctx
*ctx
, INT left
, INT top
, INT right
, INT bottom
,
406 INT xstart
, INT ystart
, INT xend
, INT yend
);
407 extern BOOL
PSDRV_Ellipse( print_ctx
*ctx
, INT left
, INT top
, INT right
, INT bottom
);
408 extern INT
PSDRV_EndPage( print_ctx
*ctx
);
409 extern INT
PSDRV_ExtEscape( print_ctx
*ctx
, INT nEscape
, INT cbInput
, LPCVOID in_data
,
410 INT cbOutput
, LPVOID out_data
);
411 extern BOOL
PSDRV_ExtTextOut( print_ctx
*ctx
, INT x
, INT y
, UINT flags
,
412 const RECT
*lprect
, LPCWSTR str
, UINT count
, const INT
*lpDx
);
413 extern BOOL
PSDRV_FillPath( print_ctx
*ctx
);
414 extern BOOL
PSDRV_LineTo(print_ctx
*ctx
, INT x
, INT y
);
415 extern BOOL
PSDRV_PaintRgn( print_ctx
*ctx
, HRGN hrgn
);
416 extern BOOL
PSDRV_PatBlt(print_ctx
*ctx
, struct ps_bitblt_coords
*dst
, DWORD dwRop
);
417 extern BOOL
PSDRV_Pie( print_ctx
*ctx
, INT left
, INT top
, INT right
, INT bottom
,
418 INT xstart
, INT ystart
, INT xend
, INT yend
);
419 extern BOOL
PSDRV_PolyBezier( print_ctx
*ctx
, const POINT
*pts
, DWORD count
);
420 extern BOOL
PSDRV_PolyBezierTo( print_ctx
*ctx
, const POINT
*pts
, DWORD count
);
421 extern BOOL
PSDRV_PolyPolygon( print_ctx
*ctx
, const POINT
* pts
, const INT
* counts
, UINT polygons
);
422 extern BOOL
PSDRV_PolyPolyline( print_ctx
*ctx
, const POINT
* pts
, const DWORD
* counts
, DWORD polylines
);
423 extern DWORD
PSDRV_PutImage( print_ctx
*ctx
, HRGN clip
, BITMAPINFO
*info
,
424 const struct ps_image_bits
*bits
, struct ps_bitblt_coords
*src
,
425 struct ps_bitblt_coords
*dst
, DWORD rop
);
426 extern BOOL
PSDRV_Rectangle( print_ctx
*ctx
, INT left
, INT top
, INT right
, INT bottom
);
427 extern BOOL
PSDRV_RoundRect( print_ctx
*ctx
, INT left
, INT top
, INT right
,
428 INT bottom
, INT ell_width
, INT ell_height
);
429 extern HBRUSH
PSDRV_SelectBrush( print_ctx
*ctx
, HBRUSH hbrush
, const struct ps_brush_pattern
*pattern
);
430 extern HFONT
PSDRV_SelectFont( print_ctx
*ctx
, HFONT hfont
, UINT
*aa_flags
);
431 extern HPEN
PSDRV_SelectPen( print_ctx
*ctx
, HPEN hpen
, const struct ps_brush_pattern
*pattern
);
432 extern COLORREF
PSDRV_SetBkColor( print_ctx
*ctx
, COLORREF color
);
433 extern COLORREF
PSDRV_SetDCBrushColor( print_ctx
*ctx
, COLORREF color
);
434 extern COLORREF
PSDRV_SetDCPenColor( print_ctx
*ctx
, COLORREF color
);
435 extern COLORREF
PSDRV_SetPixel( print_ctx
*ctx
, INT x
, INT y
, COLORREF color
);
436 extern COLORREF
PSDRV_SetTextColor( print_ctx
*ctx
, COLORREF color
);
437 extern BOOL
PSDRV_StrokeAndFillPath( print_ctx
*ctx
);
438 extern BOOL
PSDRV_StrokePath( print_ctx
*ctx
);
440 extern BOOL
PSDRV_ResetDC( print_ctx
*ctx
, const DEVMODEW
*lpInitData
);
441 extern void PSDRV_MergeDevmodes(PSDRV_DEVMODE
*dm1
, const DEVMODEW
*dm2
,
443 extern BOOL
PSDRV_GetFontMetrics(void);
444 extern PPD
*PSDRV_ParsePPD(const WCHAR
*fname
, HANDLE printer
);
445 extern PRINTERINFO
*PSDRV_FindPrinterInfo(LPCWSTR name
);
446 extern const AFM
*PSDRV_FindAFMinList(FONTFAMILY
*head
, LPCSTR name
);
447 extern BOOL
PSDRV_AddAFMtoList(FONTFAMILY
**head
, const AFM
*afm
,
449 extern void PSDRV_FreeAFMList( FONTFAMILY
*head
);
451 extern INT
PSDRV_XWStoDS( print_ctx
*ctx
, INT width
);
453 extern BOOL
PSDRV_Brush(print_ctx
*ctx
, BOOL EO
);
454 extern BOOL
PSDRV_SetFont( print_ctx
*ctx
, BOOL vertical
);
455 extern BOOL
PSDRV_SetPen( print_ctx
*ctx
);
457 extern void PSDRV_AddClip( print_ctx
*ctx
, HRGN hrgn
);
458 extern void PSDRV_SetClip( print_ctx
*ctx
);
459 extern void PSDRV_ResetClip( print_ctx
*ctx
);
461 extern void PSDRV_CreateColor( print_ctx
*ctx
, PSCOLOR
*pscolor
,
463 extern PSRGB
rgb_to_grayscale_scale( void );
464 extern char PSDRV_UnicodeToANSI(int u
);
466 extern INT
PSDRV_WriteHeader( print_ctx
*ctx
, LPCWSTR title
);
467 extern INT
PSDRV_WriteFooter( print_ctx
*ctx
);
468 extern INT
PSDRV_WriteNewPage( print_ctx
*ctx
);
469 extern INT
PSDRV_WriteEndPage( print_ctx
*ctx
);
470 extern BOOL
PSDRV_WriteMoveTo(print_ctx
*ctx
, INT x
, INT y
);
471 extern BOOL
PSDRV_WriteLineTo(print_ctx
*ctx
, INT x
, INT y
);
472 extern BOOL
PSDRV_WriteStroke(print_ctx
*ctx
);
473 extern BOOL
PSDRV_WriteRectangle(print_ctx
*ctx
, INT x
, INT y
, INT width
, INT height
);
474 extern BOOL
PSDRV_WriteRRectangle(print_ctx
*ctx
, INT x
, INT y
, INT width
, INT height
);
475 extern BOOL
PSDRV_WriteSetFont(print_ctx
*ctx
, const char *name
, matrix size
, INT escapement
,
477 extern BOOL
PSDRV_WriteGlyphShow(print_ctx
*ctx
, LPCSTR g_name
);
478 extern BOOL
PSDRV_WriteSetPen(print_ctx
*ctx
);
479 extern BOOL
PSDRV_WriteArc(print_ctx
*ctx
, INT x
, INT y
, INT w
, INT h
,
480 double ang1
, double ang2
);
481 extern BOOL
PSDRV_WriteCurveTo(print_ctx
*ctx
, POINT pts
[3]);
482 extern BOOL
PSDRV_WriteSetColor(print_ctx
*ctx
, PSCOLOR
*color
);
483 extern BOOL
PSDRV_WriteSetBrush(print_ctx
*ctx
);
484 extern BOOL
PSDRV_WriteFill(print_ctx
*ctx
);
485 extern BOOL
PSDRV_WriteEOFill(print_ctx
*ctx
);
486 extern BOOL
PSDRV_WriteGSave(print_ctx
*ctx
);
487 extern BOOL
PSDRV_WriteGRestore(print_ctx
*ctx
);
488 extern BOOL
PSDRV_WriteNewPath(print_ctx
*ctx
);
489 extern BOOL
PSDRV_WriteClosePath(print_ctx
*ctx
);
490 extern BOOL
PSDRV_WriteClip(print_ctx
*ctx
);
491 extern BOOL
PSDRV_WriteRectClip(print_ctx
*ctx
, INT x
, INT y
, INT w
, INT h
);
492 extern BOOL
PSDRV_WriteRectClip2(print_ctx
*ctx
, CHAR
*pszArrayName
);
493 extern BOOL
PSDRV_WriteEOClip(print_ctx
*ctx
);
494 extern BOOL
PSDRV_WriteHatch(print_ctx
*ctx
);
495 extern BOOL
PSDRV_WriteRotate(print_ctx
*ctx
, float ang
);
496 extern BOOL
PSDRV_WriteIndexColorSpaceBegin(print_ctx
*ctx
, int size
);
497 extern BOOL
PSDRV_WriteIndexColorSpaceEnd(print_ctx
*ctx
);
498 extern BOOL
PSDRV_WriteRGBQUAD(print_ctx
*ctx
, const RGBQUAD
*rgb
, int number
);
499 extern BOOL
PSDRV_WriteImage(print_ctx
*ctx
, WORD depth
, BOOL grayscale
, INT xDst
, INT yDst
,
500 INT widthDst
, INT heightDst
, INT widthSrc
,
501 INT heightSrc
, BOOL mask
, BOOL top_down
);
502 extern BOOL
PSDRV_WriteBytes(print_ctx
*ctx
, const BYTE
*bytes
, DWORD number
);
503 extern BOOL
PSDRV_WriteData(print_ctx
*ctx
, const BYTE
*byte
, DWORD number
);
504 extern DWORD
PSDRV_WriteSpool(print_ctx
*ctx
, LPCSTR lpData
, DWORD cch
);
505 extern BOOL
PSDRV_WriteDIBPatternDict(print_ctx
*ctx
, const BITMAPINFO
*bmi
, BYTE
*bits
, UINT usage
);
506 extern BOOL
PSDRV_WriteArrayPut(print_ctx
*ctx
, CHAR
*pszArrayName
, INT nIndex
, LONG lCoord
);
507 extern BOOL
PSDRV_WriteArrayDef(print_ctx
*ctx
, CHAR
*pszArrayName
, INT nSize
);
509 extern INT
PSDRV_StartPage( print_ctx
*ctx
);
511 INT
PSDRV_GlyphListInit(void);
512 const GLYPHNAME
*PSDRV_GlyphName(LPCSTR szName
);
513 VOID
PSDRV_IndexGlyphList(void);
514 BOOL
PSDRV_GetType1Metrics(void);
515 SHORT
PSDRV_CalcAvgCharWidth(const AFM
*afm
);
517 extern BOOL
PSDRV_WriteSetBuiltinFont(print_ctx
*ctx
);
518 extern BOOL
PSDRV_WriteBuiltinGlyphShow(print_ctx
*ctx
, LPCWSTR str
, INT count
);
520 extern BOOL
PSDRV_WriteSetDownloadFont(print_ctx
*ctx
, BOOL vertical
);
521 extern BOOL
PSDRV_WriteDownloadGlyphShow(print_ctx
*ctx
, const WORD
*glyphs
, UINT count
);
522 extern BOOL
PSDRV_EmptyDownloadList(print_ctx
*ctx
, BOOL write_undef
);
524 extern BOOL
flush_spool(print_ctx
*ctx
);
525 extern DWORD
write_spool(print_ctx
*ctx
, const void *data
, DWORD num
);
527 #define MAX_G_NAME 31 /* max length of PS glyph name */
528 extern void get_glyph_name(HDC hdc
, WORD index
, char *name
);
530 extern TYPE1
*T1_download_header(print_ctx
*ctx
, char *ps_name
,
531 RECT
*bbox
, UINT emsize
);
532 extern BOOL
T1_download_glyph(print_ctx
*ctx
, DOWNLOAD
*pdl
,
533 DWORD index
, char *glyph_name
);
534 extern void T1_free(TYPE1
*t1
);
536 extern TYPE42
*T42_download_header(print_ctx
*ctx
, char *ps_name
,
537 RECT
*bbox
, UINT emsize
);
538 extern BOOL
T42_download_glyph(print_ctx
*ctx
, DOWNLOAD
*pdl
,
539 DWORD index
, char *glyph_name
);
540 extern void T42_free(TYPE42
*t42
);
542 extern DWORD
RLE_encode(BYTE
*in_buf
, DWORD len
, BYTE
*out_buf
);
543 extern DWORD
ASCII85_encode(BYTE
*in_buf
, DWORD len
, BYTE
*out_buf
);
545 extern void passthrough_enter(print_ctx
*ctx
);
546 extern void passthrough_leave(print_ctx
*ctx
);
548 #define push_lc_numeric(x) do { \
549 const char *tmplocale = setlocale(LC_NUMERIC,NULL); \
550 setlocale(LC_NUMERIC,x);
552 #define pop_lc_numeric() \
553 setlocale(LC_NUMERIC,tmplocale); \
556 static inline WCHAR
*strdupW( const WCHAR
*str
)
561 if (!str
) return NULL
;
562 size
= (lstrlenW( str
) + 1) * sizeof(WCHAR
);
563 ret
= HeapAlloc( GetProcessHeap(), 0, size
);
564 if (ret
) memcpy( ret
, str
, size
);