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
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
35 /***********************************************************************
36 * SelectFont (WINEPS.@)
38 HFONT CDECL
PSDRV_SelectFont( PSDRV_PDEVICE
*physDev
, HFONT hfont
, HANDLE gdiFont
)
42 char FaceName
[LF_FACESIZE
];
44 if (!GetObjectW( hfont
, sizeof(lf
), &lf
)) return HGDI_ERROR
;
46 TRACE("FaceName = %s Height = %d Italic = %d Weight = %d\n",
47 debugstr_w(lf
.lfFaceName
), lf
.lfHeight
, lf
.lfItalic
,
50 WideCharToMultiByte(CP_ACP
, 0, lf
.lfFaceName
, -1,
51 FaceName
, sizeof(FaceName
), NULL
, NULL
);
53 if(FaceName
[0] == '\0') {
54 switch(lf
.lfPitchAndFamily
& 0xf0) {
59 strcpy(FaceName
, "Times");
62 strcpy(FaceName
, "Helvetica");
65 strcpy(FaceName
, "Courier");
68 strcpy(FaceName
, "Symbol");
73 if(FaceName
[0] == '\0') {
74 switch(lf
.lfPitchAndFamily
& 0x0f) {
76 strcpy(FaceName
, "Times");
79 strcpy(FaceName
, "Courier");
84 if (physDev
->pi
->FontSubTableSize
!= 0)
88 for (i
= 0; i
< physDev
->pi
->FontSubTableSize
; ++i
)
90 if (!strcasecmp (FaceName
,
91 physDev
->pi
->FontSubTable
[i
].pValueName
))
93 TRACE ("substituting facename '%s' for '%s'\n",
94 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
, FaceName
);
95 if (strlen ((LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
) <
99 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
);
103 WARN ("Facename '%s' is too long; ignoring substitution\n",
104 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
);
110 physDev
->font
.escapement
= lf
.lfEscapement
;
111 physDev
->font
.set
= FALSE
;
113 if(gdiFont
&& !subst
) {
114 if(PSDRV_SelectDownloadFont(physDev
))
115 return 0; /* use gdi font */
118 PSDRV_SelectBuiltinFont(physDev
, hfont
, &lf
, FaceName
);
119 return (HFONT
)1; /* use device font */
122 /***********************************************************************
125 BOOL
PSDRV_SetFont( PSDRV_PDEVICE
*physDev
)
127 PSDRV_WriteSetColor(physDev
, &physDev
->font
.color
);
128 if(physDev
->font
.set
) return TRUE
;
130 switch(physDev
->font
.fontloc
) {
132 PSDRV_WriteSetBuiltinFont(physDev
);
135 PSDRV_WriteSetDownloadFont(physDev
);
138 ERR("fontloc = %d\n", physDev
->font
.fontloc
);
142 physDev
->font
.set
= TRUE
;