kernel32: Update version to Win 10.
[wine.git] / dlls / wineps.drv / font.c
blobcfb3669fd3682da9b503e0542cbf41f45a9dc432
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"
30 #include "winternl.h"
32 #include "psdrv.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
37 /***********************************************************************
38 * SelectFont (WINEPS.@)
40 HFONT CDECL PSDRV_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
42 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
43 PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectFont );
44 HFONT ret;
45 LOGFONTW lf;
46 BOOL subst = FALSE;
47 char FaceName[LF_FACESIZE];
49 if (!GetObjectW( hfont, sizeof(lf), &lf )) return 0;
51 *aa_flags = GGO_BITMAP; /* no anti-aliasing on printer devices */
53 TRACE("FaceName = %s Height = %d Italic = %d Weight = %d\n",
54 debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
55 lf.lfWeight);
57 WideCharToMultiByte(CP_ACP, 0, lf.lfFaceName, -1,
58 FaceName, sizeof(FaceName), NULL, NULL);
60 if(FaceName[0] == '\0') {
61 switch(lf.lfPitchAndFamily & 0xf0) {
62 case FF_DONTCARE:
63 break;
64 case FF_ROMAN:
65 case FF_SCRIPT:
66 strcpy(FaceName, "Times");
67 break;
68 case FF_SWISS:
69 strcpy(FaceName, "Helvetica");
70 break;
71 case FF_MODERN:
72 strcpy(FaceName, "Courier");
73 break;
74 case FF_DECORATIVE:
75 strcpy(FaceName, "Symbol");
76 break;
80 if(FaceName[0] == '\0') {
81 switch(lf.lfPitchAndFamily & 0x0f) {
82 case VARIABLE_PITCH:
83 strcpy(FaceName, "Times");
84 break;
85 default:
86 strcpy(FaceName, "Courier");
87 break;
91 if (physDev->pi->FontSubTableSize != 0)
93 DWORD i;
95 for (i = 0; i < physDev->pi->FontSubTableSize; ++i)
97 if (!stricmp (FaceName,
98 physDev->pi->FontSubTable[i].pValueName))
100 TRACE ("substituting facename '%s' for '%s'\n",
101 (LPSTR) physDev->pi->FontSubTable[i].pData, FaceName);
102 if (strlen ((LPSTR) physDev->pi->FontSubTable[i].pData) <
103 LF_FACESIZE)
105 strcpy (FaceName,
106 (LPSTR) physDev->pi->FontSubTable[i].pData);
107 subst = TRUE;
109 else
110 WARN ("Facename '%s' is too long; ignoring substitution\n",
111 (LPSTR) physDev->pi->FontSubTable[i].pData);
112 break;
117 physDev->font.escapement = lf.lfEscapement;
118 physDev->font.set = UNSET;
120 if (!subst && ((ret = next->funcs->pSelectFont( next, hfont, aa_flags ))))
122 PSDRV_SelectDownloadFont(dev);
123 return ret;
126 PSDRV_SelectBuiltinFont(dev, hfont, &lf, FaceName);
127 next->funcs->pSelectFont( next, 0, aa_flags ); /* tell next driver that we selected a device font */
128 return hfont;
131 /***********************************************************************
132 * PSDRV_SetFont
134 BOOL PSDRV_SetFont( PHYSDEV dev, BOOL vertical )
136 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
138 PSDRV_WriteSetColor(dev, &physDev->font.color);
139 if (vertical && (physDev->font.set == VERTICAL_SET)) return TRUE;
140 if (!vertical && (physDev->font.set == HORIZONTAL_SET)) return TRUE;
142 switch(physDev->font.fontloc) {
143 case Builtin:
144 PSDRV_WriteSetBuiltinFont(dev);
145 break;
146 case Download:
147 PSDRV_WriteSetDownloadFont(dev, vertical);
148 break;
149 default:
150 ERR("fontloc = %d\n", physDev->font.fontloc);
151 assert(1);
152 break;
154 if (vertical)
155 physDev->font.set = VERTICAL_SET;
156 else
157 physDev->font.set = HORIZONTAL_SET;
158 return TRUE;