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

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

Added debug wrappers for all exports

File size: 29.3 KB
Line 
1/* $Id: font.cpp,v 1.27 2002-11-26 10:53:08 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//******************************************************************************
149HFONT WIN32API 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//******************************************************************************
203HFONT WIN32API CreateFontW(int nHeight,
204 int nWidth,
205 int nEscapement,
206 int nOrientation,
207 int fnWeight,
208 DWORD fdwItalic,
209 DWORD fdwUnderline,
210 DWORD fdwStrikeOut,
211 DWORD fdwCharSet,
212 DWORD fdwOutputPrecision,
213 DWORD fdwClipPrecision,
214 DWORD fdwQuality,
215 DWORD fdwPitchAndFamily,
216 LPCWSTR lpszFace)
217{
218 char *astring;
219 HFONT hFont;
220
221 // NULL is valid for lpszFace
222 if(lpszFace != NULL)
223 astring = UnicodeToAsciiString((LPWSTR)lpszFace);
224 else
225 astring = NULL;
226
227 // @@@PH switch to ODIN_ later
228 hFont = CreateFontA(nHeight,
229 nWidth,
230 nEscapement,
231 nOrientation,
232 fnWeight,
233 fdwItalic,
234 fdwUnderline,
235 fdwStrikeOut,
236 fdwCharSet,
237 fdwOutputPrecision,
238 fdwClipPrecision,
239 fdwQuality,
240 fdwPitchAndFamily,
241 astring);
242 if (astring != NULL)
243 FreeAsciiString(astring);
244
245 return(hFont);
246}
247
248//******************************************************************************
249//******************************************************************************
250HFONT WIN32API CreateFontIndirectA(const LOGFONTA* lplf)
251{
252 HFONT hFont;
253 LOGFONTA afont;
254
255 // don't touch user buffer!
256 memcpy(&afont, lplf, sizeof(LOGFONTA));
257 iFontRename(lplf->lfFaceName, afont.lfFaceName);
258
259 dprintf(("lpszFace = (%x) %s -> %s\n", lplf->lfFaceName, lplf->lfFaceName, afont.lfFaceName));
260
261 dprintf(("GDI32: CreateFontIndirectA\n"));
262 dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));
263 dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));
264 dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement));
265 dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation));
266 dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight));
267 dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic));
268 dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline));
269 dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut));
270 dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet));
271 dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision));
272 dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision));
273 dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality));
274 dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily));
275 dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName));
276
277 hFont = O32_CreateFontIndirect(&afont);
278 if(hFont) {
279 STATS_CreateFontIndirect(hFont, &afont);
280 }
281 return(hFont);
282}
283//******************************************************************************
284//******************************************************************************
285HFONT WIN32API CreateFontIndirectW(const LOGFONTW * lplf)
286{
287 LOGFONTA afont;
288 HFONT hfont;
289
290 //memcpy(&afont, lplf, ((ULONG)&afont.lfFaceName - (ULONG)&afont));
291 memcpy(&afont, lplf, sizeof(LOGFONTA));
292 memset(afont.lfFaceName, 0, LF_FACESIZE);
293 dprintf(("lpszFace = (%x)", lplf->lfFaceName));
294
295 UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
296 hfont = CreateFontIndirectA(&afont);
297 return(hfont);
298}
299//******************************************************************************
300//******************************************************************************
301int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
302 lpTextM, DWORD arg3, LPARAM arg4)
303{
304 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
305 FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc;
306 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
307
308 int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData);
309 SetFS(selTIB); // switch back to the saved FS selector
310 return rc;
311}
312//******************************************************************************
313//******************************************************************************
314int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
315 DWORD arg3, LPARAM arg4)
316{
317 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
318 FONTENUMPROCW proc = (FONTENUMPROCW)lpEnumData->userProc;
319 ENUMLOGFONTW LogFont;
320 NEWTEXTMETRICW textM;
321 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
322 int rc;
323
324 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName -
325 (ULONG)&LogFont));
326 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
327 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
328 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
329
330 textM.tmHeight = lpTextM->tmHeight;
331 textM.tmAscent = lpTextM->tmAscent;
332 textM.tmDescent = lpTextM->tmDescent;
333 textM.tmInternalLeading = lpTextM->tmInternalLeading;
334 textM.tmExternalLeading = lpTextM->tmExternalLeading;
335 textM.tmAveCharWidth = lpTextM->tmAveCharWidth;
336 textM.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
337 textM.tmWeight = lpTextM->tmWeight;
338 textM.tmOverhang = lpTextM->tmOverhang;
339 textM.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
340 textM.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
341 textM.tmFirstChar = lpTextM->tmFirstChar;
342 textM.tmLastChar = lpTextM->tmLastChar;
343 textM.tmDefaultChar = lpTextM->tmDefaultChar;
344 textM.tmBreakChar = lpTextM->tmBreakChar;
345 textM.tmItalic = lpTextM->tmItalic;
346 textM.tmUnderlined = lpTextM->tmUnderlined;
347 textM.tmStruckOut = lpTextM->tmStruckOut;
348 textM.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
349 textM.tmCharSet = lpTextM->tmCharSet;
350 textM.ntmFlags = 0;
351 textM.ntmSizeEM = 0;
352 textM.ntmCellHeight = 0;
353 textM.ntmAvgWidth = 0;
354
355 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
356 SetFS(selTIB); // switch back to the saved FS selector
357 return rc;
358}
359//******************************************************************************
360//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
361//******************************************************************************
362int EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
363 lpTextM, DWORD arg3, LPARAM arg4)
364{
365 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
366 FONTENUMPROCEXA proc = (FONTENUMPROCEXA)lpEnumData->userProc;
367 ENUMLOGFONTEXA logFont;
368 NEWTEXTMETRICEXA textM;
369 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
370
371 memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA));
372 memset(logFont.elfScript, 0, sizeof(logFont.elfScript));
373 memcpy(&textM.ntmetm, lpTextM, sizeof(textM.ntmetm));
374 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
375
376 dprintf(("EnumFontProcExA %s height %d", logFont.elfLogFont.lfFaceName, textM.ntmetm.tmHeight));
377
378 int rc = proc(&logFont, &textM, arg3, lpEnumData->userData);
379 SetFS(selTIB); // switch back to the saved FS selector
380 return rc;
381}
382//******************************************************************************
383//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
384//******************************************************************************
385int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
386 DWORD arg3, LPARAM arg4)
387{
388 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
389 FONTENUMPROCEXW proc = (FONTENUMPROCEXW)lpEnumData->userProc;
390 ENUMLOGFONTEXW LogFont;
391 NEWTEXTMETRICEXW textM;
392 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
393 int rc;
394
395 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont));
396 memset(LogFont.elfScript, 0, sizeof(LogFont.elfScript));
397 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
398 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
399 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
400
401 textM.ntmetm.tmHeight = lpTextM->tmHeight;
402 textM.ntmetm.tmAscent = lpTextM->tmAscent;
403 textM.ntmetm.tmDescent = lpTextM->tmDescent;
404 textM.ntmetm.tmInternalLeading = lpTextM->tmInternalLeading;
405 textM.ntmetm.tmExternalLeading = lpTextM->tmExternalLeading;
406 textM.ntmetm.tmAveCharWidth = lpTextM->tmAveCharWidth;
407 textM.ntmetm.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
408 textM.ntmetm.tmWeight = lpTextM->tmWeight;
409 textM.ntmetm.tmOverhang = lpTextM->tmOverhang;
410 textM.ntmetm.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
411 textM.ntmetm.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
412 textM.ntmetm.tmFirstChar = lpTextM->tmFirstChar;
413 textM.ntmetm.tmLastChar = lpTextM->tmLastChar;
414 textM.ntmetm.tmDefaultChar = lpTextM->tmDefaultChar;
415 textM.ntmetm.tmBreakChar = lpTextM->tmBreakChar;
416 textM.ntmetm.tmItalic = lpTextM->tmItalic;
417 textM.ntmetm.tmUnderlined = lpTextM->tmUnderlined;
418 textM.ntmetm.tmStruckOut = lpTextM->tmStruckOut;
419 textM.ntmetm.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
420 textM.ntmetm.tmCharSet = lpTextM->tmCharSet;
421 textM.ntmetm.ntmFlags = 0;
422 textM.ntmetm.ntmSizeEM = 0;
423 textM.ntmetm.ntmCellHeight = 0;
424 textM.ntmetm.ntmAvgWidth = 0;
425 memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature));
426
427 dprintf(("EnumFontProcExW %s height %d", lpLogFont->elfLogFont.lfFaceName, textM.ntmetm.tmHeight));
428 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
429 SetFS(selTIB); // switch back to the saved FS selector
430 return rc;
431}
432//******************************************************************************
433//******************************************************************************
434int WIN32API EnumFontsA(HDC hdc,
435 LPCSTR arg2,
436 FONTENUMPROCA arg3,
437 LPARAM arg4)
438{
439 //@@@PH shouldn't this rather be O32_EnumFonts ?
440 return EnumFontFamiliesA(hdc, arg2, arg3, arg4);
441}
442//******************************************************************************
443//******************************************************************************
444int WIN32API EnumFontsW(HDC hdc,
445 LPCWSTR arg2,
446 FONTENUMPROCW arg3,
447 LPARAM arg4)
448{
449 //@@@PH shouldn't this rather be O32_EnumFonts ?
450 return EnumFontFamiliesW(hdc, arg2, arg3, arg4);
451}
452//******************************************************************************
453//******************************************************************************
454int WIN32API EnumFontFamiliesA(HDC hdc,
455 LPCSTR lpszFontFamily,
456 FONTENUMPROCA arg3,
457 LPARAM arg4)
458{
459 ENUMUSERDATA enumData;
460 CHAR lpstrFamilyNew[LF_FACESIZE] = "";
461 int rc;
462
463 dprintf(("GDI32: EnumFontFamiliesA %s", lpszFontFamily));
464
465 iFontRename(lpszFontFamily, lpstrFamilyNew);
466
467 enumData.userProc = (DWORD)arg3;
468 enumData.userData = arg4;
469
470 rc = O32_EnumFontFamilies(hdc, lpstrFamilyNew, &EnumFontProcA, (LPARAM)&enumData);
471
472 return rc;
473}
474//******************************************************************************
475//******************************************************************************
476int WIN32API EnumFontFamiliesW(HDC hdc,
477 LPCWSTR lpszFontFamilyW,
478 FONTENUMPROCW arg3,
479 LPARAM arg4)
480{
481 CHAR lpstrFamilyNew[LF_FACESIZE] = "";
482 ENUMUSERDATA enumData;
483 int rc;
484 char *lpszFontFamilyA = UnicodeToAsciiString((LPWSTR)lpszFontFamilyW);
485
486 dprintf(("GDI32: EnumFontFamiliesW %s", lpszFontFamilyA));
487
488 iFontRename(lpszFontFamilyA, lpstrFamilyNew);
489
490 enumData.userProc = (DWORD)arg3;
491 enumData.userData = arg4;
492
493 rc = O32_EnumFontFamilies(hdc, lpstrFamilyNew, &EnumFontProcW, (LPARAM)&enumData);
494
495 if(lpszFontFamilyA) FreeAsciiString(lpszFontFamilyA);
496 return rc;
497}
498//******************************************************************************
499//******************************************************************************
500INT WIN32API EnumFontFamiliesExA(HDC hdc,
501 LPLOGFONTA arg2,
502 FONTENUMPROCEXA arg3,
503 LPARAM arg4,
504 DWORD dwFlags)
505{
506 ENUMUSERDATA enumData;
507 int rc;
508
509 dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName));
510
511 enumData.userProc = (DWORD)arg3;
512 enumData.userData = arg4;
513 enumData.dwFlags = dwFlags;
514
515 rc = O32_EnumFontFamilies(hdc, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData);
516
517 return rc;
518}
519//******************************************************************************
520//******************************************************************************
521INT WIN32API EnumFontFamiliesExW(HDC hdc,
522 LPLOGFONTW arg2,
523 FONTENUMPROCEXW arg3,
524 LPARAM arg4,
525 DWORD dwFlags)
526{
527 ENUMUSERDATA enumData;
528 int rc;
529 char *astring = UnicodeToAsciiString((LPWSTR)arg2->lfFaceName);
530
531 dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring));
532
533 enumData.userProc = (DWORD)arg3;
534 enumData.userData = arg4;
535 enumData.dwFlags = dwFlags;
536
537 rc = O32_EnumFontFamilies(hdc, astring, &EnumFontProcExW, (LPARAM)&enumData);
538
539 FreeAsciiString(astring);
540 return rc;
541}
542//******************************************************************************
543//******************************************************************************
544DWORD WIN32API GetFontData(HDC hdc, DWORD dwTable,
545 DWORD dwOffset,
546 LPVOID lpvBuffer,
547 DWORD dbData)
548{
549 dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
550 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
551
552 return(GDI_ERROR);
553}
554//******************************************************************************
555//******************************************************************************
556int WIN32API AddFontResourceA(LPCSTR szFont)
557{
558 HINSTANCE hInstance;
559
560 dprintf(("GDI32: AddFontResourceA %s", szFont));
561 hInstance = LoadLibraryA(szFont);
562 if(hInstance) {
563 dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED"));
564 FreeLibrary(hInstance);
565 return 1;
566 }
567 return O32_AddFontResource(szFont);
568}
569//******************************************************************************
570//******************************************************************************
571int WIN32API AddFontResourceW(LPCWSTR szFont)
572{
573 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
574 BOOL rc;
575
576 dprintf(("GDI32: AddFontResourceW"));
577 // NOTE: This will not work as is (needs UNICODE support)
578 rc = AddFontResourceA(astring);
579 FreeAsciiString(astring);
580 return rc;
581}
582//******************************************************************************
583//******************************************************************************
584BOOL WIN32API RemoveFontResourceA(LPCSTR arg1)
585{
586 dprintf(("GDI32: RemoveFontResourceA %s\n", arg1));
587 return O32_RemoveFontResource(arg1);
588}
589//******************************************************************************
590//******************************************************************************
591BOOL WIN32API RemoveFontResourceW(LPCWSTR szFont)
592{
593 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
594 BOOL rc;
595
596 dprintf(("GDI32: RemoveFontResourceW"));
597 rc = RemoveFontResourceA(astring);
598 FreeAsciiString(astring);
599 return(rc);
600}
601/*****************************************************************************
602 * Name : BOOL CreateScalableFontResourceA
603 * Purpose : The CreateScalableFontResourceA function creates a font resource
604 * file for a scalable font.
605 * Parameters: DWORD fdwHidden flag for read-only embedded font
606 * LPCSTR lpszFontRes address of filename for font resource
607 * LPCSTR lpszFontFile address of filename for scalable font
608 * LPCSTR lpszCurrentPath address of path to font file
609 * Variables :
610 * Result : TRUE / FALSE
611 * Remark :
612 * Status : UNTESTED STUB
613 *
614 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
615 *****************************************************************************/
616
617BOOL WIN32API CreateScalableFontResourceA(DWORD fdwHidden,
618 LPCSTR lpszFontRes,
619 LPCSTR lpszFontFile,
620 LPCSTR lpszCurrentPath)
621{
622 dprintf(("GDI32: CreateScalableFontResourceA not implemented.\n"));
623
624 return (FALSE);
625}
626
627
628/*****************************************************************************
629 * Name : BOOL CreateScalableFontResourceW
630 * Purpose : The CreateScalableFontResourceW function creates a font resource
631 * file for a scalable font.
632 * Parameters: DWORD fdwHidden flag for read-only embedded font
633 * LPCSTR lpszFontRes address of filename for font resource
634 * LPCSTR lpszFontFile address of filename for scalable font
635 * LPCSTR lpszCurrentPath address of path to font file
636 * Variables :
637 * Result : TRUE / FALSE
638 * Remark :
639 * Status : UNTESTED STUB
640 *
641 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
642 *****************************************************************************/
643
644BOOL WIN32API CreateScalableFontResourceW(DWORD fdwHidden,
645 LPCWSTR lpszFontRes,
646 LPCWSTR lpszFontFile,
647 LPCWSTR lpszCurrentPath)
648{
649 dprintf(("GDI32: CreateScalableFontResourceW not implemented.\n"));
650
651 return (FALSE);
652}
653
654
655/*****************************************************************************
656 * Name : DWORD GetFontLanguageInfo
657 * Purpose : The GetFontLanguageInfo function returns information about the
658 * currently selected font for the specified display context.
659 * Applications typically use this information and the
660 * GetCharacterPlacement function to prepare a character string for display.
661 * Parameters: HDC hdc handle to device context
662 * Variables :
663 * Result :
664 * Remark :
665 * Status : UNTESTED STUB
666 *
667 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
668 *****************************************************************************/
669
670DWORD WIN32API GetFontLanguageInfo(HDC hdc)
671{
672 dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
673 hdc));
674
675 return (0);
676}
677
678
679/*************************************************************************
680 * TranslateCharsetInfo [GDI32.382]
681 *
682 * Fills a CHARSETINFO structure for a character set, code page, or
683 * font. This allows making the correspondance between different labelings
684 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
685 * of the same encoding.
686 *
687 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
688 * only one codepage should be set in *lpSrc.
689 *
690 * RETURNS
691 * TRUE on success, FALSE on failure.
692 *
693 *
694 * LPDWORD lpSrc, if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
695 * if flags == TCI_SRCCHARSET: a character set value
696 * if flags == TCI_SRCCODEPAGE: a code page value
697 * LPCHARSETINFO lpCs, structure to receive charset information
698 * DWORD flags determines interpretation of lpSrc
699 */
700BOOL WIN32API TranslateCharsetInfo(LPDWORD lpSrc, LPCHARSETINFO lpCs,
701 DWORD flags)
702{
703 int index = 0;
704 switch (flags) {
705 case TCI_SRCFONTSIG:
706 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
707 break;
708 case TCI_SRCCODEPAGE:
709 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
710 break;
711 case TCI_SRCCHARSET:
712 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
713 break;
714 default:
715 return FALSE;
716 }
717 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
718 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
719 return TRUE;
720}
721//******************************************************************************
722//******************************************************************************
723BOOL WIN32API GetTextMetricsA( HDC hdc, LPTEXTMETRICA pwtm)
724{
725 BOOL rc;
726
727 rc = O32_GetTextMetrics(hdc, pwtm);
728 dprintf(("GDI32: GetTextMetricsA %x %x returned %d", hdc, pwtm, rc));
729 return(rc);
730}
731//******************************************************************************
732//******************************************************************************
733BOOL WIN32API GetTextMetricsW( HDC hdc, LPTEXTMETRICW pwtm)
734{
735 BOOL rc;
736 TEXTMETRICA atm;
737
738 dprintf(("GDI32: GetTextMetricsW"));
739
740 rc = O32_GetTextMetrics(hdc, &atm);
741 pwtm->tmHeight = atm.tmHeight;
742 pwtm->tmAscent = atm.tmAscent;
743 pwtm->tmDescent = atm.tmDescent;
744 pwtm->tmInternalLeading = atm.tmInternalLeading;
745 pwtm->tmExternalLeading = atm.tmExternalLeading;
746 pwtm->tmAveCharWidth = atm.tmAveCharWidth;
747 pwtm->tmMaxCharWidth = atm.tmMaxCharWidth;
748 pwtm->tmWeight = atm.tmWeight;
749 pwtm->tmOverhang = atm.tmOverhang;
750 pwtm->tmDigitizedAspectX = atm.tmDigitizedAspectX;
751 pwtm->tmDigitizedAspectY = atm.tmDigitizedAspectY;
752 pwtm->tmFirstChar = atm.tmFirstChar;
753 pwtm->tmLastChar = atm.tmLastChar;
754 pwtm->tmDefaultChar = atm.tmDefaultChar;
755 pwtm->tmBreakChar = atm.tmBreakChar;
756 pwtm->tmItalic = atm.tmItalic;
757 pwtm->tmUnderlined = atm.tmUnderlined;
758 pwtm->tmStruckOut = atm.tmStruckOut;
759 pwtm->tmPitchAndFamily = atm.tmPitchAndFamily;
760 pwtm->tmCharSet = atm.tmCharSet;
761
762 dprintf(("GDI32: GetTextMetricsW %x %x returned %d", hdc, pwtm, rc));
763 return(rc);
764}
765//******************************************************************************
766//******************************************************************************
767int WIN32API GetTextFaceA( HDC hdc, int arg2, LPSTR arg3)
768{
769 dprintf(("GDI32: GetTextFaceA %x %d %x", hdc, arg2, arg3));
770 return O32_GetTextFace(hdc, arg2, arg3);
771}
772//******************************************************************************
773//******************************************************************************
774int WIN32API GetTextFaceW( HDC hdc, int arg2, LPWSTR arg3)
775{
776 char *astring = (char *)malloc(arg2+1);
777 int rc;
778
779 dprintf(("GDI32: GetTextFaceW"));
780 *astring = 0;
781 rc = GetTextFaceA(hdc, arg2, astring);
782 AsciiToUnicode(astring, arg3);
783 free(astring);
784 return rc;
785}
786//******************************************************************************
787//******************************************************************************
788UINT WIN32API GetOutlineTextMetricsA( HDC hdc, UINT arg2, LPOUTLINETEXTMETRICA arg3)
789{
790 dprintf(("GDI32: GetOutlineTextMetricsA %x %x %x", hdc, arg2, arg3));
791 return O32_GetOutlineTextMetrics(hdc, arg2, arg3);
792}
793//******************************************************************************
794//******************************************************************************
795UINT WIN32API GetOutlineTextMetricsW( HDC hdc, UINT arg2, LPOUTLINETEXTMETRICW arg3)
796{
797 dprintf(("!ERROR!: GDI32: GetOutlineTextMetricsW STUB"));
798 // NOTE: This will not work as is (needs UNICODE support)
799// return O32_GetOutlineTextMetrics(hdc, arg2, arg3);
800 return 0;
801}
802//******************************************************************************
803//******************************************************************************
Note: See TracBrowser for help on using the repository browser.