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
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
34 /***********************************************************************
35 * SelectFont (WINEPS.@)
37 HFONT
PSDRV_SelectFont( PSDRV_PDEVICE
*physDev
, HFONT hfont
)
41 char FaceName
[LF_FACESIZE
];
43 if (!GetObjectW( hfont
, sizeof(lf
), &lf
)) return HGDI_ERROR
;
45 TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n",
46 debugstr_w(lf
.lfFaceName
), lf
.lfHeight
, lf
.lfItalic
,
49 WideCharToMultiByte(CP_ACP
, 0, lf
.lfFaceName
, -1,
50 FaceName
, sizeof(FaceName
), NULL
, NULL
);
52 if(FaceName
[0] == '\0') {
53 switch(lf
.lfPitchAndFamily
& 0xf0) {
58 strcpy(FaceName
, "Times");
61 strcpy(FaceName
, "Helvetica");
64 strcpy(FaceName
, "Courier");
67 strcpy(FaceName
, "Symbol");
72 if(FaceName
[0] == '\0') {
73 switch(lf
.lfPitchAndFamily
& 0x0f) {
75 strcpy(FaceName
, "Times");
78 strcpy(FaceName
, "Courier");
83 if (physDev
->pi
->FontSubTableSize
!= 0)
87 for (i
= 0; i
< physDev
->pi
->FontSubTableSize
; ++i
)
89 if (!strcasecmp (FaceName
,
90 physDev
->pi
->FontSubTable
[i
].pValueName
))
92 TRACE ("substituting facename '%s' for '%s'\n",
93 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
, FaceName
);
94 if (strlen ((LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
) <
98 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
);
102 WARN ("Facename '%s' is too long; ignoring substitution\n",
103 (LPSTR
) physDev
->pi
->FontSubTable
[i
].pData
);
109 physDev
->font
.escapement
= lf
.lfEscapement
;
110 physDev
->font
.set
= FALSE
;
112 if(physDev
->dc
->gdiFont
&& !subst
) {
113 if(PSDRV_SelectDownloadFont(physDev
))
114 return 0; /* use gdi font */
117 PSDRV_SelectBuiltinFont(physDev
, hfont
, &lf
, FaceName
);
118 return (HFONT
)1; /* use device font */
121 /***********************************************************************
124 BOOL
PSDRV_SetFont( PSDRV_PDEVICE
*physDev
)
126 PSDRV_WriteSetColor(physDev
, &physDev
->font
.color
);
127 if(physDev
->font
.set
) return TRUE
;
129 switch(physDev
->font
.fontloc
) {
131 PSDRV_WriteSetBuiltinFont(physDev
);
134 PSDRV_WriteSetDownloadFont(physDev
);
137 ERR("fontloc = %d\n", physDev
->font
.fontloc
);
141 physDev
->font
.set
= TRUE
;