2 * PostScript driver text functions
4 * Copyright 1998 Huw D M Davies
9 #include "debugtools.h"
12 DEFAULT_DEBUG_CHANNEL(psdrv
)
14 /***********************************************************************
17 BOOL
PSDRV_ExtTextOut( DC
*dc
, INT x
, INT y
, UINT flags
,
18 const RECT
*lprect
, LPCSTR str
, UINT count
,
21 PSDRV_PDEVICE
*physDev
= (PSDRV_PDEVICE
*)dc
->physDev
;
25 TRACE("(x=%d, y=%d, flags=0x%08x, str='%.*s', count=%d)\n", x
, y
,
26 flags
, (int)count
, str
, count
);
28 strbuf
= (char *)HeapAlloc( PSDRV_Heap
, 0, count
+ 1);
30 WARN("HeapAlloc failed\n");
34 if(dc
->w
.textAlign
& TA_UPDATECP
) {
42 GetTextExtentPoint32A(dc
->hSelf
, str
, count
, &sz
);
43 sz
.cx
= XLSTODS(dc
, sz
.cx
);
44 sz
.cy
= YLSTODS(dc
, sz
.cy
);
46 switch(dc
->w
.textAlign
& (TA_LEFT
| TA_CENTER
| TA_RIGHT
) ) {
48 if(dc
->w
.textAlign
& TA_UPDATECP
)
49 dc
->w
.CursPosX
= XDPTOLP(dc
, x
+ sz
.cx
);
58 if(dc
->w
.textAlign
& TA_UPDATECP
)
59 dc
->w
.CursPosX
= XDPTOLP(dc
, x
);
63 switch(dc
->w
.textAlign
& (TA_TOP
| TA_BASELINE
| TA_BOTTOM
) ) {
65 y
+= physDev
->font
.tm
.tmAscent
;
72 y
-= physDev
->font
.tm
.tmDescent
;
76 memcpy(strbuf
, str
, count
);
77 *(strbuf
+ count
) = '\0';
81 PSDRV_WriteMoveTo(dc
, x
, y
);
82 PSDRV_WriteShow(dc
, strbuf
, strlen(strbuf
));
85 * Underline and strikeout attributes.
87 if ((physDev
->font
.tm
.tmUnderlined
) || (physDev
->font
.tm
.tmStruckOut
)) {
89 /* Get the thickness and the position for the underline attribute */
90 /* We'll use the same thickness for the strikeout attribute */
92 float thick
= physDev
->font
.afm
->UnderlineThickness
* physDev
->font
.scale
;
93 float pos
= -physDev
->font
.afm
->UnderlinePosition
* physDev
->font
.scale
;
95 INT escapement
= physDev
->font
.escapement
;
97 TRACE("Position = %f Thickness %f Escapement %d\n",
98 pos
, thick
, escapement
);
100 /* Get the width of the text */
102 PSDRV_GetTextExtentPoint(dc
, strbuf
, strlen(strbuf
), &size
);
103 size
.cx
= XLSTODS(dc
, size
.cx
);
105 /* Do the underline */
107 if (physDev
->font
.tm
.tmUnderlined
) {
108 if (escapement
!= 0) /* rotated text */
110 PSDRV_WriteGSave(dc
); /* save the graphics state */
111 PSDRV_WriteMoveTo(dc
, x
, y
); /* move to the start */
113 /* temporarily rotate the coord system */
114 PSDRV_WriteRotate(dc
, -escapement
/10);
116 /* draw the underline relative to the starting point */
117 PSDRV_WriteRRectangle(dc
, 0, (INT
)pos
, size
.cx
, (INT
)thick
);
120 PSDRV_WriteRectangle(dc
, x
, y
+ (INT
)pos
, size
.cx
, (INT
)thick
);
124 if (escapement
!= 0) /* rotated text */
125 PSDRV_WriteGRestore(dc
); /* restore the graphics state */
128 /* Do the strikeout */
130 if (physDev
->font
.tm
.tmStruckOut
) {
131 pos
= -physDev
->font
.tm
.tmAscent
/ 2;
133 if (escapement
!= 0) /* rotated text */
135 PSDRV_WriteGSave(dc
); /* save the graphics state */
136 PSDRV_WriteMoveTo(dc
, x
, y
); /* move to the start */
138 /* temporarily rotate the coord system */
139 PSDRV_WriteRotate(dc
, -escapement
/10);
141 /* draw the underline relative to the starting point */
142 PSDRV_WriteRRectangle(dc
, 0, (INT
)pos
, size
.cx
, (INT
)thick
);
145 PSDRV_WriteRectangle(dc
, x
, y
+ (INT
)pos
, size
.cx
, (INT
)thick
);
149 if (escapement
!= 0) /* rotated text */
150 PSDRV_WriteGRestore(dc
); /* restore the graphics state */
154 HeapFree(PSDRV_Heap
, 0, strbuf
);