Remove extra #include directives from winspool.h.
[wine/multimedia.git] / dlls / wineps / font.c
blobd99b6f0f9fbcc5e32410d3962d56c99262fc738b
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <string.h>
21 #include <assert.h>
22 #include <stdlib.h>
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "winspool.h"
28 #include "gdi.h"
29 #include "psdrv.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
34 /***********************************************************************
35 * SelectFont (WINEPS.@)
37 HFONT PSDRV_SelectFont( PSDRV_PDEVICE *physDev, HFONT hfont )
39 LOGFONTW lf;
40 BOOL subst = FALSE;
41 char FaceName[LF_FACESIZE];
43 if (!GetObjectW( hfont, sizeof(lf), &lf )) return HGDI_ERROR;
45 TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n",
46 debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
47 lf.lfWeight);
49 WideCharToMultiByte(CP_ACP, 0, lf.lfFaceName, -1,
50 FaceName, sizeof(FaceName), NULL, NULL);
52 if(FaceName[0] == '\0') {
53 switch(lf.lfPitchAndFamily & 0xf0) {
54 case FF_DONTCARE:
55 break;
56 case FF_ROMAN:
57 case FF_SCRIPT:
58 strcpy(FaceName, "Times");
59 break;
60 case FF_SWISS:
61 strcpy(FaceName, "Helvetica");
62 break;
63 case FF_MODERN:
64 strcpy(FaceName, "Courier");
65 break;
66 case FF_DECORATIVE:
67 strcpy(FaceName, "Symbol");
68 break;
72 if(FaceName[0] == '\0') {
73 switch(lf.lfPitchAndFamily & 0x0f) {
74 case VARIABLE_PITCH:
75 strcpy(FaceName, "Times");
76 break;
77 default:
78 strcpy(FaceName, "Courier");
79 break;
83 if (physDev->pi->FontSubTableSize != 0)
85 DWORD i;
87 for (i = 0; i < physDev->pi->FontSubTableSize; ++i)
89 if (!strcasecmp (FaceName,
90 physDev->pi->FontSubTable[i].pValueName))
92 TRACE ("substituting facename '%s' for '%s'\n",
93 (LPSTR) physDev->pi->FontSubTable[i].pData, FaceName);
94 if (strlen ((LPSTR) physDev->pi->FontSubTable[i].pData) <
95 LF_FACESIZE)
97 strcpy (FaceName,
98 (LPSTR) physDev->pi->FontSubTable[i].pData);
99 subst = TRUE;
101 else
102 WARN ("Facename '%s' is too long; ignoring substitution\n",
103 (LPSTR) physDev->pi->FontSubTable[i].pData);
104 break;
109 physDev->font.escapement = lf.lfEscapement;
110 physDev->font.set = FALSE;
112 if(physDev->dc->gdiFont && !subst) {
113 if(PSDRV_SelectDownloadFont(physDev))
114 return 0; /* use gdi font */
117 PSDRV_SelectBuiltinFont(physDev, hfont, &lf, FaceName);
118 return (HFONT)1; /* use device font */
121 /***********************************************************************
122 * PSDRV_SetFont
124 BOOL PSDRV_SetFont( PSDRV_PDEVICE *physDev )
126 PSDRV_WriteSetColor(physDev, &physDev->font.color);
127 if(physDev->font.set) return TRUE;
129 switch(physDev->font.fontloc) {
130 case Builtin:
131 PSDRV_WriteSetBuiltinFont(physDev);
132 break;
133 case Download:
134 PSDRV_WriteSetDownloadFont(physDev);
135 break;
136 default:
137 ERR("fontloc = %d\n", physDev->font.fontloc);
138 assert(1);
139 break;
141 physDev->font.set = TRUE;
142 return TRUE;