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

Last change on this file since 7635 was 7635, checked in by sandervl, 24 years ago

Added statistics for font, bitmap, pen, brush & region objects.

File size: 25.8 KB
Line 
1/* $Id: font.cpp,v 1.22 2001-12-15 18:50:26 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
99/*****************************************************************************
100 * Name : static void iFontRename
101 * Purpose : font remapping table to map win32 fonts to OS/2 pendants
102 * Parameters: LPSTR lpstrFaceOriginal - the win32 face name
103 * LPSTR lpstrFaceBuffer - [LF_FACESIZE] buffer to new name
104 * Variables :
105 * Result :
106 * Remark : remapped name is passed back in the buffer
107 * if no mapping pendant is available, return input parameter
108 * as default.
109 * Status :
110 *
111 * Author : Patrick Haller [Fri, 1998/06/12 03:44]
112 *****************************************************************************/
113
114static void iFontRename(LPCSTR lpstrFaceOriginal,
115 LPSTR lpstrFaceTemp)
116{
117 int iRet;
118
119 // NULL is a valid parameter
120 if (lpstrFaceOriginal == NULL)
121 return;
122
123 strncpy(lpstrFaceTemp, lpstrFaceOriginal, LF_FACESIZE);
124 lpstrFaceTemp[LF_FACESIZE-1] = 0;
125
126 {
127 char *y = lpstrFaceTemp;
128 while(*y) {
129 if(IsDBCSLeadByte( *y )) {
130 y += 2; // DBCS skip
131 } else {
132 *y = toupper( *y );
133 y++;
134 }
135 }
136 }
137
138 //lookup table
139 iRet = PROFILE_GetOdinIniString(ODINFONTSECTION,
140 lpstrFaceTemp,
141 lpstrFaceOriginal,
142 lpstrFaceTemp,
143 LF_FACESIZE);
144}
145
146//******************************************************************************
147HFONT hFntDefaultGui = NULL;
148//TODO: more??
149//******************************************************************************
150BOOL WIN32API IsSystemFont(HFONT hFont)
151{
152 if(hFont == hFntDefaultGui) {
153 return TRUE;
154 }
155 return FALSE;
156}
157//******************************************************************************
158//******************************************************************************
159ODINFUNCTIONNODBG14(HFONT, CreateFontA, int, nHeight,
160 int, nWidth,
161 int, nEscapement,
162 int, nOrientation,
163 int, fnWeight,
164 DWORD, fdwItalic,
165 DWORD, fdwUnderline,
166 DWORD, fdwStrikeOut,
167 DWORD, fdwCharSet,
168 DWORD, fdwOutputPrecision,
169 DWORD, fdwClipPrecision,
170 DWORD, fdwQuality,
171 DWORD, fdwPitchAndFamily,
172 LPCSTR, lpszFace)
173{
174 CHAR lpstrFaceNew[LF_FACESIZE];
175 HFONT hFont;
176
177 if(lpszFace == NULL)
178 lpszFace = "";
179
180 if(strlen(lpszFace) >= LF_FACESIZE)
181 {
182 dprintf(("ERROR: Invalid string length for font name!!"));
183 SetLastError(ERROR_INVALID_PARAMETER);
184 return 0;
185 }
186
187 iFontRename(lpszFace, lpstrFaceNew);
188
189 dprintf(("lpszFace = %s -> %s\n", lpszFace, lpstrFaceNew));
190
191 LOGFONTA logFont =
192 {
193 nHeight,
194 nWidth,
195 nEscapement,
196 nOrientation,
197 fnWeight,
198 (BYTE)fdwItalic,
199 (BYTE)fdwUnderline,
200 (BYTE)fdwStrikeOut,
201 (BYTE)fdwCharSet,
202 (BYTE)fdwOutputPrecision,
203 (BYTE)fdwClipPrecision,
204 (BYTE)fdwQuality,
205 (BYTE)fdwPitchAndFamily
206 };
207 strcpy(logFont.lfFaceName, lpszFace);
208
209 return CreateFontIndirectA(&logFont);
210}
211//******************************************************************************
212//******************************************************************************
213ODINFUNCTIONNODBG14(HFONT, CreateFontW,
214 int, nHeight,
215 int, nWidth,
216 int, nEscapement,
217 int, nOrientation,
218 int, fnWeight,
219 DWORD, fdwItalic,
220 DWORD, fdwUnderline,
221 DWORD, fdwStrikeOut,
222 DWORD, fdwCharSet,
223 DWORD, fdwOutputPrecision,
224 DWORD, fdwClipPrecision,
225 DWORD, fdwQuality,
226 DWORD, fdwPitchAndFamily,
227 LPCWSTR,lpszFace)
228{
229 char *astring;
230 HFONT hFont;
231
232 // NULL is valid for lpszFace
233 if(lpszFace != NULL)
234 astring = UnicodeToAsciiString((LPWSTR)lpszFace);
235 else
236 astring = NULL;
237
238 // @@@PH switch to ODIN_ later
239 hFont = CreateFontA(nHeight,
240 nWidth,
241 nEscapement,
242 nOrientation,
243 fnWeight,
244 fdwItalic,
245 fdwUnderline,
246 fdwStrikeOut,
247 fdwCharSet,
248 fdwOutputPrecision,
249 fdwClipPrecision,
250 fdwQuality,
251 fdwPitchAndFamily,
252 astring);
253 if (astring != NULL)
254 FreeAsciiString(astring);
255
256 return(hFont);
257}
258
259//******************************************************************************
260//******************************************************************************
261ODINFUNCTION1(HFONT,CreateFontIndirectA,const LOGFONTA*, lplf)
262{
263 HFONT hFont;
264 LOGFONTA afont;
265
266 // don't touch user buffer!
267 memcpy(&afont, lplf, sizeof(LOGFONTA));
268 iFontRename(lplf->lfFaceName, afont.lfFaceName);
269
270 dprintf(("lpszFace = (%x) %s -> %s\n", lplf->lfFaceName, lplf->lfFaceName, afont.lfFaceName));
271
272 dprintf(("GDI32: CreateFontIndirectA\n"));
273 dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));
274 dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));
275 dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement));
276 dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation));
277 dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight));
278 dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic));
279 dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline));
280 dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut));
281 dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet));
282 dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision));
283 dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision));
284 dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality));
285 dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily));
286 dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName));
287
288 hFont = O32_CreateFontIndirect(&afont);
289
290 if(hFont) {
291 STATS_CreateFontIndirect(hFont, &afont);
292 }
293 return(hFont);
294}
295//******************************************************************************
296//******************************************************************************
297ODINFUNCTION1(HFONT, CreateFontIndirectW,const LOGFONTW *, lplf)
298{
299 LOGFONTA afont;
300 HFONT hfont;
301
302 //memcpy(&afont, lplf, ((ULONG)&afont.lfFaceName - (ULONG)&afont));
303 memcpy(&afont, lplf, sizeof(LOGFONTA));
304 memset(afont.lfFaceName, 0, LF_FACESIZE);
305 dprintf(("lpszFace = (%x)", lplf->lfFaceName));
306
307 UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
308 hfont = CreateFontIndirectA(&afont);
309 return(hfont);
310}
311//******************************************************************************
312//******************************************************************************
313int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
314 lpTextM, DWORD arg3, LPARAM arg4)
315{
316 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
317 FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc;
318 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
319
320 int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData);
321 SetFS(selTIB); // switch back to the saved FS selector
322 return rc;
323}
324//******************************************************************************
325//******************************************************************************
326int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
327 DWORD arg3, LPARAM arg4)
328{
329 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
330 FONTENUMPROCW proc = (FONTENUMPROCW)lpEnumData->userProc;
331 ENUMLOGFONTW LogFont;
332 NEWTEXTMETRICW textM;
333 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
334 int rc;
335
336 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName -
337 (ULONG)&LogFont));
338 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
339 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
340 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
341
342 textM.tmHeight = lpTextM->tmHeight;
343 textM.tmAscent = lpTextM->tmAscent;
344 textM.tmDescent = lpTextM->tmDescent;
345 textM.tmInternalLeading = lpTextM->tmInternalLeading;
346 textM.tmExternalLeading = lpTextM->tmExternalLeading;
347 textM.tmAveCharWidth = lpTextM->tmAveCharWidth;
348 textM.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
349 textM.tmWeight = lpTextM->tmWeight;
350 textM.tmOverhang = lpTextM->tmOverhang;
351 textM.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
352 textM.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
353 textM.tmFirstChar = lpTextM->tmFirstChar;
354 textM.tmLastChar = lpTextM->tmLastChar;
355 textM.tmDefaultChar = lpTextM->tmDefaultChar;
356 textM.tmBreakChar = lpTextM->tmBreakChar;
357 textM.tmItalic = lpTextM->tmItalic;
358 textM.tmUnderlined = lpTextM->tmUnderlined;
359 textM.tmStruckOut = lpTextM->tmStruckOut;
360 textM.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
361 textM.tmCharSet = lpTextM->tmCharSet;
362 textM.ntmFlags = 0;
363 textM.ntmSizeEM = 0;
364 textM.ntmCellHeight = 0;
365 textM.ntmAvgWidth = 0;
366
367 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
368 SetFS(selTIB); // switch back to the saved FS selector
369 return rc;
370}
371//******************************************************************************
372//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
373//******************************************************************************
374int EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
375 lpTextM, DWORD arg3, LPARAM arg4)
376{
377 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
378 FONTENUMPROCEXA proc = (FONTENUMPROCEXA)lpEnumData->userProc;
379 ENUMLOGFONTEXA logFont;
380 NEWTEXTMETRICEXA textM;
381 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
382
383 memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA));
384 memset(logFont.elfScript, 0, sizeof(logFont.elfScript));
385 memcpy(&textM.ntmetm, lpTextM, sizeof(textM.ntmetm));
386 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
387
388 dprintf(("EnumFontProcExA %s", logFont.elfLogFont.lfFaceName));
389
390 int rc = proc(&logFont, &textM, arg3, lpEnumData->userData);
391 SetFS(selTIB); // switch back to the saved FS selector
392 return rc;
393}
394//******************************************************************************
395//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
396//******************************************************************************
397int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
398 DWORD arg3, LPARAM arg4)
399{
400 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
401 FONTENUMPROCEXW proc = (FONTENUMPROCEXW)lpEnumData->userProc;
402 ENUMLOGFONTEXW LogFont;
403 NEWTEXTMETRICEXW textM;
404 int rc;
405
406 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont));
407 memset(LogFont.elfScript, 0, sizeof(LogFont.elfScript));
408 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
409 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
410 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
411
412 textM.ntmetm.tmHeight = lpTextM->tmHeight;
413 textM.ntmetm.tmAscent = lpTextM->tmAscent;
414 textM.ntmetm.tmDescent = lpTextM->tmDescent;
415 textM.ntmetm.tmInternalLeading = lpTextM->tmInternalLeading;
416 textM.ntmetm.tmExternalLeading = lpTextM->tmExternalLeading;
417 textM.ntmetm.tmAveCharWidth = lpTextM->tmAveCharWidth;
418 textM.ntmetm.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
419 textM.ntmetm.tmWeight = lpTextM->tmWeight;
420 textM.ntmetm.tmOverhang = lpTextM->tmOverhang;
421 textM.ntmetm.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
422 textM.ntmetm.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
423 textM.ntmetm.tmFirstChar = lpTextM->tmFirstChar;
424 textM.ntmetm.tmLastChar = lpTextM->tmLastChar;
425 textM.ntmetm.tmDefaultChar = lpTextM->tmDefaultChar;
426 textM.ntmetm.tmBreakChar = lpTextM->tmBreakChar;
427 textM.ntmetm.tmItalic = lpTextM->tmItalic;
428 textM.ntmetm.tmUnderlined = lpTextM->tmUnderlined;
429 textM.ntmetm.tmStruckOut = lpTextM->tmStruckOut;
430 textM.ntmetm.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
431 textM.ntmetm.tmCharSet = lpTextM->tmCharSet;
432 textM.ntmetm.ntmFlags = 0;
433 textM.ntmetm.ntmSizeEM = 0;
434 textM.ntmetm.ntmCellHeight = 0;
435 textM.ntmetm.ntmAvgWidth = 0;
436 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
437
438 dprintf(("EnumFontProcExW %s", lpLogFont->elfLogFont.lfFaceName));
439 return proc(&LogFont, &textM, arg3, lpEnumData->userData);
440}
441//******************************************************************************
442//******************************************************************************
443ODINFUNCTION4(int, EnumFontsA,
444 HDC, arg1,
445 LPCSTR, arg2,
446 FONTENUMPROCA, arg3,
447 LPARAM, arg4)
448{
449 //@@@PH shouldn't this rather be O32_EnumFonts ?
450 return EnumFontFamiliesA(arg1, arg2, arg3, arg4);
451}
452//******************************************************************************
453//******************************************************************************
454ODINFUNCTION4(int, EnumFontsW,
455 HDC, arg1,
456 LPCWSTR, arg2,
457 FONTENUMPROCW, arg3,
458 LPARAM, arg4)
459{
460 //@@@PH shouldn't this rather be O32_EnumFonts ?
461 return EnumFontFamiliesW(arg1, arg2, arg3, arg4);
462}
463//******************************************************************************
464//******************************************************************************
465ODINFUNCTION4(int, EnumFontFamiliesA,
466 HDC, arg1,
467 LPCSTR, arg2,
468 FONTENUMPROCA, arg3,
469 LPARAM, arg4)
470{
471 ENUMUSERDATA enumData;
472 int rc;
473
474 dprintf(("GDI32: EnumFontFamiliesA %s", arg2));
475
476 enumData.userProc = (DWORD)arg3;
477 enumData.userData = arg4;
478
479 rc = O32_EnumFontFamilies(arg1, arg2, &EnumFontProcA, (LPARAM)&enumData);
480
481 return rc;
482}
483//******************************************************************************
484//******************************************************************************
485ODINFUNCTION4(int, EnumFontFamiliesW,
486 HDC, arg1,
487 LPCWSTR, arg2,
488 FONTENUMPROCW, arg3,
489 LPARAM, arg4)
490{
491 ENUMUSERDATA enumData;
492 int rc;
493 char *astring = UnicodeToAsciiString((LPWSTR)arg2);
494
495 dprintf(("GDI32: EnumFontFamiliesW %s", astring));
496
497 enumData.userProc = (DWORD)arg3;
498 enumData.userData = arg4;
499
500 rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcW, (LPARAM)&enumData);
501
502 FreeAsciiString(astring);
503 return rc;
504}
505//******************************************************************************
506//******************************************************************************
507ODINFUNCTION5(INT, EnumFontFamiliesExA,
508 HDC, arg1,
509 LPLOGFONTA, arg2,
510 FONTENUMPROCEXA, arg3,
511 LPARAM, arg4,
512 DWORD, dwFlags)
513{
514 ENUMUSERDATA enumData;
515 int rc;
516
517 dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName));
518
519 enumData.userProc = (DWORD)arg3;
520 enumData.userData = arg4;
521 enumData.dwFlags = dwFlags;
522
523 rc = O32_EnumFontFamilies(arg1, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData);
524
525 return rc;
526}
527//******************************************************************************
528//******************************************************************************
529ODINFUNCTION5(INT, EnumFontFamiliesExW,
530 HDC, arg1,
531 LPLOGFONTW, arg2,
532 FONTENUMPROCEXW, arg3,
533 LPARAM, arg4,
534 DWORD, dwFlags)
535{
536 ENUMUSERDATA enumData;
537 int rc;
538 char *astring = UnicodeToAsciiString((LPWSTR)arg2->lfFaceName);
539
540 dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring));
541
542 enumData.userProc = (DWORD)arg3;
543 enumData.userData = arg4;
544 enumData.dwFlags = dwFlags;
545
546 rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcExW, (LPARAM)&enumData);
547
548 FreeAsciiString(astring);
549 return rc;
550}
551//******************************************************************************
552//******************************************************************************
553ODINFUNCTION5(DWORD, GetFontData,
554 HDC, hdc,
555 DWORD, dwTable,
556 DWORD, dwOffset,
557 LPVOID, lpvBuffer,
558 DWORD, dbData)
559{
560 dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
561 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
562
563 return(GDI_ERROR);
564}
565//******************************************************************************
566//******************************************************************************
567ODINFUNCTION1(int, AddFontResourceA,
568 LPCSTR, szFont)
569{
570 HINSTANCE hInstance;
571
572 dprintf(("GDI32: AddFontResourceA %s", szFont));
573 hInstance = LoadLibraryA(szFont);
574 if(hInstance) {
575 dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED"));
576 FreeLibrary(hInstance);
577 return 1;
578 }
579 return O32_AddFontResource(szFont);
580}
581//******************************************************************************
582//******************************************************************************
583ODINFUNCTION1(int, AddFontResourceW,
584 LPCWSTR, szFont)
585{
586 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
587 BOOL rc;
588
589 dprintf(("GDI32: AddFontResourceW"));
590 // NOTE: This will not work as is (needs UNICODE support)
591 rc = AddFontResourceA(astring);
592 FreeAsciiString(astring);
593 return rc;
594}
595//******************************************************************************
596//******************************************************************************
597ODINFUNCTION1(BOOL, RemoveFontResourceA,
598 LPCSTR, arg1)
599{
600 dprintf(("GDI32: RemoveFontResourceA %s\n", arg1));
601 return O32_RemoveFontResource(arg1);
602}
603//******************************************************************************
604//******************************************************************************
605ODINFUNCTION1(BOOL, RemoveFontResourceW,
606 LPCWSTR, szFont)
607{
608 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
609 BOOL rc;
610
611 dprintf(("GDI32: RemoveFontResourceW"));
612 rc = RemoveFontResourceA(astring);
613 FreeAsciiString(astring);
614 return(rc);
615}
616/*****************************************************************************
617 * Name : BOOL CreateScalableFontResourceA
618 * Purpose : The CreateScalableFontResourceA function creates a font resource
619 * file for a scalable font.
620 * Parameters: DWORD fdwHidden flag for read-only embedded font
621 * LPCSTR lpszFontRes address of filename for font resource
622 * LPCSTR lpszFontFile address of filename for scalable font
623 * LPCSTR lpszCurrentPath address of path to font file
624 * Variables :
625 * Result : TRUE / FALSE
626 * Remark :
627 * Status : UNTESTED STUB
628 *
629 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
630 *****************************************************************************/
631
632ODINFUNCTION4(BOOL, CreateScalableFontResourceA,
633 DWORD, fdwHidden,
634 LPCSTR, lpszFontRes,
635 LPCSTR, lpszFontFile,
636 LPCSTR, lpszCurrentPath)
637{
638 dprintf(("GDI32: CreateScalableFontResourceA not implemented.\n"));
639
640 return (FALSE);
641}
642
643
644/*****************************************************************************
645 * Name : BOOL CreateScalableFontResourceW
646 * Purpose : The CreateScalableFontResourceW function creates a font resource
647 * file for a scalable font.
648 * Parameters: DWORD fdwHidden flag for read-only embedded font
649 * LPCSTR lpszFontRes address of filename for font resource
650 * LPCSTR lpszFontFile address of filename for scalable font
651 * LPCSTR lpszCurrentPath address of path to font file
652 * Variables :
653 * Result : TRUE / FALSE
654 * Remark :
655 * Status : UNTESTED STUB
656 *
657 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
658 *****************************************************************************/
659
660ODINFUNCTION4(BOOL, CreateScalableFontResourceW,
661 DWORD, fdwHidden,
662 LPCWSTR, lpszFontRes,
663 LPCWSTR, lpszFontFile,
664 LPCWSTR, lpszCurrentPath)
665{
666 dprintf(("GDI32: CreateScalableFontResourceW not implemented.\n"));
667
668 return (FALSE);
669}
670
671
672/*****************************************************************************
673 * Name : DWORD GetFontLanguageInfo
674 * Purpose : The GetFontLanguageInfo function returns information about the
675 * currently selected font for the specified display context.
676 * Applications typically use this information and the
677 * GetCharacterPlacement function to prepare a character string for display.
678 * Parameters: HDC hdc handle to device context
679 * Variables :
680 * Result :
681 * Remark :
682 * Status : UNTESTED STUB
683 *
684 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
685 *****************************************************************************/
686
687ODINFUNCTION1(DWORD, GetFontLanguageInfo,
688 HDC, hdc)
689{
690 dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
691 hdc));
692
693 return (0);
694}
695
696
697/*************************************************************************
698 * TranslateCharsetInfo [GDI32.382]
699 *
700 * Fills a CHARSETINFO structure for a character set, code page, or
701 * font. This allows making the correspondance between different labelings
702 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
703 * of the same encoding.
704 *
705 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
706 * only one codepage should be set in *lpSrc.
707 *
708 * RETURNS
709 * TRUE on success, FALSE on failure.
710 *
711 *
712 * LPDWORD lpSrc, if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
713 * if flags == TCI_SRCCHARSET: a character set value
714 * if flags == TCI_SRCCODEPAGE: a code page value
715 * LPCHARSETINFO lpCs, structure to receive charset information
716 * DWORD flags determines interpretation of lpSrc
717 */
718ODINFUNCTION3(BOOL, TranslateCharsetInfo,
719 LPDWORD, lpSrc,
720 LPCHARSETINFO, lpCs,
721 DWORD, flags)
722{
723 int index = 0;
724 switch (flags) {
725 case TCI_SRCFONTSIG:
726 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
727 break;
728 case TCI_SRCCODEPAGE:
729 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
730 break;
731 case TCI_SRCCHARSET:
732 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
733 break;
734 default:
735 return FALSE;
736 }
737 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
738 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
739 return TRUE;
740}
741//******************************************************************************
742//******************************************************************************
Note: See TracBrowser for help on using the repository browser.