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

Last change on this file since 10349 was 10349, checked in by sandervl, 22 years ago

Updates

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