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
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
30 /***********************************************************************
31 * SelectFont (WINEPS.@)
33 HFONT PSDRV_SelectFont( PSDRV_PDEVICE *physDev, HFONT hfont )
37 char FaceName[LF_FACESIZE];
39 if (!GetObjectW( hfont, sizeof(lf), &lf )) return HGDI_ERROR;
41 TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n",
42 debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
45 WideCharToMultiByte(CP_ACP, 0, lf.lfFaceName, -1,
46 FaceName, sizeof(FaceName), NULL, NULL);
48 if(FaceName[0] == '\0') {
49 switch(lf.lfPitchAndFamily & 0xf0) {
54 strcpy(FaceName, "Times");
57 strcpy(FaceName, "Helvetica");
60 strcpy(FaceName, "Courier");
63 strcpy(FaceName, "Symbol");
68 if(FaceName[0] == '\0') {
69 switch(lf.lfPitchAndFamily & 0x0f) {
71 strcpy(FaceName, "Times");
74 strcpy(FaceName, "Courier");
79 if (physDev->pi->FontSubTableSize != 0)
83 for (i = 0; i < physDev->pi->FontSubTableSize; ++i)
85 if (!strcasecmp (FaceName,
86 physDev->pi->FontSubTable[i].pValueName))
88 TRACE ("substituting facename '%s' for '%s'\n",
89 (LPSTR) physDev->pi->FontSubTable[i].pData, FaceName);
90 if (strlen ((LPSTR) physDev->pi->FontSubTable[i].pData) <
94 (LPSTR) physDev->pi->FontSubTable[i].pData);
98 WARN ("Facename '%s' is too long; ignoring substitution\n",
99 (LPSTR) physDev->pi->FontSubTable[i].pData);
105 physDev->font.escapement = lf.lfEscapement;
106 physDev->font.set = FALSE;
108 if(physDev->dc->gdiFont && !subst) {
109 if(PSDRV_SelectDownloadFont(physDev))
110 return 0; /* use gdi font */
113 PSDRV_SelectBuiltinFont(physDev, hfont, &lf, FaceName);
114 return (HFONT)1; /* use device font */
117 /***********************************************************************
120 BOOL PSDRV_SetFont( PSDRV_PDEVICE *physDev )
122 PSDRV_WriteSetColor(physDev, &physDev->font.color);
123 if(physDev->font.set) return TRUE;
125 switch(physDev->font.fontloc) {
127 PSDRV_WriteSetBuiltinFont(physDev);
130 PSDRV_WriteSetDownloadFont(physDev);
133 ERR("fontloc = %d\n", physDev->font.fontloc);
137 physDev->font.set = TRUE;