source: trunk/src/gdi32/font.cpp@ 1697

Last change on this file since 1697 was 1697, checked in by phaller, 26 years ago

Fix: code cleaning + debug info

File size: 14.3 KB
Line 
1/* $Id: font.cpp,v 1.3 1999-11-10 22:44:19 phaller Exp $ */
2
3/*
4 * GDI32 font apis
5 *
6 * Copyright 1999 Edgar Buerkle (Edgar.Buerkle@gmx.ne)
7 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
8 * Copyright 1998 Patrick Haller
9 *
10 * TODO: EnumFontsA/W, EnumFontFamiliesExA/W + others
11 *
12 * Project Odin Software License can be found in LICENSE.TXT
13 *
14 */
15
16#include <odin.h>
17#include <odinwrap.h>
18#include <os2sel.h>
19
20#include <os2win.h>
21#include <stdlib.h>
22#include <stdarg.h>
23#include <string.h>
24#include "misc.h"
25#include "unicode.h"
26#include <vmutex.h>
27
28
29ODINDEBUGCHANNEL(GDI32-FONT)
30
31
32VMutex mutexProcWinA;
33VMutex mutexProcWinW;
34FONTENUMPROCA FontEnumProcWinA;
35FONTENUMPROCW FontEnumProcWinW;
36
37//******************************************************************************
38//******************************************************************************
39ODINFUNCTION14(HFONT, CreateFontA,
40 int, nHeight,
41 int, nWidth,
42 int, nEscapement,
43 int, nOrientation,
44 int, fnWeight,
45 DWORD, fdwItalic,
46 DWORD, fdwUnderline,
47 DWORD, fdwStrikeOut,
48 DWORD, fdwCharSet,
49 DWORD, fdwOutputPrecision,
50 DWORD, fdwClipPrecision,
51 DWORD, fdwQuality,
52 DWORD, fdwPitchAndFamily,
53 LPCSTR, lpszFace)
54{
55 dprintf(("lpszFace = %s\n", lpszFace));
56
57 return O32_CreateFont(nHeight,
58 nWidth,
59 nEscapement,
60 nOrientation,
61 fnWeight,
62 fdwItalic,
63 fdwUnderline,
64 fdwStrikeOut,
65 fdwCharSet,
66 fdwOutputPrecision,
67 fdwClipPrecision,
68 fdwQuality,
69 fdwPitchAndFamily,
70 lpszFace);
71}
72//******************************************************************************
73//******************************************************************************
74ODINFUNCTION14(HFONT, CreateFontW,
75 int, nHeight,
76 int, nWidth,
77 int, nEscapement,
78 int, nOrientation,
79 int, fnWeight,
80 DWORD, fdwItalic,
81 DWORD, fdwUnderline,
82 DWORD, fdwStrikeOut,
83 DWORD, fdwCharSet,
84 DWORD, fdwOutputPrecision,
85 DWORD, fdwClipPrecision,
86 DWORD, fdwQuality,
87 DWORD, fdwPitchAndFamily,
88 LPCWSTR,lpszFace)
89{
90 char *astring;
91 HFONT hFont;
92
93 // NULL is valid for lpszFace
94 if(lpszFace != NULL)
95 astring = UnicodeToAsciiString((LPWSTR)lpszFace);
96 else
97 astring = NULL;
98
99 // @@@PH switch to ODIN_ later
100 hFont = CreateFontA(nHeight,
101 nWidth,
102 nEscapement,
103 nOrientation,
104 fnWeight,
105 fdwItalic,
106 fdwUnderline,
107 fdwStrikeOut,
108 fdwCharSet,
109 fdwOutputPrecision,
110 fdwClipPrecision,
111 fdwQuality,
112 fdwPitchAndFamily,
113 astring);
114 if (astring != NULL)
115 FreeAsciiString(astring);
116
117 return(hFont);
118}
119
120//******************************************************************************
121//******************************************************************************
122HFONT WIN32API CreateFontIndirectA(const LOGFONTA *lplf)
123{
124 HFONT rc;
125
126 dprintf(("GDI32: CreateFontIndirectA\n"));
127 dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));
128 dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));
129 dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement));
130 dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation));
131 dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight));
132 dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic));
133 dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline));
134 dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut));
135 dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet));
136 dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision));
137 dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision));
138 dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality));
139 dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily));
140 dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName));
141 rc = O32_CreateFontIndirect(lplf);
142 dprintf(("GDI32: OS2CreateFontIndirectA returned %X\n", rc));
143 return(rc);
144}
145//******************************************************************************
146//******************************************************************************
147ODINFUNCTION1(HFONT, CreateFontIndirectW,const LOGFONTW *, lplf)
148{
149 LOGFONTA afont;
150 HFONT hfont;
151
152 //memcpy(&afont, lplf, ((int)&afont.lfFaceName - (int)&afont));
153 memcpy(&afont, lplf, sizeof(LOGFONTA));
154 memset(afont.lfFaceName, 0, LF_FACESIZE);
155 UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
156 hfont = CreateFontIndirectA(&afont);
157 return(hfont);
158}
159//******************************************************************************
160//******************************************************************************
161int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
162 lpTextM, DWORD arg3, LPARAM arg4)
163{
164 return FontEnumProcWinA(lpLogFont, lpTextM, arg3, arg4);
165}
166//******************************************************************************
167//******************************************************************************
168int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
169 DWORD arg3, LPARAM arg4)
170{
171 ENUMLOGFONTW LogFont;
172 int rc;
173
174 memcpy(&LogFont, lpLogFont, ((int)&LogFont.elfLogFont.lfFaceName -
175 (int)&LogFont));
176 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
177 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
178 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
179
180 rc = FontEnumProcWinW(&LogFont, (LPNEWTEXTMETRICW) lpTextM, arg3, arg4);
181 return rc;
182}
183//******************************************************************************
184//******************************************************************************
185int WIN32API EnumFontsA( HDC arg1, LPCSTR arg2, FONTENUMPROCA arg3, LPARAM arg4)
186{
187 dprintf(("GDI32: OS2EnumFontsA"));
188// return O32_EnumFonts(arg1, arg2, arg3, arg4);
189 return 1;
190}
191//******************************************************************************
192//TODO: Callback
193//******************************************************************************
194int WIN32API EnumFontsW( HDC arg1, LPCWSTR arg2, FONTENUMPROCW arg3, LPARAM arg4)
195{
196 dprintf(("GDI32: OS2EnumFontsW - stub (1)"));
197 // NOTE: This will not work as is (needs UNICODE support)
198// return O32_EnumFonts(arg1, arg2, arg3, arg4);
199 return 1;
200}
201//******************************************************************************
202//******************************************************************************
203int WIN32API EnumFontFamiliesA(HDC arg1,
204 LPCSTR arg2,
205 FONTENUMPROCA arg3,
206 LPARAM arg4)
207{
208 int rc;
209
210 dprintf(("GDI32: OS2EnumFontFamiliesA "));
211
212 mutexProcWinA.enter();
213
214 FontEnumProcWinA = arg3;
215
216 rc = O32_EnumFontFamilies(arg1, arg2, &EnumFontProcA, arg4);
217
218 mutexProcWinA.leave();
219 return rc;
220}
221//******************************************************************************
222//******************************************************************************
223int WIN32API EnumFontFamiliesW(HDC arg1,
224 LPCWSTR arg2,
225 FONTENUMPROCW arg3,
226 LPARAM arg4)
227{
228 int rc;
229 char *astring = UnicodeToAsciiString((LPWSTR)arg2);
230
231 dprintf(("GDI32: OS2EnumFontFamiliesW "));
232
233 mutexProcWinW.enter();
234
235 FontEnumProcWinW = arg3;
236
237 rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcW, arg4);
238
239 mutexProcWinW.leave();
240
241 FreeAsciiString(astring);
242 return rc;
243}
244//******************************************************************************
245//******************************************************************************
246INT WIN32API EnumFontFamiliesExA( HDC arg1, LPLOGFONTA arg2, FONTENUMPROCEXA arg3, LPARAM arg4, DWORD dwFlags)
247{
248 dprintf(("GDI32: OS2EnumFontFamiliesExA, not implemented\n"));
249 return 0;
250}
251//******************************************************************************
252//******************************************************************************
253INT WIN32API EnumFontFamiliesExW( HDC arg1, LPLOGFONTW arg2, FONTENUMPROCEXW arg3, LPARAM arg4, DWORD dwFlags)
254{
255 dprintf(("GDI32: OS2EnumFontFamiliesW, not implemented\n"));
256 // NOTE: This will not work as is (needs UNICODE support)
257 return 0;
258}
259//******************************************************************************
260//******************************************************************************
261DWORD WIN32API GetFontData(HDC hdc, DWORD dwTable, DWORD dwOffset, LPVOID lpvBuffer,
262 DWORD dbData)
263{
264 dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
265 return(GDI_ERROR);
266}
267//******************************************************************************
268//******************************************************************************
269int WIN32API AddFontResourceA( LPCSTR arg1)
270{
271 dprintf(("GDI32: OS2AddFontResourceA"));
272 return O32_AddFontResource(arg1);
273}
274//******************************************************************************
275//******************************************************************************
276int WIN32API AddFontResourceW( LPCWSTR arg1)
277{
278 dprintf(("GDI32: OS2AddFontResourceW STUB"));
279 // NOTE: This will not work as is (needs UNICODE support)
280// return O32_AddFontResource(arg1);
281 return 0;
282}
283//******************************************************************************
284//******************************************************************************
285BOOL WIN32API RemoveFontResourceA( LPCSTR arg1)
286{
287 dprintf(("GDI32: OS2RemoveFontResourceA %s\n", arg1));
288 return O32_RemoveFontResource(arg1);
289}
290//******************************************************************************
291//******************************************************************************
292BOOL WIN32API RemoveFontResourceW(LPCWSTR arg1)
293{
294 char *astring = UnicodeToAsciiString((LPWSTR)arg1);
295 BOOL rc;
296
297 dprintf(("GDI32: OS2RemoveFontResourceW\n"));
298 rc = O32_RemoveFontResource(astring);
299 FreeAsciiString(astring);
300 return(rc);
301}
302/*****************************************************************************
303 * Name : BOOL CreateScalableFontResourceA
304 * Purpose : The CreateScalableFontResourceA function creates a font resource
305 * file for a scalable font.
306 * Parameters: DWORD fdwHidden flag for read-only embedded font
307 * LPCSTR lpszFontRes address of filename for font resource
308 * LPCSTR lpszFontFile address of filename for scalable font
309 * LPCSTR lpszCurrentPath address of path to font file
310 * Variables :
311 * Result : TRUE / FALSE
312 * Remark :
313 * Status : UNTESTED STUB
314 *
315 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
316 *****************************************************************************/
317
318BOOL WIN32API CreateScalableFontResourceA(DWORD fdwHidden,
319 LPCSTR lpszFontRes,
320 LPCSTR lpszFontFile,
321 LPCSTR lpszCurrentPath)
322{
323 dprintf(("GDI32: CreateScalableFontResourceA(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
324 fdwHidden,
325 lpszFontRes,
326 lpszFontFile,
327 lpszCurrentPath));
328
329 return (FALSE);
330}
331
332
333/*****************************************************************************
334 * Name : BOOL CreateScalableFontResourceW
335 * Purpose : The CreateScalableFontResourceW function creates a font resource
336 * file for a scalable font.
337 * Parameters: DWORD fdwHidden flag for read-only embedded font
338 * LPCSTR lpszFontRes address of filename for font resource
339 * LPCSTR lpszFontFile address of filename for scalable font
340 * LPCSTR lpszCurrentPath address of path to font file
341 * Variables :
342 * Result : TRUE / FALSE
343 * Remark :
344 * Status : UNTESTED STUB
345 *
346 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
347 *****************************************************************************/
348
349BOOL WIN32API CreateScalableFontResourceW(DWORD fdwHidden,
350 LPCWSTR lpszFontRes,
351 LPCWSTR lpszFontFile,
352 LPCWSTR lpszCurrentPath)
353{
354 dprintf(("GDI32: CreateScalableFontResourceW(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
355 fdwHidden,
356 lpszFontRes,
357 lpszFontFile,
358 lpszCurrentPath));
359
360 return (FALSE);
361}
362/*****************************************************************************
363 * Name : DWORD GetFontLanguageInfo
364 * Purpose : The GetFontLanguageInfo function returns information about the
365 * currently selected font for the specified display context.
366 * Applications typically use this information and the
367 * GetCharacterPlacement function to prepare a character string for display.
368 * Parameters: HDC hdc handle to device context
369 * Variables :
370 * Result :
371 * Remark :
372 * Status : UNTESTED STUB
373 *
374 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
375 *****************************************************************************/
376
377DWORD WIN32API GetFontLanguageInfo(HDC hdc)
378{
379 dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
380 hdc));
381
382 return (0);
383}
384//******************************************************************************
385//******************************************************************************
Note: See TracBrowser for help on using the repository browser.