wineps: Store font related strings in unicode.
[wine.git] / dlls / wineps.drv / font.c
blobcc219724aeed912d75fba9b12ed493e80e394ddd
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;
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 = %ld Italic = %d Weight = %ld\n",
53 debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
54 lf.lfWeight);
56 if(lf.lfFaceName[0] == '\0') {
57 switch(lf.lfPitchAndFamily & 0xf0) {
58 case FF_DONTCARE:
59 break;
60 case FF_ROMAN:
61 case FF_SCRIPT:
62 wcscpy(lf.lfFaceName, L"Times");
63 break;
64 case FF_SWISS:
65 wcscpy(lf.lfFaceName, L"Helvetica");
66 break;
67 case FF_MODERN:
68 wcscpy(lf.lfFaceName, L"Courier");
69 break;
70 case FF_DECORATIVE:
71 wcscpy(lf.lfFaceName, L"Symbol");
72 break;
76 if(lf.lfFaceName[0] == '\0') {
77 switch(lf.lfPitchAndFamily & 0x0f) {
78 case VARIABLE_PITCH:
79 wcscpy(lf.lfFaceName, L"Times");
80 break;
81 default:
82 wcscpy(lf.lfFaceName, L"Courier");
83 break;
87 if (physDev->pi->FontSubTableSize != 0)
89 DWORD i;
91 for (i = 0; i < physDev->pi->FontSubTableSize; ++i)
93 if (!wcsicmp (lf.lfFaceName,
94 physDev->pi->FontSubTable[i].pValueName))
96 TRACE("substituting facename %s for %s\n",
97 debugstr_w((WCHAR *)physDev->pi->FontSubTable[i].pData), debugstr_w(lf.lfFaceName));
98 if (wcslen((WCHAR *)physDev->pi->FontSubTable[i].pData) < LF_FACESIZE)
100 wcscpy(lf.lfFaceName, (WCHAR *)physDev->pi->FontSubTable[i].pData);
101 subst = TRUE;
103 else
104 WARN("Facename %s is too long; ignoring substitution\n",
105 debugstr_w((WCHAR *)physDev->pi->FontSubTable[i].pData));
106 break;
111 physDev->font.escapement = lf.lfEscapement;
112 physDev->font.set = UNSET;
114 if (!subst && ((ret = next->funcs->pSelectFont( next, hfont, aa_flags ))))
116 PSDRV_SelectDownloadFont(dev);
117 return ret;
120 PSDRV_SelectBuiltinFont(dev, hfont, &lf, lf.lfFaceName);
121 next->funcs->pSelectFont( next, 0, aa_flags ); /* tell next driver that we selected a device font */
122 return hfont;
125 /***********************************************************************
126 * PSDRV_SetFont
128 BOOL PSDRV_SetFont( PHYSDEV dev, BOOL vertical )
130 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
132 PSDRV_WriteSetColor(dev, &physDev->font.color);
133 if (vertical && (physDev->font.set == VERTICAL_SET)) return TRUE;
134 if (!vertical && (physDev->font.set == HORIZONTAL_SET)) return TRUE;
136 switch(physDev->font.fontloc) {
137 case Builtin:
138 PSDRV_WriteSetBuiltinFont(dev);
139 break;
140 case Download:
141 PSDRV_WriteSetDownloadFont(dev, vertical);
142 break;
143 default:
144 ERR("fontloc = %d\n", physDev->font.fontloc);
145 assert(1);
146 break;
148 if (vertical)
149 physDev->font.set = VERTICAL_SET;
150 else
151 physDev->font.set = HORIZONTAL_SET;
152 return TRUE;