gdiplus/tests: Don't fail if we do find Microsoft Sans Serif on Wine.
[wine/hacks.git] / dlls / wineps.drv / text.c
blob9b4bea63edcb9ea323dd29295cac9c2ae5636f37
1 /*
2 * PostScript driver text functions
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
20 #include <string.h>
21 #include <stdarg.h>
22 #include <stdlib.h>
23 #include <math.h>
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "psdrv.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
32 static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
33 LPCWSTR str, UINT count,
34 BOOL bDrawBackground, const INT *lpDx);
36 /***********************************************************************
37 * PSDRV_ExtTextOut
39 BOOL CDECL PSDRV_ExtTextOut( PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
40 const RECT *lprect, LPCWSTR str, UINT count,
41 const INT *lpDx )
43 BOOL bResult = TRUE;
44 BOOL bClipped = FALSE;
45 BOOL bOpaque = FALSE;
47 TRACE("(x=%d, y=%d, flags=0x%08x, str=%s, count=%d, lpDx=%p)\n", x, y,
48 flags, debugstr_wn(str, count), count, lpDx);
50 if(physDev->job.id == 0) return FALSE;
52 /* write font if not already written */
53 PSDRV_SetFont(physDev);
55 PSDRV_SetClip(physDev);
57 /* set clipping and/or draw background */
58 if ((flags & (ETO_CLIPPED | ETO_OPAQUE)) && (lprect != NULL))
60 PSDRV_WriteGSave(physDev);
61 PSDRV_WriteRectangle(physDev, lprect->left, lprect->top, lprect->right - lprect->left,
62 lprect->bottom - lprect->top);
64 if (flags & ETO_OPAQUE)
66 bOpaque = TRUE;
67 PSDRV_WriteGSave(physDev);
68 PSDRV_WriteSetColor(physDev, &physDev->bkColor);
69 PSDRV_WriteFill(physDev);
70 PSDRV_WriteGRestore(physDev);
73 if (flags & ETO_CLIPPED)
75 bClipped = TRUE;
76 PSDRV_WriteClip(physDev);
79 bResult = PSDRV_Text(physDev, x, y, flags, str, count, !(bClipped && bOpaque), lpDx);
80 PSDRV_WriteGRestore(physDev);
82 else
84 bResult = PSDRV_Text(physDev, x, y, flags, str, count, TRUE, lpDx);
87 PSDRV_ResetClip(physDev);
88 return bResult;
91 /***********************************************************************
92 * PSDRV_Text
94 static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR str,
95 UINT count, BOOL bDrawBackground, const INT *lpDx)
97 WORD *glyphs = NULL;
99 if (!count)
100 return TRUE;
102 if(physDev->font.fontloc == Download)
103 glyphs = (LPWORD)str;
105 PSDRV_WriteMoveTo(physDev, x, y);
107 if(!lpDx) {
108 if(physDev->font.fontloc == Download)
109 PSDRV_WriteDownloadGlyphShow(physDev, glyphs, count);
110 else
111 PSDRV_WriteBuiltinGlyphShow(physDev, str, count);
113 else {
114 UINT i;
115 POINT offset = {0, 0};
117 for(i = 0; i < count-1; i++) {
118 if(physDev->font.fontloc == Download)
119 PSDRV_WriteDownloadGlyphShow(physDev, glyphs + i, 1);
120 else
121 PSDRV_WriteBuiltinGlyphShow(physDev, str + i, 1);
122 if(flags & ETO_PDY)
124 offset.x += lpDx[i * 2];
125 offset.y += lpDx[i * 2 + 1];
127 else
128 offset.x += lpDx[i];
129 PSDRV_WriteMoveTo(physDev, x + offset.x, y + offset.y);
131 if(physDev->font.fontloc == Download)
132 PSDRV_WriteDownloadGlyphShow(physDev, glyphs + i, 1);
133 else
134 PSDRV_WriteBuiltinGlyphShow(physDev, str + i, 1);
137 return TRUE;