gdi32: Add a null driver entry point for UnrealizePalette.
[wine.git] / dlls / wineps.drv / font.c
blobd66c5e678d257c2e75a1cc2c91e2776aff4b3a2d
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 CDECL PSDRV_SelectFont( PSDRV_PDEVICE *physDev, HFONT hfont, HANDLE gdiFont )
41 LOGFONTW lf;
42 BOOL subst = FALSE;
43 char FaceName[LF_FACESIZE];
45 if (!GetObjectW( hfont, sizeof(lf), &lf )) return HGDI_ERROR;
47 TRACE("FaceName = %s Height = %d Italic = %d Weight = %d\n",
48 debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
49 lf.lfWeight);
51 WideCharToMultiByte(CP_ACP, 0, lf.lfFaceName, -1,
52 FaceName, sizeof(FaceName), NULL, NULL);
54 if(FaceName[0] == '\0') {
55 switch(lf.lfPitchAndFamily & 0xf0) {
56 case FF_DONTCARE:
57 break;
58 case FF_ROMAN:
59 case FF_SCRIPT:
60 strcpy(FaceName, "Times");
61 break;
62 case FF_SWISS:
63 strcpy(FaceName, "Helvetica");
64 break;
65 case FF_MODERN:
66 strcpy(FaceName, "Courier");
67 break;
68 case FF_DECORATIVE:
69 strcpy(FaceName, "Symbol");
70 break;
74 if(FaceName[0] == '\0') {
75 switch(lf.lfPitchAndFamily & 0x0f) {
76 case VARIABLE_PITCH:
77 strcpy(FaceName, "Times");
78 break;
79 default:
80 strcpy(FaceName, "Courier");
81 break;
85 if (physDev->pi->FontSubTableSize != 0)
87 DWORD i;
89 for (i = 0; i < physDev->pi->FontSubTableSize; ++i)
91 if (!strcasecmp (FaceName,
92 physDev->pi->FontSubTable[i].pValueName))
94 TRACE ("substituting facename '%s' for '%s'\n",
95 (LPSTR) physDev->pi->FontSubTable[i].pData, FaceName);
96 if (strlen ((LPSTR) physDev->pi->FontSubTable[i].pData) <
97 LF_FACESIZE)
99 strcpy (FaceName,
100 (LPSTR) physDev->pi->FontSubTable[i].pData);
101 subst = TRUE;
103 else
104 WARN ("Facename '%s' is too long; ignoring substitution\n",
105 (LPSTR) physDev->pi->FontSubTable[i].pData);
106 break;
111 physDev->font.escapement = lf.lfEscapement;
112 physDev->font.set = FALSE;
114 if(gdiFont && !subst) {
115 if(PSDRV_SelectDownloadFont(physDev))
116 return 0; /* use gdi font */
119 PSDRV_SelectBuiltinFont(physDev, hfont, &lf, FaceName);
120 return (HFONT)1; /* use device font */
123 /***********************************************************************
124 * PSDRV_SetFont
126 BOOL PSDRV_SetFont( PSDRV_PDEVICE *physDev )
128 PSDRV_WriteSetColor(physDev, &physDev->font.color);
129 if(physDev->font.set) return TRUE;
131 switch(physDev->font.fontloc) {
132 case Builtin:
133 PSDRV_WriteSetBuiltinFont(physDev);
134 break;
135 case Download:
136 PSDRV_WriteSetDownloadFont(physDev);
137 break;
138 default:
139 ERR("fontloc = %d\n", physDev->font.fontloc);
140 assert(1);
141 break;
143 physDev->font.set = TRUE;
144 return TRUE;