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

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

KOM: Fixed FONT_mbtowc(). If charset is 0, CP must not be 1252 in DBCS country; Restored calcDimensions(). The result of the old is the same as that of O32_GetTextExtent()

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