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

Last change on this file since 8871 was 8871, checked in by sandervl, 23 years ago

Handle management updates

File size: 29.2 KB
Line 
1/* $Id: font.cpp,v 1.26 2002-07-15 10:02:28 sandervl Exp $ */
2
3/*
4 * GDI32 font apis
5 *
6 * Copyright 1999 Edgar Buerkle (Edgar.Buerkle@gmx.ne)
7 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
8 * Copyright 1998 Patrick Haller
9 *
10 * TODO: EnumFontsA/W, EnumFontFamiliesExA/W not complete
11 *
12 * Parts based on Wine code (991031)
13 *
14 * Copyright 1993 Alexandre Julliard
15 * 1997 Alex Korobka
16 *
17 * Project Odin Software License can be found in LICENSE.TXT
18 *
19 */
20
21/*****************************************************************************
22 * Includes *
23 *****************************************************************************/
24
25#include <odin.h>
26#include <odinwrap.h>
27#include <os2sel.h>
28
29#include <os2win.h>
30#include <stdlib.h>
31#include <stdarg.h>
32#include <ctype.h>
33#include <string.h>
34#include "misc.h"
35#include "unicode.h"
36#include <heapstring.h>
37#include <win\options.h>
38#include <wprocess.h>
39#include <odininst.h>
40#include <stats.h>
41
42#define DBG_LOCALLOG DBG_font
43#include "dbglocal.h"
44
45ODINDEBUGCHANNEL(GDI32-FONT)
46
47
48typedef struct {
49 DWORD userProc;
50 DWORD userData;
51 DWORD dwFlags;
52} ENUMUSERDATA;
53
54/*
55 * For TranslateCharsetInfo
56 */
57#define FS(x) {{0,0,0,0},{0x1<<(x),0}}
58#define MAXTCIINDEX 32
59static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
60 /* ANSI */
61 { ANSI_CHARSET, 1252, FS(0)},
62 { EASTEUROPE_CHARSET, 1250, FS(1)},
63 { RUSSIAN_CHARSET, 1251, FS(2)},
64 { GREEK_CHARSET, 1253, FS(3)},
65 { TURKISH_CHARSET, 1254, FS(4)},
66 { HEBREW_CHARSET, 1255, FS(5)},
67 { ARABIC_CHARSET, 1256, FS(6)},
68 { BALTIC_CHARSET, 1257, FS(7)},
69 /* reserved by ANSI */
70 { DEFAULT_CHARSET, 0, FS(0)},
71 { DEFAULT_CHARSET, 0, FS(0)},
72 { DEFAULT_CHARSET, 0, FS(0)},
73 { DEFAULT_CHARSET, 0, FS(0)},
74 { DEFAULT_CHARSET, 0, FS(0)},
75 { DEFAULT_CHARSET, 0, FS(0)},
76 { DEFAULT_CHARSET, 0, FS(0)},
77 { DEFAULT_CHARSET, 0, FS(0)},
78 /* ANSI and OEM */
79 { THAI_CHARSET, 874, FS(16)},
80 { SHIFTJIS_CHARSET, 932, FS(17)},
81 { GB2312_CHARSET, 936, FS(18)},
82 { HANGEUL_CHARSET, 949, FS(19)},
83 { CHINESEBIG5_CHARSET, 950, FS(20)},
84 { JOHAB_CHARSET, 1361, FS(21)},
85 /* reserved for alternate ANSI and OEM */
86 { DEFAULT_CHARSET, 0, FS(0)},
87 { DEFAULT_CHARSET, 0, FS(0)},
88 { DEFAULT_CHARSET, 0, FS(0)},
89 { DEFAULT_CHARSET, 0, FS(0)},
90 { DEFAULT_CHARSET, 0, FS(0)},
91 { DEFAULT_CHARSET, 0, FS(0)},
92 { DEFAULT_CHARSET, 0, FS(0)},
93 { DEFAULT_CHARSET, 0, FS(0)},
94 /* reserved for system */
95 { DEFAULT_CHARSET, 0, FS(0)},
96 { DEFAULT_CHARSET, 0, FS(0)},
97};
98
99HFONT hFntDefaultGui = NULL;
100
101/*****************************************************************************
102 * Name : static void iFontRename
103 * Purpose : font remapping table to map win32 fonts to OS/2 pendants
104 * Parameters: LPSTR lpstrFaceOriginal - the win32 face name
105 * LPSTR lpstrFaceBuffer - [LF_FACESIZE] buffer to new name
106 * Variables :
107 * Result :
108 * Remark : remapped name is passed back in the buffer
109 * if no mapping pendant is available, return input parameter
110 * as default.
111 * Status :
112 *
113 * Author : Patrick Haller [Fri, 1998/06/12 03:44]
114 *****************************************************************************/
115
116static void iFontRename(LPCSTR lpstrFaceOriginal,
117 LPSTR lpstrFaceTemp)
118{
119 int iRet;
120
121 // NULL is a valid parameter
122 if (lpstrFaceOriginal == NULL)
123 return;
124
125 strncpy(lpstrFaceTemp, lpstrFaceOriginal, LF_FACESIZE);
126 lpstrFaceTemp[LF_FACESIZE-1] = 0;
127
128 {
129 char *y = lpstrFaceTemp;
130 while(*y) {
131 if(IsDBCSLeadByte( *y )) {
132 y += 2; // DBCS skip
133 } else {
134 *y = toupper( *y );
135 y++;
136 }
137 }
138 }
139
140 //lookup table
141 iRet = PROFILE_GetOdinIniString(ODINFONTSECTION,
142 lpstrFaceTemp,
143 lpstrFaceOriginal,
144 lpstrFaceTemp,
145 LF_FACESIZE);
146}
147//******************************************************************************
148//******************************************************************************
149ODINFUNCTIONNODBG14(HFONT, CreateFontA, int, nHeight,
150 int, nWidth,
151 int, nEscapement,
152 int, nOrientation,
153 int, fnWeight,
154 DWORD, fdwItalic,
155 DWORD, fdwUnderline,
156 DWORD, fdwStrikeOut,
157 DWORD, fdwCharSet,
158 DWORD, fdwOutputPrecision,
159 DWORD, fdwClipPrecision,
160 DWORD, fdwQuality,
161 DWORD, fdwPitchAndFamily,
162 LPCSTR, lpszFace)
163{
164 CHAR lpstrFaceNew[LF_FACESIZE];
165 HFONT hFont;
166
167 if(lpszFace == NULL)
168 lpszFace = "";
169
170 if(strlen(lpszFace) >= LF_FACESIZE)
171 {
172 dprintf(("ERROR: Invalid string length for font name!!"));
173 SetLastError(ERROR_INVALID_PARAMETER);
174 return 0;
175 }
176
177 iFontRename(lpszFace, lpstrFaceNew);
178
179 dprintf(("lpszFace = %s -> %s\n", lpszFace, lpstrFaceNew));
180
181 LOGFONTA logFont =
182 {
183 nHeight,
184 nWidth,
185 nEscapement,
186 nOrientation,
187 fnWeight,
188 (BYTE)fdwItalic,
189 (BYTE)fdwUnderline,
190 (BYTE)fdwStrikeOut,
191 (BYTE)fdwCharSet,
192 (BYTE)fdwOutputPrecision,
193 (BYTE)fdwClipPrecision,
194 (BYTE)fdwQuality,
195 (BYTE)fdwPitchAndFamily
196 };
197 strcpy(logFont.lfFaceName, lpszFace);
198
199 return CreateFontIndirectA(&logFont);
200}
201//******************************************************************************
202//******************************************************************************
203ODINFUNCTIONNODBG14(HFONT, CreateFontW,
204 int, nHeight,
205 int, nWidth,
206 int, nEscapement,
207 int, nOrientation,
208 int, fnWeight,
209 DWORD, fdwItalic,
210 DWORD, fdwUnderline,
211 DWORD, fdwStrikeOut,
212 DWORD, fdwCharSet,
213 DWORD, fdwOutputPrecision,
214 DWORD, fdwClipPrecision,
215 DWORD, fdwQuality,
216 DWORD, fdwPitchAndFamily,
217 LPCWSTR,lpszFace)
218{
219 char *astring;
220 HFONT hFont;
221
222 // NULL is valid for lpszFace
223 if(lpszFace != NULL)
224 astring = UnicodeToAsciiString((LPWSTR)lpszFace);
225 else
226 astring = NULL;
227
228 // @@@PH switch to ODIN_ later
229 hFont = CreateFontA(nHeight,
230 nWidth,
231 nEscapement,
232 nOrientation,
233 fnWeight,
234 fdwItalic,
235 fdwUnderline,
236 fdwStrikeOut,
237 fdwCharSet,
238 fdwOutputPrecision,
239 fdwClipPrecision,
240 fdwQuality,
241 fdwPitchAndFamily,
242 astring);
243 if (astring != NULL)
244 FreeAsciiString(astring);
245
246 return(hFont);
247}
248
249//******************************************************************************
250//******************************************************************************
251ODINFUNCTION1(HFONT,CreateFontIndirectA,const LOGFONTA*, lplf)
252{
253 HFONT hFont;
254 LOGFONTA afont;
255
256 // don't touch user buffer!
257 memcpy(&afont, lplf, sizeof(LOGFONTA));
258 iFontRename(lplf->lfFaceName, afont.lfFaceName);
259
260 dprintf(("lpszFace = (%x) %s -> %s\n", lplf->lfFaceName, lplf->lfFaceName, afont.lfFaceName));
261
262 dprintf(("GDI32: CreateFontIndirectA\n"));
263 dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));
264 dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));
265 dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement));
266 dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation));
267 dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight));
268 dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic));
269 dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline));
270 dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut));
271 dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet));
272 dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision));
273 dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision));
274 dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality));
275 dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily));
276 dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName));
277
278 hFont = O32_CreateFontIndirect(&afont);
279 if(hFont) {
280 STATS_CreateFontIndirect(hFont, &afont);
281 }
282 return(hFont);
283}
284//******************************************************************************
285//******************************************************************************
286ODINFUNCTION1(HFONT, CreateFontIndirectW,const LOGFONTW *, lplf)
287{
288 LOGFONTA afont;
289 HFONT hfont;
290
291 //memcpy(&afont, lplf, ((ULONG)&afont.lfFaceName - (ULONG)&afont));
292 memcpy(&afont, lplf, sizeof(LOGFONTA));
293 memset(afont.lfFaceName, 0, LF_FACESIZE);
294 dprintf(("lpszFace = (%x)", lplf->lfFaceName));
295
296 UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
297 hfont = CreateFontIndirectA(&afont);
298 return(hfont);
299}
300//******************************************************************************
301//******************************************************************************
302int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
303 lpTextM, DWORD arg3, LPARAM arg4)
304{
305 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
306 FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc;
307 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
308
309 int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData);
310 SetFS(selTIB); // switch back to the saved FS selector
311 return rc;
312}
313//******************************************************************************
314//******************************************************************************
315int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
316 DWORD arg3, LPARAM arg4)
317{
318 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
319 FONTENUMPROCW proc = (FONTENUMPROCW)lpEnumData->userProc;
320 ENUMLOGFONTW LogFont;
321 NEWTEXTMETRICW textM;
322 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
323 int rc;
324
325 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName -
326 (ULONG)&LogFont));
327 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
328 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
329 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
330
331 textM.tmHeight = lpTextM->tmHeight;
332 textM.tmAscent = lpTextM->tmAscent;
333 textM.tmDescent = lpTextM->tmDescent;
334 textM.tmInternalLeading = lpTextM->tmInternalLeading;
335 textM.tmExternalLeading = lpTextM->tmExternalLeading;
336 textM.tmAveCharWidth = lpTextM->tmAveCharWidth;
337 textM.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
338 textM.tmWeight = lpTextM->tmWeight;
339 textM.tmOverhang = lpTextM->tmOverhang;
340 textM.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
341 textM.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
342 textM.tmFirstChar = lpTextM->tmFirstChar;
343 textM.tmLastChar = lpTextM->tmLastChar;
344 textM.tmDefaultChar = lpTextM->tmDefaultChar;
345 textM.tmBreakChar = lpTextM->tmBreakChar;
346 textM.tmItalic = lpTextM->tmItalic;
347 textM.tmUnderlined = lpTextM->tmUnderlined;
348 textM.tmStruckOut = lpTextM->tmStruckOut;
349 textM.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
350 textM.tmCharSet = lpTextM->tmCharSet;
351 textM.ntmFlags = 0;
352 textM.ntmSizeEM = 0;
353 textM.ntmCellHeight = 0;
354 textM.ntmAvgWidth = 0;
355
356 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
357 SetFS(selTIB); // switch back to the saved FS selector
358 return rc;
359}
360//******************************************************************************
361//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
362//******************************************************************************
363int EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
364 lpTextM, DWORD arg3, LPARAM arg4)
365{
366 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
367 FONTENUMPROCEXA proc = (FONTENUMPROCEXA)lpEnumData->userProc;
368 ENUMLOGFONTEXA logFont;
369 NEWTEXTMETRICEXA textM;
370 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
371
372 memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA));
373 memset(logFont.elfScript, 0, sizeof(logFont.elfScript));
374 memcpy(&textM.ntmetm, lpTextM, sizeof(textM.ntmetm));
375 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
376
377 dprintf(("EnumFontProcExA %s height %d", logFont.elfLogFont.lfFaceName, textM.ntmetm.tmHeight));
378
379 int rc = proc(&logFont, &textM, arg3, lpEnumData->userData);
380 SetFS(selTIB); // switch back to the saved FS selector
381 return rc;
382}
383//******************************************************************************
384//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
385//******************************************************************************
386int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
387 DWORD arg3, LPARAM arg4)
388{
389 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
390 FONTENUMPROCEXW proc = (FONTENUMPROCEXW)lpEnumData->userProc;
391 ENUMLOGFONTEXW LogFont;
392 NEWTEXTMETRICEXW textM;
393 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
394 int rc;
395
396 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont));
397 memset(LogFont.elfScript, 0, sizeof(LogFont.elfScript));
398 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
399 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
400 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
401
402 textM.ntmetm.tmHeight = lpTextM->tmHeight;
403 textM.ntmetm.tmAscent = lpTextM->tmAscent;
404 textM.ntmetm.tmDescent = lpTextM->tmDescent;
405 textM.ntmetm.tmInternalLeading = lpTextM->tmInternalLeading;
406 textM.ntmetm.tmExternalLeading = lpTextM->tmExternalLeading;
407 textM.ntmetm.tmAveCharWidth = lpTextM->tmAveCharWidth;
408 textM.ntmetm.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
409 textM.ntmetm.tmWeight = lpTextM->tmWeight;
410 textM.ntmetm.tmOverhang = lpTextM->tmOverhang;
411 textM.ntmetm.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
412 textM.ntmetm.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
413 textM.ntmetm.tmFirstChar = lpTextM->tmFirstChar;
414 textM.ntmetm.tmLastChar = lpTextM->tmLastChar;
415 textM.ntmetm.tmDefaultChar = lpTextM->tmDefaultChar;
416 textM.ntmetm.tmBreakChar = lpTextM->tmBreakChar;
417 textM.ntmetm.tmItalic = lpTextM->tmItalic;
418 textM.ntmetm.tmUnderlined = lpTextM->tmUnderlined;
419 textM.ntmetm.tmStruckOut = lpTextM->tmStruckOut;
420 textM.ntmetm.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
421 textM.ntmetm.tmCharSet = lpTextM->tmCharSet;
422 textM.ntmetm.ntmFlags = 0;
423 textM.ntmetm.ntmSizeEM = 0;
424 textM.ntmetm.ntmCellHeight = 0;
425 textM.ntmetm.ntmAvgWidth = 0;
426 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
427
428 dprintf(("EnumFontProcExW %s height %d", lpLogFont->elfLogFont.lfFaceName, textM.ntmetm.tmHeight));
429 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
430 SetFS(selTIB); // switch back to the saved FS selector
431 return rc;
432}
433//******************************************************************************
434//******************************************************************************
435ODINFUNCTION4(int, EnumFontsA,
436 HDC, hdc,
437 LPCSTR, arg2,
438 FONTENUMPROCA, arg3,
439 LPARAM, arg4)
440{
441 //@@@PH shouldn't this rather be O32_EnumFonts ?
442 return EnumFontFamiliesA(hdc, arg2, arg3, arg4);
443}
444//******************************************************************************
445//******************************************************************************
446ODINFUNCTION4(int, EnumFontsW,
447 HDC, hdc,
448 LPCWSTR, arg2,
449 FONTENUMPROCW, arg3,
450 LPARAM, arg4)
451{
452 //@@@PH shouldn't this rather be O32_EnumFonts ?
453 return EnumFontFamiliesW(hdc, arg2, arg3, arg4);
454}
455//******************************************************************************
456//******************************************************************************
457ODINFUNCTION4(int, EnumFontFamiliesA,
458 HDC, hdc,
459 LPCSTR, lpszFontFamily,
460 FONTENUMPROCA, arg3,
461 LPARAM, arg4)
462{
463 ENUMUSERDATA enumData;
464 CHAR lpstrFamilyNew[LF_FACESIZE] = "";
465 int rc;
466
467 dprintf(("GDI32: EnumFontFamiliesA %s", lpszFontFamily));
468
469 iFontRename(lpszFontFamily, lpstrFamilyNew);
470
471 enumData.userProc = (DWORD)arg3;
472 enumData.userData = arg4;
473
474 rc = O32_EnumFontFamilies(hdc, lpstrFamilyNew, &EnumFontProcA, (LPARAM)&enumData);
475
476 return rc;
477}
478//******************************************************************************
479//******************************************************************************
480ODINFUNCTION4(int, EnumFontFamiliesW,
481 HDC, hdc,
482 LPCWSTR, lpszFontFamilyW,
483 FONTENUMPROCW, arg3,
484 LPARAM, arg4)
485{
486 CHAR lpstrFamilyNew[LF_FACESIZE] = "";
487 ENUMUSERDATA enumData;
488 int rc;
489 char *lpszFontFamilyA = UnicodeToAsciiString((LPWSTR)lpszFontFamilyW);
490
491 dprintf(("GDI32: EnumFontFamiliesW %s", lpszFontFamilyA));
492
493 iFontRename(lpszFontFamilyA, lpstrFamilyNew);
494
495 enumData.userProc = (DWORD)arg3;
496 enumData.userData = arg4;
497
498 rc = O32_EnumFontFamilies(hdc, lpstrFamilyNew, &EnumFontProcW, (LPARAM)&enumData);
499
500 if(lpszFontFamilyA) FreeAsciiString(lpszFontFamilyA);
501 return rc;
502}
503//******************************************************************************
504//******************************************************************************
505ODINFUNCTION5(INT, EnumFontFamiliesExA,
506 HDC, hdc,
507 LPLOGFONTA, arg2,
508 FONTENUMPROCEXA, arg3,
509 LPARAM, arg4,
510 DWORD, dwFlags)
511{
512 ENUMUSERDATA enumData;
513 int rc;
514
515 dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName));
516
517 enumData.userProc = (DWORD)arg3;
518 enumData.userData = arg4;
519 enumData.dwFlags = dwFlags;
520
521 rc = O32_EnumFontFamilies(hdc, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData);
522
523 return rc;
524}
525//******************************************************************************
526//******************************************************************************
527ODINFUNCTION5(INT, EnumFontFamiliesExW,
528 HDC, hdc,
529 LPLOGFONTW, arg2,
530 FONTENUMPROCEXW, arg3,
531 LPARAM, arg4,
532 DWORD, dwFlags)
533{
534 ENUMUSERDATA enumData;
535 int rc;
536 char *astring = UnicodeToAsciiString((LPWSTR)arg2->lfFaceName);
537
538 dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring));
539
540 enumData.userProc = (DWORD)arg3;
541 enumData.userData = arg4;
542 enumData.dwFlags = dwFlags;
543
544 rc = O32_EnumFontFamilies(hdc, astring, &EnumFontProcExW, (LPARAM)&enumData);
545
546 FreeAsciiString(astring);
547 return rc;
548}
549//******************************************************************************
550//******************************************************************************
551ODINFUNCTION5(DWORD, GetFontData,
552 HDC, hdc,
553 DWORD, dwTable,
554 DWORD, dwOffset,
555 LPVOID, lpvBuffer,
556 DWORD, dbData)
557{
558 dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
559 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
560
561 return(GDI_ERROR);
562}
563//******************************************************************************
564//******************************************************************************
565ODINFUNCTION1(int, AddFontResourceA,
566 LPCSTR, szFont)
567{
568 HINSTANCE hInstance;
569
570 dprintf(("GDI32: AddFontResourceA %s", szFont));
571 hInstance = LoadLibraryA(szFont);
572 if(hInstance) {
573 dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED"));
574 FreeLibrary(hInstance);
575 return 1;
576 }
577 return O32_AddFontResource(szFont);
578}
579//******************************************************************************
580//******************************************************************************
581ODINFUNCTION1(int, AddFontResourceW,
582 LPCWSTR, szFont)
583{
584 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
585 BOOL rc;
586
587 dprintf(("GDI32: AddFontResourceW"));
588 // NOTE: This will not work as is (needs UNICODE support)
589 rc = AddFontResourceA(astring);
590 FreeAsciiString(astring);
591 return rc;
592}
593//******************************************************************************
594//******************************************************************************
595ODINFUNCTION1(BOOL, RemoveFontResourceA,
596 LPCSTR, arg1)
597{
598 dprintf(("GDI32: RemoveFontResourceA %s\n", arg1));
599 return O32_RemoveFontResource(arg1);
600}
601//******************************************************************************
602//******************************************************************************
603ODINFUNCTION1(BOOL, RemoveFontResourceW,
604 LPCWSTR, szFont)
605{
606 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
607 BOOL rc;
608
609 dprintf(("GDI32: RemoveFontResourceW"));
610 rc = RemoveFontResourceA(astring);
611 FreeAsciiString(astring);
612 return(rc);
613}
614/*****************************************************************************
615 * Name : BOOL CreateScalableFontResourceA
616 * Purpose : The CreateScalableFontResourceA function creates a font resource
617 * file for a scalable font.
618 * Parameters: DWORD fdwHidden flag for read-only embedded font
619 * LPCSTR lpszFontRes address of filename for font resource
620 * LPCSTR lpszFontFile address of filename for scalable font
621 * LPCSTR lpszCurrentPath address of path to font file
622 * Variables :
623 * Result : TRUE / FALSE
624 * Remark :
625 * Status : UNTESTED STUB
626 *
627 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
628 *****************************************************************************/
629
630ODINFUNCTION4(BOOL, CreateScalableFontResourceA,
631 DWORD, fdwHidden,
632 LPCSTR, lpszFontRes,
633 LPCSTR, lpszFontFile,
634 LPCSTR, lpszCurrentPath)
635{
636 dprintf(("GDI32: CreateScalableFontResourceA not implemented.\n"));
637
638 return (FALSE);
639}
640
641
642/*****************************************************************************
643 * Name : BOOL CreateScalableFontResourceW
644 * Purpose : The CreateScalableFontResourceW function creates a font resource
645 * file for a scalable font.
646 * Parameters: DWORD fdwHidden flag for read-only embedded font
647 * LPCSTR lpszFontRes address of filename for font resource
648 * LPCSTR lpszFontFile address of filename for scalable font
649 * LPCSTR lpszCurrentPath address of path to font file
650 * Variables :
651 * Result : TRUE / FALSE
652 * Remark :
653 * Status : UNTESTED STUB
654 *
655 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
656 *****************************************************************************/
657
658ODINFUNCTION4(BOOL, CreateScalableFontResourceW,
659 DWORD, fdwHidden,
660 LPCWSTR, lpszFontRes,
661 LPCWSTR, lpszFontFile,
662 LPCWSTR, lpszCurrentPath)
663{
664 dprintf(("GDI32: CreateScalableFontResourceW not implemented.\n"));
665
666 return (FALSE);
667}
668
669
670/*****************************************************************************
671 * Name : DWORD GetFontLanguageInfo
672 * Purpose : The GetFontLanguageInfo function returns information about the
673 * currently selected font for the specified display context.
674 * Applications typically use this information and the
675 * GetCharacterPlacement function to prepare a character string for display.
676 * Parameters: HDC hdc handle to device context
677 * Variables :
678 * Result :
679 * Remark :
680 * Status : UNTESTED STUB
681 *
682 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
683 *****************************************************************************/
684
685ODINFUNCTION1(DWORD, GetFontLanguageInfo,
686 HDC, hdc)
687{
688 dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
689 hdc));
690
691 return (0);
692}
693
694
695/*************************************************************************
696 * TranslateCharsetInfo [GDI32.382]
697 *
698 * Fills a CHARSETINFO structure for a character set, code page, or
699 * font. This allows making the correspondance between different labelings
700 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
701 * of the same encoding.
702 *
703 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
704 * only one codepage should be set in *lpSrc.
705 *
706 * RETURNS
707 * TRUE on success, FALSE on failure.
708 *
709 *
710 * LPDWORD lpSrc, if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
711 * if flags == TCI_SRCCHARSET: a character set value
712 * if flags == TCI_SRCCODEPAGE: a code page value
713 * LPCHARSETINFO lpCs, structure to receive charset information
714 * DWORD flags determines interpretation of lpSrc
715 */
716ODINFUNCTION3(BOOL, TranslateCharsetInfo,
717 LPDWORD, lpSrc,
718 LPCHARSETINFO, lpCs,
719 DWORD, flags)
720{
721 int index = 0;
722 switch (flags) {
723 case TCI_SRCFONTSIG:
724 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
725 break;
726 case TCI_SRCCODEPAGE:
727 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
728 break;
729 case TCI_SRCCHARSET:
730 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
731 break;
732 default:
733 return FALSE;
734 }
735 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
736 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
737 return TRUE;
738}
739//******************************************************************************
740//******************************************************************************
741BOOL WIN32API GetTextMetricsA( HDC hdc, LPTEXTMETRICA pwtm)
742{
743 BOOL rc;
744
745 rc = O32_GetTextMetrics(hdc, pwtm);
746 dprintf(("GDI32: GetTextMetricsA %x %x returned %d", hdc, pwtm, rc));
747 return(rc);
748}
749//******************************************************************************
750//******************************************************************************
751BOOL WIN32API GetTextMetricsW( HDC hdc, LPTEXTMETRICW pwtm)
752{
753 BOOL rc;
754 TEXTMETRICA atm;
755
756 dprintf(("GDI32: GetTextMetricsW"));
757
758 rc = O32_GetTextMetrics(hdc, &atm);
759 pwtm->tmHeight = atm.tmHeight;
760 pwtm->tmAscent = atm.tmAscent;
761 pwtm->tmDescent = atm.tmDescent;
762 pwtm->tmInternalLeading = atm.tmInternalLeading;
763 pwtm->tmExternalLeading = atm.tmExternalLeading;
764 pwtm->tmAveCharWidth = atm.tmAveCharWidth;
765 pwtm->tmMaxCharWidth = atm.tmMaxCharWidth;
766 pwtm->tmWeight = atm.tmWeight;
767 pwtm->tmOverhang = atm.tmOverhang;
768 pwtm->tmDigitizedAspectX = atm.tmDigitizedAspectX;
769 pwtm->tmDigitizedAspectY = atm.tmDigitizedAspectY;
770 pwtm->tmFirstChar = atm.tmFirstChar;
771 pwtm->tmLastChar = atm.tmLastChar;
772 pwtm->tmDefaultChar = atm.tmDefaultChar;
773 pwtm->tmBreakChar = atm.tmBreakChar;
774 pwtm->tmItalic = atm.tmItalic;
775 pwtm->tmUnderlined = atm.tmUnderlined;
776 pwtm->tmStruckOut = atm.tmStruckOut;
777 pwtm->tmPitchAndFamily = atm.tmPitchAndFamily;
778 pwtm->tmCharSet = atm.tmCharSet;
779
780 dprintf(("GDI32: GetTextMetricsW %x %x returned %d", hdc, pwtm, rc));
781 return(rc);
782}
783//******************************************************************************
784//******************************************************************************
785int WIN32API GetTextFaceA( HDC hdc, int arg2, LPSTR arg3)
786{
787 dprintf(("GDI32: GetTextFaceA %x %d %x", hdc, arg2, arg3));
788 return O32_GetTextFace(hdc, arg2, arg3);
789}
790//******************************************************************************
791//******************************************************************************
792int WIN32API GetTextFaceW( HDC hdc, int arg2, LPWSTR arg3)
793{
794 char *astring = (char *)malloc(arg2+1);
795 int rc;
796
797 dprintf(("GDI32: GetTextFaceW"));
798 *astring = 0;
799 rc = GetTextFaceA(hdc, arg2, astring);
800 AsciiToUnicode(astring, arg3);
801 free(astring);
802 return rc;
803}
804//******************************************************************************
805//******************************************************************************
806UINT WIN32API GetOutlineTextMetricsA( HDC hdc, UINT arg2, LPOUTLINETEXTMETRICA arg3)
807{
808 dprintf(("GDI32: GetOutlineTextMetricsA %x %x %x", hdc, arg2, arg3));
809 return O32_GetOutlineTextMetrics(hdc, arg2, arg3);
810}
811//******************************************************************************
812//******************************************************************************
813UINT WIN32API GetOutlineTextMetricsW( HDC hdc, UINT arg2, LPOUTLINETEXTMETRICW arg3)
814{
815 dprintf(("!ERROR!: GDI32: GetOutlineTextMetricsW STUB"));
816 // NOTE: This will not work as is (needs UNICODE support)
817// return O32_GetOutlineTextMetrics(hdc, arg2, arg3);
818 return 0;
819}
820//******************************************************************************
821//******************************************************************************
Note: See TracBrowser for help on using the repository browser.