text.c 3.84 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
Alexandre Julliard's avatar
Alexandre Julliard committed
2
 *	PostScript driver text functions
Alexandre Julliard's avatar
Alexandre Julliard committed
3 4 5
 *
 *	Copyright 1998  Huw D M Davies
 *
6 7 8 9 10 11 12 13 14 15 16 17
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
Alexandre Julliard's avatar
Alexandre Julliard committed
19 20
 */
#include <string.h>
21
#include <stdarg.h>
22
#include <stdlib.h>
23 24 25 26
#include <math.h>

#include "windef.h"
#include "wingdi.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
27
#include "psdrv.h"
28
#include "wine/debug.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
29

30
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
31

32
static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags,
33
		       LPCWSTR str, UINT count,
34
		       BOOL bDrawBackground, const INT *lpDx);
35

Alexandre Julliard's avatar
Alexandre Julliard committed
36 37 38
/***********************************************************************
 *           PSDRV_ExtTextOut
 */
39 40
BOOL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect, LPCWSTR str, UINT count,
                       const INT *lpDx )
Alexandre Julliard's avatar
Alexandre Julliard committed
41
{
42
    PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
43
    BOOL bResult = TRUE;
44 45
    BOOL bClipped = FALSE;
    BOOL bOpaque = FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
46

47 48
    TRACE("(x=%d, y=%d, flags=0x%08x, str=%s, count=%d, lpDx=%p)\n", x, y,
	  flags, debugstr_wn(str, count), count, lpDx);
Alexandre Julliard's avatar
Alexandre Julliard committed
49

50
    if(physDev->job.id == 0) return FALSE;
51

52
    /* write font if not already written */
53
    PSDRV_SetFont(dev);
54

55
    PSDRV_SetClip(dev);
56

57
    /* set clipping and/or draw background */
58
    if ((flags & (ETO_CLIPPED | ETO_OPAQUE)) && (lprect != NULL))
59
    {
60 61
	PSDRV_WriteGSave(dev);
	PSDRV_WriteRectangle(dev, lprect->left, lprect->top, lprect->right - lprect->left,
62
			     lprect->bottom - lprect->top);
63 64 65

	if (flags & ETO_OPAQUE)
	{
66
	    bOpaque = TRUE;
67 68 69 70
	    PSDRV_WriteGSave(dev);
	    PSDRV_WriteSetColor(dev, &physDev->bkColor);
	    PSDRV_WriteFill(dev);
	    PSDRV_WriteGRestore(dev);
71 72 73 74
	}

	if (flags & ETO_CLIPPED)
	{
75
	    bClipped = TRUE;
76
	    PSDRV_WriteClip(dev);
77 78
	}

79 80
	bResult = PSDRV_Text(dev, x, y, flags, str, count, !(bClipped && bOpaque), lpDx);
	PSDRV_WriteGRestore(dev);
81 82 83
    }
    else
    {
84
	bResult = PSDRV_Text(dev, x, y, flags, str, count, TRUE, lpDx);
85 86
    }

87
    PSDRV_ResetClip(dev);
88 89 90 91 92 93
    return bResult;
}

/***********************************************************************
 *           PSDRV_Text
 */
94
static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
95
		       UINT count, BOOL bDrawBackground, const INT *lpDx)
96
{
97
    PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
98
    WORD *glyphs = NULL;
99

100 101 102
    if (!count)
	return TRUE;

103
    if(physDev->font.fontloc == Download)
104
        glyphs = (LPWORD)str;
Alexandre Julliard's avatar
Alexandre Julliard committed
105

106
    PSDRV_WriteMoveTo(dev, x, y);
107

108
    if(!lpDx) {
109
        if(physDev->font.fontloc == Download)
110
	    PSDRV_WriteDownloadGlyphShow(dev, glyphs, count);
111
	else
112
	    PSDRV_WriteBuiltinGlyphShow(dev, str, count);
113
    }
114
    else {
115
        UINT i;
116 117
	POINT offset = {0, 0};

118
        for(i = 0; i < count-1; i++) {
119
	    if(physDev->font.fontloc == Download)
120
	        PSDRV_WriteDownloadGlyphShow(dev, glyphs + i, 1);
121
	    else
122
	        PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
123 124 125 126 127 128 129
            if(flags & ETO_PDY)
            {
                offset.x += lpDx[i * 2];
                offset.y += lpDx[i * 2 + 1];
            }
            else
                offset.x += lpDx[i];
130
	    PSDRV_WriteMoveTo(dev, x + offset.x, y + offset.y);
131
	}
132
	if(physDev->font.fontloc == Download)
133
	    PSDRV_WriteDownloadGlyphShow(dev, glyphs + i, 1);
134
	else
135
	    PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
136 137
    }

Alexandre Julliard's avatar
Alexandre Julliard committed
138 139
    return TRUE;
}