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

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

better logging for some functions

File size: 25.8 KB
Line 
1/* $Id: font.cpp,v 1.23 2002-01-02 18:36:00 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 if(hFont) {
290 STATS_CreateFontIndirect(hFont, &afont);
291 }
292 return(hFont);
293}
294//******************************************************************************
295//******************************************************************************
296ODINFUNCTION1(HFONT, CreateFontIndirectW,const LOGFONTW *, lplf)
297{
298 LOGFONTA afont;
299 HFONT hfont;
300
301 //memcpy(&afont, lplf, ((ULONG)&afont.lfFaceName - (ULONG)&afont));
302 memcpy(&afont, lplf, sizeof(LOGFONTA));
303 memset(afont.lfFaceName, 0, LF_FACESIZE);
304 dprintf(("lpszFace = (%x)", lplf->lfFaceName));
305
306 UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
307 hfont = CreateFontIndirectA(&afont);
308 return(hfont);
309}
310//******************************************************************************
311//******************************************************************************
312int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
313 lpTextM, DWORD arg3, LPARAM arg4)
314{
315 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
316 FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc;
317 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
318
319 int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData);
320 SetFS(selTIB); // switch back to the saved FS selector
321 return rc;
322}
323//******************************************************************************
324//******************************************************************************
325int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
326 DWORD arg3, LPARAM arg4)
327{
328 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
329 FONTENUMPROCW proc = (FONTENUMPROCW)lpEnumData->userProc;
330 ENUMLOGFONTW LogFont;
331 NEWTEXTMETRICW textM;
332 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
333 int rc;
334
335 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName -
336 (ULONG)&LogFont));
337 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
338 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
339 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
340
341 textM.tmHeight = lpTextM->tmHeight;
342 textM.tmAscent = lpTextM->tmAscent;
343 textM.tmDescent = lpTextM->tmDescent;
344 textM.tmInternalLeading = lpTextM->tmInternalLeading;
345 textM.tmExternalLeading = lpTextM->tmExternalLeading;
346 textM.tmAveCharWidth = lpTextM->tmAveCharWidth;
347 textM.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
348 textM.tmWeight = lpTextM->tmWeight;
349 textM.tmOverhang = lpTextM->tmOverhang;
350 textM.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
351 textM.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
352 textM.tmFirstChar = lpTextM->tmFirstChar;
353 textM.tmLastChar = lpTextM->tmLastChar;
354 textM.tmDefaultChar = lpTextM->tmDefaultChar;
355 textM.tmBreakChar = lpTextM->tmBreakChar;
356 textM.tmItalic = lpTextM->tmItalic;
357 textM.tmUnderlined = lpTextM->tmUnderlined;
358 textM.tmStruckOut = lpTextM->tmStruckOut;
359 textM.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
360 textM.tmCharSet = lpTextM->tmCharSet;
361 textM.ntmFlags = 0;
362 textM.ntmSizeEM = 0;
363 textM.ntmCellHeight = 0;
364 textM.ntmAvgWidth = 0;
365
366 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
367 SetFS(selTIB); // switch back to the saved FS selector
368 return rc;
369}
370//******************************************************************************
371//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
372//******************************************************************************
373int EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
374 lpTextM, DWORD arg3, LPARAM arg4)
375{
376 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
377 FONTENUMPROCEXA proc = (FONTENUMPROCEXA)lpEnumData->userProc;
378 ENUMLOGFONTEXA logFont;
379 NEWTEXTMETRICEXA textM;
380 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
381
382 memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA));
383 memset(logFont.elfScript, 0, sizeof(logFont.elfScript));
384 memcpy(&textM.ntmetm, lpTextM, sizeof(textM.ntmetm));
385 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
386
387 dprintf(("EnumFontProcExA %s", logFont.elfLogFont.lfFaceName));
388
389 int rc = proc(&logFont, &textM, arg3, lpEnumData->userData);
390 SetFS(selTIB); // switch back to the saved FS selector
391 return rc;
392}
393//******************************************************************************
394//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
395//******************************************************************************
396int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
397 DWORD arg3, LPARAM arg4)
398{
399 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
400 FONTENUMPROCEXW proc = (FONTENUMPROCEXW)lpEnumData->userProc;
401 ENUMLOGFONTEXW LogFont;
402 NEWTEXTMETRICEXW textM;
403 int rc;
404
405 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont));
406 memset(LogFont.elfScript, 0, sizeof(LogFont.elfScript));
407 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
408 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
409 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
410
411 textM.ntmetm.tmHeight = lpTextM->tmHeight;
412 textM.ntmetm.tmAscent = lpTextM->tmAscent;
413 textM.ntmetm.tmDescent = lpTextM->tmDescent;
414 textM.ntmetm.tmInternalLeading = lpTextM->tmInternalLeading;
415 textM.ntmetm.tmExternalLeading = lpTextM->tmExternalLeading;
416 textM.ntmetm.tmAveCharWidth = lpTextM->tmAveCharWidth;
417 textM.ntmetm.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
418 textM.ntmetm.tmWeight = lpTextM->tmWeight;
419 textM.ntmetm.tmOverhang = lpTextM->tmOverhang;
420 textM.ntmetm.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
421 textM.ntmetm.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
422 textM.ntmetm.tmFirstChar = lpTextM->tmFirstChar;
423 textM.ntmetm.tmLastChar = lpTextM->tmLastChar;
424 textM.ntmetm.tmDefaultChar = lpTextM->tmDefaultChar;
425 textM.ntmetm.tmBreakChar = lpTextM->tmBreakChar;
426 textM.ntmetm.tmItalic = lpTextM->tmItalic;
427 textM.ntmetm.tmUnderlined = lpTextM->tmUnderlined;
428 textM.ntmetm.tmStruckOut = lpTextM->tmStruckOut;
429 textM.ntmetm.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
430 textM.ntmetm.tmCharSet = lpTextM->tmCharSet;
431 textM.ntmetm.ntmFlags = 0;
432 textM.ntmetm.ntmSizeEM = 0;
433 textM.ntmetm.ntmCellHeight = 0;
434 textM.ntmetm.ntmAvgWidth = 0;
435 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
436
437 dprintf(("EnumFontProcExW %s", lpLogFont->elfLogFont.lfFaceName));
438 return proc(&LogFont, &textM, arg3, lpEnumData->userData);
439}
440//******************************************************************************
441//******************************************************************************
442ODINFUNCTION4(int, EnumFontsA,
443 HDC, arg1,
444 LPCSTR, arg2,
445 FONTENUMPROCA, arg3,
446 LPARAM, arg4)
447{
448 //@@@PH shouldn't this rather be O32_EnumFonts ?
449 return EnumFontFamiliesA(arg1, arg2, arg3, arg4);
450}
451//******************************************************************************
452//******************************************************************************
453ODINFUNCTION4(int, EnumFontsW,
454 HDC, arg1,
455 LPCWSTR, arg2,
456 FONTENUMPROCW, arg3,
457 LPARAM, arg4)
458{
459 //@@@PH shouldn't this rather be O32_EnumFonts ?
460 return EnumFontFamiliesW(arg1, arg2, arg3, arg4);
461}
462//******************************************************************************
463//******************************************************************************
464ODINFUNCTION4(int, EnumFontFamiliesA,
465 HDC, arg1,
466 LPCSTR, arg2,
467 FONTENUMPROCA, arg3,
468 LPARAM, arg4)
469{
470 ENUMUSERDATA enumData;
471 int rc;
472
473 dprintf(("GDI32: EnumFontFamiliesA %s", arg2));
474
475 enumData.userProc = (DWORD)arg3;
476 enumData.userData = arg4;
477
478 rc = O32_EnumFontFamilies(arg1, arg2, &EnumFontProcA, (LPARAM)&enumData);
479
480 return rc;
481}
482//******************************************************************************
483//******************************************************************************
484ODINFUNCTION4(int, EnumFontFamiliesW,
485 HDC, arg1,
486 LPCWSTR, arg2,
487 FONTENUMPROCW, arg3,
488 LPARAM, arg4)
489{
490 ENUMUSERDATA enumData;
491 int rc;
492 char *astring = UnicodeToAsciiString((LPWSTR)arg2);
493
494 dprintf(("GDI32: EnumFontFamiliesW %s", astring));
495
496 enumData.userProc = (DWORD)arg3;
497 enumData.userData = arg4;
498
499 rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcW, (LPARAM)&enumData);
500
501 FreeAsciiString(astring);
502 return rc;
503}
504//******************************************************************************
505//******************************************************************************
506ODINFUNCTION5(INT, EnumFontFamiliesExA,
507 HDC, arg1,
508 LPLOGFONTA, arg2,
509 FONTENUMPROCEXA, arg3,
510 LPARAM, arg4,
511 DWORD, dwFlags)
512{
513 ENUMUSERDATA enumData;
514 int rc;
515
516 dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName));
517
518 enumData.userProc = (DWORD)arg3;
519 enumData.userData = arg4;
520 enumData.dwFlags = dwFlags;
521
522 rc = O32_EnumFontFamilies(arg1, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData);
523
524 return rc;
525}
526//******************************************************************************
527//******************************************************************************
528ODINFUNCTION5(INT, EnumFontFamiliesExW,
529 HDC, arg1,
530 LPLOGFONTW, arg2,
531 FONTENUMPROCEXW, arg3,
532 LPARAM, arg4,
533 DWORD, dwFlags)
534{
535 ENUMUSERDATA enumData;
536 int rc;
537 char *astring = UnicodeToAsciiString((LPWSTR)arg2->lfFaceName);
538
539 dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring));
540
541 enumData.userProc = (DWORD)arg3;
542 enumData.userData = arg4;
543 enumData.dwFlags = dwFlags;
544
545 rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcExW, (LPARAM)&enumData);
546
547 FreeAsciiString(astring);
548 return rc;
549}
550//******************************************************************************
551//******************************************************************************
552ODINFUNCTION5(DWORD, GetFontData,
553 HDC, hdc,
554 DWORD, dwTable,
555 DWORD, dwOffset,
556 LPVOID, lpvBuffer,
557 DWORD, dbData)
558{
559 dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
560 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
561
562 return(GDI_ERROR);
563}
564//******************************************************************************
565//******************************************************************************
566ODINFUNCTION1(int, AddFontResourceA,
567 LPCSTR, szFont)
568{
569 HINSTANCE hInstance;
570
571 dprintf(("GDI32: AddFontResourceA %s", szFont));
572 hInstance = LoadLibraryA(szFont);
573 if(hInstance) {
574 dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED"));
575 FreeLibrary(hInstance);
576 return 1;
577 }
578 return O32_AddFontResource(szFont);
579}
580//******************************************************************************
581//******************************************************************************
582ODINFUNCTION1(int, AddFontResourceW,
583 LPCWSTR, szFont)
584{
585 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
586 BOOL rc;
587
588 dprintf(("GDI32: AddFontResourceW"));
589 // NOTE: This will not work as is (needs UNICODE support)
590 rc = AddFontResourceA(astring);
591 FreeAsciiString(astring);
592 return rc;
593}
594//******************************************************************************
595//******************************************************************************
596ODINFUNCTION1(BOOL, RemoveFontResourceA,
597 LPCSTR, arg1)
598{
599 dprintf(("GDI32: RemoveFontResourceA %s\n", arg1));
600 return O32_RemoveFontResource(arg1);
601}
602//******************************************************************************
603//******************************************************************************
604ODINFUNCTION1(BOOL, RemoveFontResourceW,
605 LPCWSTR, szFont)
606{
607 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
608 BOOL rc;
609
610 dprintf(("GDI32: RemoveFontResourceW"));
611 rc = RemoveFontResourceA(astring);
612 FreeAsciiString(astring);
613 return(rc);
614}
615/*****************************************************************************
616 * Name : BOOL CreateScalableFontResourceA
617 * Purpose : The CreateScalableFontResourceA function creates a font resource
618 * file for a scalable font.
619 * Parameters: DWORD fdwHidden flag for read-only embedded font
620 * LPCSTR lpszFontRes address of filename for font resource
621 * LPCSTR lpszFontFile address of filename for scalable font
622 * LPCSTR lpszCurrentPath address of path to font file
623 * Variables :
624 * Result : TRUE / FALSE
625 * Remark :
626 * Status : UNTESTED STUB
627 *
628 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
629 *****************************************************************************/
630
631ODINFUNCTION4(BOOL, CreateScalableFontResourceA,
632 DWORD, fdwHidden,
633 LPCSTR, lpszFontRes,
634 LPCSTR, lpszFontFile,
635 LPCSTR, lpszCurrentPath)
636{
637 dprintf(("GDI32: CreateScalableFontResourceA not implemented.\n"));
638
639 return (FALSE);
640}
641
642
643/*****************************************************************************
644 * Name : BOOL CreateScalableFontResourceW
645 * Purpose : The CreateScalableFontResourceW function creates a font resource
646 * file for a scalable font.
647 * Parameters: DWORD fdwHidden flag for read-only embedded font
648 * LPCSTR lpszFontRes address of filename for font resource
649 * LPCSTR lpszFontFile address of filename for scalable font
650 * LPCSTR lpszCurrentPath address of path to font file
651 * Variables :
652 * Result : TRUE / FALSE
653 * Remark :
654 * Status : UNTESTED STUB
655 *
656 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
657 *****************************************************************************/
658
659ODINFUNCTION4(BOOL, CreateScalableFontResourceW,
660 DWORD, fdwHidden,
661 LPCWSTR, lpszFontRes,
662 LPCWSTR, lpszFontFile,
663 LPCWSTR, lpszCurrentPath)
664{
665 dprintf(("GDI32: CreateScalableFontResourceW not implemented.\n"));
666
667 return (FALSE);
668}
669
670
671/*****************************************************************************
672 * Name : DWORD GetFontLanguageInfo
673 * Purpose : The GetFontLanguageInfo function returns information about the
674 * currently selected font for the specified display context.
675 * Applications typically use this information and the
676 * GetCharacterPlacement function to prepare a character string for display.
677 * Parameters: HDC hdc handle to device context
678 * Variables :
679 * Result :
680 * Remark :
681 * Status : UNTESTED STUB
682 *
683 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
684 *****************************************************************************/
685
686ODINFUNCTION1(DWORD, GetFontLanguageInfo,
687 HDC, hdc)
688{
689 dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
690 hdc));
691
692 return (0);
693}
694
695
696/*************************************************************************
697 * TranslateCharsetInfo [GDI32.382]
698 *
699 * Fills a CHARSETINFO structure for a character set, code page, or
700 * font. This allows making the correspondance between different labelings
701 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
702 * of the same encoding.
703 *
704 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
705 * only one codepage should be set in *lpSrc.
706 *
707 * RETURNS
708 * TRUE on success, FALSE on failure.
709 *
710 *
711 * LPDWORD lpSrc, if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
712 * if flags == TCI_SRCCHARSET: a character set value
713 * if flags == TCI_SRCCODEPAGE: a code page value
714 * LPCHARSETINFO lpCs, structure to receive charset information
715 * DWORD flags determines interpretation of lpSrc
716 */
717ODINFUNCTION3(BOOL, TranslateCharsetInfo,
718 LPDWORD, lpSrc,
719 LPCHARSETINFO, lpCs,
720 DWORD, flags)
721{
722 int index = 0;
723 switch (flags) {
724 case TCI_SRCFONTSIG:
725 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
726 break;
727 case TCI_SRCCODEPAGE:
728 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
729 break;
730 case TCI_SRCCHARSET:
731 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
732 break;
733 default:
734 return FALSE;
735 }
736 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
737 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
738 return TRUE;
739}
740//******************************************************************************
741//******************************************************************************
Note: See TracBrowser for help on using the repository browser.