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