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
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
36 /***********************************************************************
37 * SelectFont (WINEPS.@)
39 HFONT CDECL
PSDRV_SelectFont( PSDRV_PDEVICE
*physDev
, HFONT hfont
, HANDLE gdiFont
)
43 char FaceName
[LF_FACESIZE
];
45 if (!GetObjectW( hfont
, sizeof(lf
), &lf
)) return HGDI_ERROR
;
47 TRACE("FaceName = %s Height = %d Italic = %d Weight = %d\n",
48 debugstr_w(lf
.lfFaceName
), lf
.lfHeight
, lf
.lfItalic
,
51 WideCharToMultiByte(CP_ACP
, 0, lf
.lfFaceName
, -1,
52 FaceName
, sizeof(FaceName
), NULL
, NULL
);
54 if(FaceName
[0] == '\0') {
55 switch(lf
.lfPitchAndFamily
& 0xf0) {
60 strcpy(FaceName
, "Times");
63 strcpy(FaceName
, "Helvetica");
66 strcpy(FaceName
, "Courier");
69 strcpy(FaceName
, "Symbol");
74 if(FaceName
[0] == '\0') {
75 switch(lf
.lfPitchAndFamily
& 0x0f) {
77 strcpy(FaceName
, "Times");
80 strcpy(FaceName
, "Courier");
85 if (physDev
->pi
->FontSubTableSize
!= 0)
89 for (i
= 0; i
< physDev
->pi
->FontSubTableSize
; ++i
)
91 if (!strcasecmp (FaceName
,
92 physDev
->pi
->FontSubTable
[i
].pValueName
))
94 TRACE ("substituting facename '%s' for '%s'\n",
95 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
, FaceName
);
96 if (strlen ((LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
) <
100 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
);
104 WARN ("Facename '%s' is too long; ignoring substitution\n",
105 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
);
111 physDev
->font
.escapement
= lf
.lfEscapement
;
112 physDev
->font
.set
= FALSE
;
114 if(gdiFont
&& !subst
) {
115 if(PSDRV_SelectDownloadFont(physDev
))
116 return 0; /* use gdi font */
119 PSDRV_SelectBuiltinFont(physDev
, hfont
, &lf
, FaceName
);
120 return (HFONT
)1; /* use device font */
123 /***********************************************************************
126 BOOL
PSDRV_SetFont( PSDRV_PDEVICE
*physDev
)
128 PSDRV_WriteSetColor(physDev
, &physDev
->font
.color
);
129 if(physDev
->font
.set
) return TRUE
;
131 switch(physDev
->font
.fontloc
) {
133 PSDRV_WriteSetBuiltinFont(physDev
);
136 PSDRV_WriteSetDownloadFont(physDev
);
139 ERR("fontloc = %d\n", physDev
->font
.fontloc
);
143 physDev
->font
.set
= TRUE
;