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

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

KOM: Use Warpsans Combined in DBCS environments

File size: 32.5 KB
Line 
1/* $Id: font.cpp,v 1.33 2003-12-01 13:28:10 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 if( IsDBCSEnv())
352 {
353 if( !strcmp( afont.lfFaceName, "WarpSans" ))
354 {
355 dprintf(("DBCS : WarpSans -> WarpSans Combined"));
356
357 strcpy( afont.lfFaceName, "WarpSans Combined" );
358 }
359 }
360
361 hFont = O32_CreateFontIndirect(&afont);
362 if(hFont) {
363 STATS_CreateFontIndirect(hFont, &afont);
364 }
365 return(hFont);
366}
367//******************************************************************************
368//******************************************************************************
369HFONT WIN32API CreateFontIndirectW(const LOGFONTW * lplf)
370{
371 LOGFONTA afont;
372 HFONT hfont;
373
374 //memcpy(&afont, lplf, ((ULONG)&afont.lfFaceName - (ULONG)&afont));
375 memcpy(&afont, lplf, sizeof(LOGFONTA));
376 memset(afont.lfFaceName, 0, LF_FACESIZE);
377 dprintf(("lpszFace = (%x)", lplf->lfFaceName));
378
379 UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
380 hfont = CreateFontIndirectA(&afont);
381 return(hfont);
382}
383//******************************************************************************
384//******************************************************************************
385int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
386 lpTextM, DWORD arg3, LPARAM arg4)
387{
388 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
389 FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc;
390 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
391
392 int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData);
393 SetFS(selTIB); // switch back to the saved FS selector
394 return rc;
395}
396//******************************************************************************
397//******************************************************************************
398int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
399 DWORD arg3, LPARAM arg4)
400{
401 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
402 FONTENUMPROCW proc = (FONTENUMPROCW)lpEnumData->userProc;
403 ENUMLOGFONTW LogFont;
404 NEWTEXTMETRICW textM;
405 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
406 int rc;
407
408 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName -
409 (ULONG)&LogFont));
410 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
411 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
412 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
413
414 textM.tmHeight = lpTextM->tmHeight;
415 textM.tmAscent = lpTextM->tmAscent;
416 textM.tmDescent = lpTextM->tmDescent;
417 textM.tmInternalLeading = lpTextM->tmInternalLeading;
418 textM.tmExternalLeading = lpTextM->tmExternalLeading;
419 textM.tmAveCharWidth = lpTextM->tmAveCharWidth;
420 textM.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
421 textM.tmWeight = lpTextM->tmWeight;
422 textM.tmOverhang = lpTextM->tmOverhang;
423 textM.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
424 textM.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
425 textM.tmFirstChar = lpTextM->tmFirstChar;
426 textM.tmLastChar = lpTextM->tmLastChar;
427 textM.tmDefaultChar = lpTextM->tmDefaultChar;
428 textM.tmBreakChar = lpTextM->tmBreakChar;
429 textM.tmItalic = lpTextM->tmItalic;
430 textM.tmUnderlined = lpTextM->tmUnderlined;
431 textM.tmStruckOut = lpTextM->tmStruckOut;
432 textM.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
433 textM.tmCharSet = lpTextM->tmCharSet;
434 textM.ntmFlags = 0;
435 textM.ntmSizeEM = 0;
436 textM.ntmCellHeight = 0;
437 textM.ntmAvgWidth = 0;
438
439 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
440 SetFS(selTIB); // switch back to the saved FS selector
441 return rc;
442}
443//******************************************************************************
444//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
445//******************************************************************************
446int EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
447 lpTextM, DWORD arg3, LPARAM arg4)
448{
449 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
450 FONTENUMPROCEXA proc = (FONTENUMPROCEXA)lpEnumData->userProc;
451 ENUMLOGFONTEXA logFont;
452 NEWTEXTMETRICEXA textM;
453 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
454
455 memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA));
456 memset(logFont.elfScript, 0, sizeof(logFont.elfScript));
457 memcpy(&textM.ntmTm, lpTextM, sizeof(textM.ntmTm));
458 memset(&textM.ntmFontSig, 0, sizeof(textM.ntmFontSig));
459
460 dprintf(("EnumFontProcExA %s height %d", logFont.elfLogFont.lfFaceName, textM.ntmTm.tmHeight));
461
462 int rc = proc(&logFont, &textM, arg3, lpEnumData->userData);
463 SetFS(selTIB); // switch back to the saved FS selector
464 return rc;
465}
466//******************************************************************************
467//TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part)
468//******************************************************************************
469int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
470 DWORD arg3, LPARAM arg4)
471{
472 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4;
473 FONTENUMPROCEXW proc = (FONTENUMPROCEXW)lpEnumData->userProc;
474 ENUMLOGFONTEXW LogFont;
475 NEWTEXTMETRICEXW textM;
476 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel
477 int rc;
478
479 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont));
480 memset(LogFont.elfScript, 0, sizeof(LogFont.elfScript));
481 AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
482 AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
483 AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
484
485 textM.ntmTm.tmHeight = lpTextM->tmHeight;
486 textM.ntmTm.tmAscent = lpTextM->tmAscent;
487 textM.ntmTm.tmDescent = lpTextM->tmDescent;
488 textM.ntmTm.tmInternalLeading = lpTextM->tmInternalLeading;
489 textM.ntmTm.tmExternalLeading = lpTextM->tmExternalLeading;
490 textM.ntmTm.tmAveCharWidth = lpTextM->tmAveCharWidth;
491 textM.ntmTm.tmMaxCharWidth = lpTextM->tmMaxCharWidth;
492 textM.ntmTm.tmWeight = lpTextM->tmWeight;
493 textM.ntmTm.tmOverhang = lpTextM->tmOverhang;
494 textM.ntmTm.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX;
495 textM.ntmTm.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY;
496 textM.ntmTm.tmFirstChar = lpTextM->tmFirstChar;
497 textM.ntmTm.tmLastChar = lpTextM->tmLastChar;
498 textM.ntmTm.tmDefaultChar = lpTextM->tmDefaultChar;
499 textM.ntmTm.tmBreakChar = lpTextM->tmBreakChar;
500 textM.ntmTm.tmItalic = lpTextM->tmItalic;
501 textM.ntmTm.tmUnderlined = lpTextM->tmUnderlined;
502 textM.ntmTm.tmStruckOut = lpTextM->tmStruckOut;
503 textM.ntmTm.tmPitchAndFamily = lpTextM->tmPitchAndFamily;
504 textM.ntmTm.tmCharSet = lpTextM->tmCharSet;
505 textM.ntmTm.ntmFlags = 0;
506 textM.ntmTm.ntmSizeEM = 0;
507 textM.ntmTm.ntmCellHeight = 0;
508 textM.ntmTm.ntmAvgWidth = 0;
509 memset(&textM.ntmFontSig, 0, sizeof(textM.ntmFontSig));
510
511 dprintf(("EnumFontProcExW %s height %d", lpLogFont->elfLogFont.lfFaceName, textM.ntmTm.tmHeight));
512 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);
513 SetFS(selTIB); // switch back to the saved FS selector
514 return rc;
515}
516//******************************************************************************
517//******************************************************************************
518int WIN32API EnumFontsA(HDC hdc,
519 LPCSTR arg2,
520 FONTENUMPROCA arg3,
521 LPARAM arg4)
522{
523 //@@@PH shouldn't this rather be O32_EnumFonts ?
524 return EnumFontFamiliesA(hdc, arg2, arg3, arg4);
525}
526//******************************************************************************
527//******************************************************************************
528int WIN32API EnumFontsW(HDC hdc,
529 LPCWSTR arg2,
530 FONTENUMPROCW arg3,
531 LPARAM arg4)
532{
533 //@@@PH shouldn't this rather be O32_EnumFonts ?
534 return EnumFontFamiliesW(hdc, arg2, arg3, arg4);
535}
536//******************************************************************************
537//******************************************************************************
538int WIN32API EnumFontFamiliesA(HDC hdc,
539 LPCSTR lpszFontFamily,
540 FONTENUMPROCA arg3,
541 LPARAM arg4)
542{
543 ENUMUSERDATA enumData;
544 CHAR lpstrFamilyNew[LF_FACESIZE] = "";
545 int rc;
546
547 dprintf(("GDI32: EnumFontFamiliesA %s", lpszFontFamily));
548
549 iFontRename(lpszFontFamily, lpstrFamilyNew);
550
551 enumData.userProc = (DWORD)arg3;
552 enumData.userData = arg4;
553
554 rc = O32_EnumFontFamilies(hdc, lpstrFamilyNew, &EnumFontProcA, (LPARAM)&enumData);
555
556 return rc;
557}
558//******************************************************************************
559//******************************************************************************
560int WIN32API EnumFontFamiliesW(HDC hdc,
561 LPCWSTR lpszFontFamilyW,
562 FONTENUMPROCW arg3,
563 LPARAM arg4)
564{
565 CHAR lpstrFamilyNew[LF_FACESIZE] = "";
566 ENUMUSERDATA enumData;
567 int rc;
568 char *lpszFontFamilyA = UnicodeToAsciiString((LPWSTR)lpszFontFamilyW);
569
570 dprintf(("GDI32: EnumFontFamiliesW %s", lpszFontFamilyA));
571
572 iFontRename(lpszFontFamilyA, lpstrFamilyNew);
573
574 enumData.userProc = (DWORD)arg3;
575 enumData.userData = arg4;
576
577 rc = O32_EnumFontFamilies(hdc, lpstrFamilyNew, &EnumFontProcW, (LPARAM)&enumData);
578
579 if(lpszFontFamilyA) FreeAsciiString(lpszFontFamilyA);
580 return rc;
581}
582//******************************************************************************
583//******************************************************************************
584INT WIN32API EnumFontFamiliesExA(HDC hdc,
585 LPLOGFONTA arg2,
586 FONTENUMPROCEXA arg3,
587 LPARAM arg4,
588 DWORD dwFlags)
589{
590 ENUMUSERDATA enumData;
591 int rc;
592
593 dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName));
594
595 enumData.userProc = (DWORD)arg3;
596 enumData.userData = arg4;
597 enumData.dwFlags = dwFlags;
598
599 rc = O32_EnumFontFamilies(hdc, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData);
600
601 return rc;
602}
603//******************************************************************************
604//******************************************************************************
605INT WIN32API EnumFontFamiliesExW(HDC hdc,
606 LPLOGFONTW arg2,
607 FONTENUMPROCEXW arg3,
608 LPARAM arg4,
609 DWORD dwFlags)
610{
611 ENUMUSERDATA enumData;
612 int rc;
613 char *astring = UnicodeToAsciiString((LPWSTR)arg2->lfFaceName);
614
615 dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring));
616
617 enumData.userProc = (DWORD)arg3;
618 enumData.userData = arg4;
619 enumData.dwFlags = dwFlags;
620
621 rc = O32_EnumFontFamilies(hdc, astring, &EnumFontProcExW, (LPARAM)&enumData);
622
623 FreeAsciiString(astring);
624 return rc;
625}
626//******************************************************************************
627//******************************************************************************
628DWORD WIN32API GetFontData(HDC hdc, DWORD dwTable,
629 DWORD dwOffset,
630 LPVOID lpvBuffer,
631 DWORD dbData)
632{
633 dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
634 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
635
636 return(GDI_ERROR);
637}
638//******************************************************************************
639//******************************************************************************
640int WIN32API AddFontResourceA(LPCSTR szFont)
641{
642 HINSTANCE hInstance;
643
644 dprintf(("GDI32: AddFontResourceA %s", szFont));
645 hInstance = LoadLibraryA(szFont);
646 if(hInstance) {
647 dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED"));
648 FreeLibrary(hInstance);
649 return 1;
650 }
651 return 1;
652}
653//******************************************************************************
654//******************************************************************************
655int WIN32API AddFontResourceW(LPCWSTR szFont)
656{
657 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
658 BOOL rc;
659
660 dprintf(("GDI32: AddFontResourceW"));
661 // NOTE: This will not work as is (needs UNICODE support)
662 rc = AddFontResourceA(astring);
663 FreeAsciiString(astring);
664 return rc;
665}
666//******************************************************************************
667//******************************************************************************
668BOOL WIN32API RemoveFontResourceA(LPCSTR lpszFont)
669{
670 dprintf(("GDI32: RemoveFontResourceA %s", lpszFont));
671 return FALSE;
672}
673//******************************************************************************
674//******************************************************************************
675BOOL WIN32API RemoveFontResourceW(LPCWSTR szFont)
676{
677 char *astring = UnicodeToAsciiString((LPWSTR)szFont);
678 BOOL rc;
679
680 dprintf(("GDI32: RemoveFontResourceW"));
681 rc = RemoveFontResourceA(astring);
682 FreeAsciiString(astring);
683 return(rc);
684}
685/*****************************************************************************
686 * Name : BOOL CreateScalableFontResourceA
687 * Purpose : The CreateScalableFontResourceA function creates a font resource
688 * file for a scalable font.
689 * Parameters: DWORD fdwHidden flag for read-only embedded font
690 * LPCSTR lpszFontRes address of filename for font resource
691 * LPCSTR lpszFontFile address of filename for scalable font
692 * LPCSTR lpszCurrentPath address of path to font file
693 * Variables :
694 * Result : TRUE / FALSE
695 * Remark :
696 * Status : UNTESTED STUB
697 *
698 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
699 *****************************************************************************/
700
701BOOL WIN32API CreateScalableFontResourceA(DWORD fdwHidden,
702 LPCSTR lpszFontRes,
703 LPCSTR lpszFontFile,
704 LPCSTR lpszCurrentPath)
705{
706 dprintf(("GDI32: CreateScalableFontResourceA %x %s %s %s not implemented", fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath));
707
708// return OSLibGpiLoadFonts((LPSTR)lpszFontFile);
709 return FALSE;
710}
711
712
713/*****************************************************************************
714 * Name : BOOL CreateScalableFontResourceW
715 * Purpose : The CreateScalableFontResourceW function creates a font resource
716 * file for a scalable font.
717 * Parameters: DWORD fdwHidden flag for read-only embedded font
718 * LPCSTR lpszFontRes address of filename for font resource
719 * LPCSTR lpszFontFile address of filename for scalable font
720 * LPCSTR lpszCurrentPath address of path to font file
721 * Variables :
722 * Result : TRUE / FALSE
723 * Remark :
724 * Status : UNTESTED STUB
725 *
726 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
727 *****************************************************************************/
728
729BOOL WIN32API CreateScalableFontResourceW(DWORD fdwHidden,
730 LPCWSTR lpszFontRes,
731 LPCWSTR lpszFontFile,
732 LPCWSTR lpszCurrentPath)
733{
734 LPSTR lpszFontFileA = NULL, lpszFontResA = NULL, lpszCurrentPathA = NULL;
735
736 dprintf(("GDI32: CreateScalableFontResourceW %x %ls %ls %ls not implemented", fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath));
737
738 STACK_strdupWtoA(lpszFontFile, lpszFontFileA);
739 STACK_strdupWtoA(lpszFontRes, lpszFontResA);
740 STACK_strdupWtoA(lpszCurrentPath, lpszCurrentPathA);
741 return CreateScalableFontResourceA(fdwHidden, lpszFontResA, lpszFontFileA, lpszCurrentPathA);
742}
743
744
745/*****************************************************************************
746 * Name : DWORD GetFontLanguageInfo
747 * Purpose : The GetFontLanguageInfo function returns information about the
748 * currently selected font for the specified display context.
749 * Applications typically use this information and the
750 * GetCharacterPlacement function to prepare a character string for display.
751 * Parameters: HDC hdc handle to device context
752 * Variables :
753 * Result :
754 * Remark :
755 * Status : UNTESTED STUB
756 *
757 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
758 *****************************************************************************/
759
760DWORD WIN32API GetFontLanguageInfo(HDC hdc)
761{
762 dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
763 hdc));
764
765 return (0);
766}
767
768
769/*************************************************************************
770 * TranslateCharsetInfo [GDI32.382]
771 *
772 * Fills a CHARSETINFO structure for a character set, code page, or
773 * font. This allows making the correspondance between different labelings
774 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
775 * of the same encoding.
776 *
777 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
778 * only one codepage should be set in *lpSrc.
779 *
780 * RETURNS
781 * TRUE on success, FALSE on failure.
782 *
783 *
784 * LPDWORD lpSrc, if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
785 * if flags == TCI_SRCCHARSET: a character set value
786 * if flags == TCI_SRCCODEPAGE: a code page value
787 * LPCHARSETINFO lpCs, structure to receive charset information
788 * DWORD flags determines interpretation of lpSrc
789 */
790BOOL WIN32API TranslateCharsetInfo(LPDWORD lpSrc, LPCHARSETINFO lpCs,
791 DWORD flags)
792{
793 int index = 0;
794 switch (flags) {
795 case TCI_SRCFONTSIG:
796 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
797 break;
798 case TCI_SRCCODEPAGE:
799 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
800 break;
801 case TCI_SRCCHARSET:
802 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
803 break;
804 default:
805 return FALSE;
806 }
807 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
808 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
809 return TRUE;
810}
811//******************************************************************************
812//******************************************************************************
813BOOL WIN32API GetTextMetricsA( HDC hdc, LPTEXTMETRICA pwtm)
814{
815 BOOL rc;
816
817 rc = O32_GetTextMetrics(hdc, pwtm);
818 dprintf(("GDI32: GetTextMetricsA %x %x returned %d", hdc, pwtm, rc));
819 return(rc);
820}
821//******************************************************************************
822//******************************************************************************
823BOOL WIN32API GetTextMetricsW( HDC hdc, LPTEXTMETRICW pwtm)
824{
825 BOOL rc;
826 TEXTMETRICA atm;
827
828 dprintf(("GDI32: GetTextMetricsW"));
829
830 rc = O32_GetTextMetrics(hdc, &atm);
831 pwtm->tmHeight = atm.tmHeight;
832 pwtm->tmAscent = atm.tmAscent;
833 pwtm->tmDescent = atm.tmDescent;
834 pwtm->tmInternalLeading = atm.tmInternalLeading;
835 pwtm->tmExternalLeading = atm.tmExternalLeading;
836 pwtm->tmAveCharWidth = atm.tmAveCharWidth;
837 pwtm->tmMaxCharWidth = atm.tmMaxCharWidth;
838 pwtm->tmWeight = atm.tmWeight;
839 pwtm->tmOverhang = atm.tmOverhang;
840 pwtm->tmDigitizedAspectX = atm.tmDigitizedAspectX;
841 pwtm->tmDigitizedAspectY = atm.tmDigitizedAspectY;
842 pwtm->tmFirstChar = atm.tmFirstChar;
843 pwtm->tmLastChar = atm.tmLastChar;
844 pwtm->tmDefaultChar = atm.tmDefaultChar;
845 pwtm->tmBreakChar = atm.tmBreakChar;
846 pwtm->tmItalic = atm.tmItalic;
847 pwtm->tmUnderlined = atm.tmUnderlined;
848 pwtm->tmStruckOut = atm.tmStruckOut;
849 pwtm->tmPitchAndFamily = atm.tmPitchAndFamily;
850 pwtm->tmCharSet = atm.tmCharSet;
851
852 dprintf(("GDI32: GetTextMetricsW %x %x returned %d", hdc, pwtm, rc));
853 return(rc);
854}
855//******************************************************************************
856//******************************************************************************
857int WIN32API GetTextFaceA( HDC hdc, int arg2, LPSTR arg3)
858{
859 dprintf(("GDI32: GetTextFaceA %x %d %x", hdc, arg2, arg3));
860 return O32_GetTextFace(hdc, arg2, arg3);
861}
862//******************************************************************************
863//******************************************************************************
864int WIN32API GetTextFaceW( HDC hdc, int arg2, LPWSTR arg3)
865{
866 char *astring = NULL;
867 int lenA = GetTextFaceA( hdc, 0, NULL );
868 int rc;
869
870 dprintf(("GDI32: GetTextFaceW"));
871 astring = ( char * )malloc( lenA );
872 if( astring )
873 return 0;
874
875 rc = GetTextFaceA(hdc, lenA, astring);
876
877 if( rc )
878 {
879 if( arg3 )
880 {
881 AsciiToUnicodeN(astring, arg3, arg2);
882 rc = lstrlenW( arg3 );
883 }
884 else
885 rc = lstrlenAtoW( astring, -1 );
886
887 rc++; // including null-terminator
888 }
889
890 free(astring);
891
892 return rc;
893}
894//******************************************************************************
895//******************************************************************************
896UINT WIN32API GetOutlineTextMetricsA( HDC hdc, UINT arg2, LPOUTLINETEXTMETRICA arg3)
897{
898 dprintf(("GDI32: GetOutlineTextMetricsA %x %x %x", hdc, arg2, arg3));
899 return O32_GetOutlineTextMetrics(hdc, arg2, arg3);
900}
901//******************************************************************************
902//******************************************************************************
903UINT WIN32API GetOutlineTextMetricsW( HDC hdc, UINT arg2, LPOUTLINETEXTMETRICW arg3)
904{
905 dprintf(("!ERROR!: GDI32: GetOutlineTextMetricsW STUB"));
906 // NOTE: This will not work as is (needs UNICODE support)
907// return O32_GetOutlineTextMetrics(hdc, arg2, arg3);
908 return 0;
909}
910//******************************************************************************
911//******************************************************************************
Note: See TracBrowser for help on using the repository browser.