1 | /* $Id: font.cpp,v 1.2 1999-11-09 19:52:33 phaller Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * GDI32 font apis
|
---|
5 | *
|
---|
6 | * Copyright 1999 Edgar Buerkle (Edgar.Buerkle@gmx.ne)
|
---|
7 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
8 | * Copyright 1998 Patrick Haller
|
---|
9 | *
|
---|
10 | * TODO: EnumFontsA/W, EnumFontFamiliesExA/W + others
|
---|
11 | *
|
---|
12 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
13 | *
|
---|
14 | */
|
---|
15 |
|
---|
16 | #include <odin.h>
|
---|
17 | #include <odinwrap.h>
|
---|
18 | #include <os2sel.h>
|
---|
19 |
|
---|
20 | #include <os2win.h>
|
---|
21 | #include <stdlib.h>
|
---|
22 | #include <stdarg.h>
|
---|
23 | #include <string.h>
|
---|
24 | #include "misc.h"
|
---|
25 | #include "unicode.h"
|
---|
26 | #include <vmutex.h>
|
---|
27 |
|
---|
28 |
|
---|
29 | ODINDEBUGCHANNEL(GDI32-FONT)
|
---|
30 |
|
---|
31 |
|
---|
32 | VMutex mutexProcWinA;
|
---|
33 | VMutex mutexProcWinW;
|
---|
34 | FONTENUMPROCA FontEnumProcWinA;
|
---|
35 | FONTENUMPROCW FontEnumProcWinW;
|
---|
36 |
|
---|
37 | //******************************************************************************
|
---|
38 | //******************************************************************************
|
---|
39 | HFONT WIN32API CreateFontA(int arg1, int arg2, int arg3, int arg4, int arg5,
|
---|
40 | DWORD arg6, DWORD arg7, DWORD arg8, DWORD arg9,
|
---|
41 | DWORD arg10, DWORD arg11, DWORD arg12, DWORD arg13, LPCSTR arg14)
|
---|
42 | {
|
---|
43 | HFONT hfont;
|
---|
44 |
|
---|
45 | hfont = O32_CreateFont(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
|
---|
46 | dprintf(("GDI32: CreateFontA '%s' returned %D\n", arg14, hfont));
|
---|
47 | return(hfont);
|
---|
48 | }
|
---|
49 | //******************************************************************************
|
---|
50 | //******************************************************************************
|
---|
51 | HFONT WIN32API CreateFontW(int arg1, int arg2, int arg3, int arg4, int arg5,
|
---|
52 | DWORD arg6, DWORD arg7, DWORD arg8, DWORD arg9,
|
---|
53 | DWORD arg10, DWORD arg11, DWORD arg12, DWORD arg13, LPCWSTR arg14)
|
---|
54 | {
|
---|
55 | char *astring = UnicodeToAsciiString((LPWSTR)arg14);
|
---|
56 | HFONT rc;
|
---|
57 |
|
---|
58 | dprintf(("GDI32: OS2CreateFontW\n"));
|
---|
59 | rc = O32_CreateFont(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, astring);
|
---|
60 | FreeAsciiString(astring);
|
---|
61 | return(rc);
|
---|
62 | }
|
---|
63 | //******************************************************************************
|
---|
64 | //******************************************************************************
|
---|
65 | HFONT WIN32API CreateFontIndirectA(const LOGFONTA *lplf)
|
---|
66 | {
|
---|
67 | HFONT rc;
|
---|
68 |
|
---|
69 | dprintf(("GDI32: CreateFontIndirectA\n"));
|
---|
70 | dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));
|
---|
71 | dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));
|
---|
72 | dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement));
|
---|
73 | dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation));
|
---|
74 | dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight));
|
---|
75 | dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic));
|
---|
76 | dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline));
|
---|
77 | dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut));
|
---|
78 | dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet));
|
---|
79 | dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision));
|
---|
80 | dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision));
|
---|
81 | dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality));
|
---|
82 | dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily));
|
---|
83 | dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName));
|
---|
84 | rc = O32_CreateFontIndirect(lplf);
|
---|
85 | dprintf(("GDI32: OS2CreateFontIndirectA returned %X\n", rc));
|
---|
86 | return(rc);
|
---|
87 | }
|
---|
88 | //******************************************************************************
|
---|
89 | //******************************************************************************
|
---|
90 | ODINFUNCTION1(HFONT, CreateFontIndirectW,const LOGFONTW *, lplf)
|
---|
91 | {
|
---|
92 | LOGFONTA afont;
|
---|
93 | HFONT hfont;
|
---|
94 |
|
---|
95 | //memcpy(&afont, lplf, ((int)&afont.lfFaceName - (int)&afont));
|
---|
96 | memcpy(&afont, lplf, sizeof(LOGFONTA));
|
---|
97 | UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
|
---|
98 | hfont = CreateFontIndirectA(&afont);
|
---|
99 | return(hfont);
|
---|
100 | }
|
---|
101 | //******************************************************************************
|
---|
102 | //******************************************************************************
|
---|
103 | int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
|
---|
104 | lpTextM, DWORD arg3, LPARAM arg4)
|
---|
105 | {
|
---|
106 | return FontEnumProcWinA(lpLogFont, lpTextM, arg3, arg4);
|
---|
107 | }
|
---|
108 | //******************************************************************************
|
---|
109 | //******************************************************************************
|
---|
110 | int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
|
---|
111 | DWORD arg3, LPARAM arg4)
|
---|
112 | {
|
---|
113 | ENUMLOGFONTW LogFont;
|
---|
114 | int rc;
|
---|
115 |
|
---|
116 | memcpy(&LogFont, lpLogFont, ((int)&LogFont.elfLogFont.lfFaceName -
|
---|
117 | (int)&LogFont));
|
---|
118 | AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
|
---|
119 | AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
|
---|
120 | AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
|
---|
121 |
|
---|
122 | rc = FontEnumProcWinW(&LogFont, (LPNEWTEXTMETRICW) lpTextM, arg3, arg4);
|
---|
123 | return rc;
|
---|
124 | }
|
---|
125 | //******************************************************************************
|
---|
126 | //******************************************************************************
|
---|
127 | int WIN32API EnumFontsA( HDC arg1, LPCSTR arg2, FONTENUMPROCA arg3, LPARAM arg4)
|
---|
128 | {
|
---|
129 | dprintf(("GDI32: OS2EnumFontsA"));
|
---|
130 | // return O32_EnumFonts(arg1, arg2, arg3, arg4);
|
---|
131 | return 1;
|
---|
132 | }
|
---|
133 | //******************************************************************************
|
---|
134 | //TODO: Callback
|
---|
135 | //******************************************************************************
|
---|
136 | int WIN32API EnumFontsW( HDC arg1, LPCWSTR arg2, FONTENUMPROCW arg3, LPARAM arg4)
|
---|
137 | {
|
---|
138 | dprintf(("GDI32: OS2EnumFontsW - stub (1)"));
|
---|
139 | // NOTE: This will not work as is (needs UNICODE support)
|
---|
140 | // return O32_EnumFonts(arg1, arg2, arg3, arg4);
|
---|
141 | return 1;
|
---|
142 | }
|
---|
143 | //******************************************************************************
|
---|
144 | //******************************************************************************
|
---|
145 | int WIN32API EnumFontFamiliesA(HDC arg1,
|
---|
146 | LPCSTR arg2,
|
---|
147 | FONTENUMPROCA arg3,
|
---|
148 | LPARAM arg4)
|
---|
149 | {
|
---|
150 | int rc;
|
---|
151 |
|
---|
152 | dprintf(("GDI32: OS2EnumFontFamiliesA "));
|
---|
153 |
|
---|
154 | mutexProcWinA.enter();
|
---|
155 |
|
---|
156 | FontEnumProcWinA = arg3;
|
---|
157 |
|
---|
158 | rc = O32_EnumFontFamilies(arg1, arg2, &EnumFontProcA, arg4);
|
---|
159 |
|
---|
160 | mutexProcWinA.leave();
|
---|
161 | return rc;
|
---|
162 | }
|
---|
163 | //******************************************************************************
|
---|
164 | //******************************************************************************
|
---|
165 | int WIN32API EnumFontFamiliesW(HDC arg1,
|
---|
166 | LPCWSTR arg2,
|
---|
167 | FONTENUMPROCW arg3,
|
---|
168 | LPARAM arg4)
|
---|
169 | {
|
---|
170 | int rc;
|
---|
171 | char *astring = UnicodeToAsciiString((LPWSTR)arg2);
|
---|
172 |
|
---|
173 | dprintf(("GDI32: OS2EnumFontFamiliesW "));
|
---|
174 |
|
---|
175 | mutexProcWinW.enter();
|
---|
176 |
|
---|
177 | FontEnumProcWinW = arg3;
|
---|
178 |
|
---|
179 | rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcW, arg4);
|
---|
180 |
|
---|
181 | mutexProcWinW.leave();
|
---|
182 |
|
---|
183 | FreeAsciiString(astring);
|
---|
184 | return rc;
|
---|
185 | }
|
---|
186 | //******************************************************************************
|
---|
187 | //******************************************************************************
|
---|
188 | INT WIN32API EnumFontFamiliesExA( HDC arg1, LPLOGFONTA arg2, FONTENUMPROCEXA arg3, LPARAM arg4, DWORD dwFlags)
|
---|
189 | {
|
---|
190 | dprintf(("GDI32: OS2EnumFontFamiliesExA, not implemented\n"));
|
---|
191 | return 0;
|
---|
192 | }
|
---|
193 | //******************************************************************************
|
---|
194 | //******************************************************************************
|
---|
195 | INT WIN32API EnumFontFamiliesExW( HDC arg1, LPLOGFONTW arg2, FONTENUMPROCEXW arg3, LPARAM arg4, DWORD dwFlags)
|
---|
196 | {
|
---|
197 | dprintf(("GDI32: OS2EnumFontFamiliesW, not implemented\n"));
|
---|
198 | // NOTE: This will not work as is (needs UNICODE support)
|
---|
199 | return 0;
|
---|
200 | }
|
---|
201 | //******************************************************************************
|
---|
202 | //******************************************************************************
|
---|
203 | DWORD WIN32API GetFontData(HDC hdc, DWORD dwTable, DWORD dwOffset, LPVOID lpvBuffer,
|
---|
204 | DWORD dbData)
|
---|
205 | {
|
---|
206 | dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
|
---|
207 | return(GDI_ERROR);
|
---|
208 | }
|
---|
209 | //******************************************************************************
|
---|
210 | //******************************************************************************
|
---|
211 | int WIN32API AddFontResourceA( LPCSTR arg1)
|
---|
212 | {
|
---|
213 | dprintf(("GDI32: OS2AddFontResourceA"));
|
---|
214 | return O32_AddFontResource(arg1);
|
---|
215 | }
|
---|
216 | //******************************************************************************
|
---|
217 | //******************************************************************************
|
---|
218 | int WIN32API AddFontResourceW( LPCWSTR arg1)
|
---|
219 | {
|
---|
220 | dprintf(("GDI32: OS2AddFontResourceW STUB"));
|
---|
221 | // NOTE: This will not work as is (needs UNICODE support)
|
---|
222 | // return O32_AddFontResource(arg1);
|
---|
223 | return 0;
|
---|
224 | }
|
---|
225 | //******************************************************************************
|
---|
226 | //******************************************************************************
|
---|
227 | BOOL WIN32API RemoveFontResourceA( LPCSTR arg1)
|
---|
228 | {
|
---|
229 | dprintf(("GDI32: OS2RemoveFontResourceA %s\n", arg1));
|
---|
230 | return O32_RemoveFontResource(arg1);
|
---|
231 | }
|
---|
232 | //******************************************************************************
|
---|
233 | //******************************************************************************
|
---|
234 | BOOL WIN32API RemoveFontResourceW(LPCWSTR arg1)
|
---|
235 | {
|
---|
236 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
237 | BOOL rc;
|
---|
238 |
|
---|
239 | dprintf(("GDI32: OS2RemoveFontResourceW\n"));
|
---|
240 | rc = O32_RemoveFontResource(astring);
|
---|
241 | FreeAsciiString(astring);
|
---|
242 | return(rc);
|
---|
243 | }
|
---|
244 | /*****************************************************************************
|
---|
245 | * Name : BOOL CreateScalableFontResourceA
|
---|
246 | * Purpose : The CreateScalableFontResourceA function creates a font resource
|
---|
247 | * file for a scalable font.
|
---|
248 | * Parameters: DWORD fdwHidden flag for read-only embedded font
|
---|
249 | * LPCSTR lpszFontRes address of filename for font resource
|
---|
250 | * LPCSTR lpszFontFile address of filename for scalable font
|
---|
251 | * LPCSTR lpszCurrentPath address of path to font file
|
---|
252 | * Variables :
|
---|
253 | * Result : TRUE / FALSE
|
---|
254 | * Remark :
|
---|
255 | * Status : UNTESTED STUB
|
---|
256 | *
|
---|
257 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
258 | *****************************************************************************/
|
---|
259 |
|
---|
260 | BOOL WIN32API CreateScalableFontResourceA(DWORD fdwHidden,
|
---|
261 | LPCSTR lpszFontRes,
|
---|
262 | LPCSTR lpszFontFile,
|
---|
263 | LPCSTR lpszCurrentPath)
|
---|
264 | {
|
---|
265 | dprintf(("GDI32: CreateScalableFontResourceA(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
266 | fdwHidden,
|
---|
267 | lpszFontRes,
|
---|
268 | lpszFontFile,
|
---|
269 | lpszCurrentPath));
|
---|
270 |
|
---|
271 | return (FALSE);
|
---|
272 | }
|
---|
273 |
|
---|
274 |
|
---|
275 | /*****************************************************************************
|
---|
276 | * Name : BOOL CreateScalableFontResourceW
|
---|
277 | * Purpose : The CreateScalableFontResourceW function creates a font resource
|
---|
278 | * file for a scalable font.
|
---|
279 | * Parameters: DWORD fdwHidden flag for read-only embedded font
|
---|
280 | * LPCSTR lpszFontRes address of filename for font resource
|
---|
281 | * LPCSTR lpszFontFile address of filename for scalable font
|
---|
282 | * LPCSTR lpszCurrentPath address of path to font file
|
---|
283 | * Variables :
|
---|
284 | * Result : TRUE / FALSE
|
---|
285 | * Remark :
|
---|
286 | * Status : UNTESTED STUB
|
---|
287 | *
|
---|
288 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
289 | *****************************************************************************/
|
---|
290 |
|
---|
291 | BOOL WIN32API CreateScalableFontResourceW(DWORD fdwHidden,
|
---|
292 | LPCWSTR lpszFontRes,
|
---|
293 | LPCWSTR lpszFontFile,
|
---|
294 | LPCWSTR lpszCurrentPath)
|
---|
295 | {
|
---|
296 | dprintf(("GDI32: CreateScalableFontResourceW(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
297 | fdwHidden,
|
---|
298 | lpszFontRes,
|
---|
299 | lpszFontFile,
|
---|
300 | lpszCurrentPath));
|
---|
301 |
|
---|
302 | return (FALSE);
|
---|
303 | }
|
---|
304 | /*****************************************************************************
|
---|
305 | * Name : DWORD GetFontLanguageInfo
|
---|
306 | * Purpose : The GetFontLanguageInfo function returns information about the
|
---|
307 | * currently selected font for the specified display context.
|
---|
308 | * Applications typically use this information and the
|
---|
309 | * GetCharacterPlacement function to prepare a character string for display.
|
---|
310 | * Parameters: HDC hdc handle to device context
|
---|
311 | * Variables :
|
---|
312 | * Result :
|
---|
313 | * Remark :
|
---|
314 | * Status : UNTESTED STUB
|
---|
315 | *
|
---|
316 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
317 | *****************************************************************************/
|
---|
318 |
|
---|
319 | DWORD WIN32API GetFontLanguageInfo(HDC hdc)
|
---|
320 | {
|
---|
321 | dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
|
---|
322 | hdc));
|
---|
323 |
|
---|
324 | return (0);
|
---|
325 | }
|
---|
326 | //******************************************************************************
|
---|
327 | //******************************************************************************
|
---|