wined3d: Clear the renderbuffer IDs on unload.
[wine.git] / dlls / wineps.drv / font.c
blobc8ec97695c46ec5e381fe6ecee2d3b063eb9f12a
1 /*
2 * PostScript driver font 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 <stdarg.h>
21 #include <string.h>
22 #include <assert.h>
23 #include <stdlib.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winnls.h"
29 #include "winspool.h"
31 #include "psdrv.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
36 /***********************************************************************
37 * SelectFont (WINEPS.@)
39 HFONT PSDRV_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
41 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
42 PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectFont );
43 HFONT ret;
44 LOGFONTW lf;
45 BOOL subst = FALSE;
46 char FaceName[LF_FACESIZE];
48 if (!GetObjectW( hfont, sizeof(lf), &lf )) return 0;
50 *aa_flags = GGO_BITMAP; /* no anti-aliasing on printer devices */
52 TRACE("FaceName = %s Height = %d Italic = %d Weight = %d\n",
53 debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
54 lf.lfWeight);
56 WideCharToMultiByte(CP_ACP, 0, lf.lfFaceName, -1,
57 FaceName, sizeof(FaceName), NULL, NULL);
59 if(FaceName[0] == '\0') {
60 switch(lf.lfPitchAndFamily & 0xf0) {
61 case FF_DONTCARE:
62 break;
63 case FF_ROMAN:
64 case FF_SCRIPT:
65 strcpy(FaceName, "Times");
66 break;
67 case FF_SWISS:
68 strcpy(FaceName, "Helvetica");
69 break;
70 case FF_MODERN:
71 strcpy(FaceName, "Courier");
72 break;
73 case FF_DECORATIVE:
74 strcpy(FaceName, "Symbol");
75 break;
79 if(FaceName[0] == '\0') {
80 switch(lf.lfPitchAndFamily & 0x0f) {
81 case VARIABLE_PITCH:
82 strcpy(FaceName, "Times");
83 break;
84 default:
85 strcpy(FaceName, "Courier");
86 break;
90 if (physDev->pi->FontSubTableSize != 0)
92 DWORD i;
94 for (i = 0; i < physDev->pi->FontSubTableSize; ++i)
96 if (!strcasecmp (FaceName,
97 physDev->pi->FontSubTable[i].pValueName))
99 TRACE ("substituting facename '%s' for '%s'\n",
100 (LPSTR) physDev->pi->FontSubTable[i].pData, FaceName);
101 if (strlen ((LPSTR) physDev->pi->FontSubTable[i].pData) <
102 LF_FACESIZE)
104 strcpy (FaceName,
105 (LPSTR) physDev->pi->FontSubTable[i].pData);
106 subst = TRUE;
108 else
109 WARN ("Facename '%s' is too long; ignoring substitution\n",
110 (LPSTR) physDev->pi->FontSubTable[i].pData);
111 break;
116 physDev->font.escapement = lf.lfEscapement;
117 physDev->font.set = UNSET;
119 if (!subst && ((ret = next->funcs->pSelectFont( next, hfont, aa_flags ))))
121 PSDRV_SelectDownloadFont(dev);
122 return ret;
125 PSDRV_SelectBuiltinFont(dev, hfont, &lf, FaceName);
126 next->funcs->pSelectFont( next, 0, aa_flags ); /* tell next driver that we selected a device font */
127 return hfont;
130 /***********************************************************************
131 * PSDRV_SetFont
133 BOOL PSDRV_SetFont( PHYSDEV dev, BOOL vertical )
135 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
137 PSDRV_WriteSetColor(dev, &physDev->font.color);
138 if (vertical && (physDev->font.set == VERTICAL_SET)) return TRUE;
139 if (!vertical && (physDev->font.set == HORIZONTAL_SET)) return TRUE;
141 switch(physDev->font.fontloc) {
142 case Builtin:
143 PSDRV_WriteSetBuiltinFont(dev);
144 break;
145 case Download:
146 PSDRV_WriteSetDownloadFont(dev, vertical);
147 break;
148 default:
149 ERR("fontloc = %d\n", physDev->font.fontloc);
150 assert(1);
151 break;
153 if (vertical)
154 physDev->font.set = VERTICAL_SET;
155 else
156 physDev->font.set = HORIZONTAL_SET;
157 return TRUE;