1 | /*
|
---|
2 | * GDI32 FreeType2 Support Class
|
---|
3 | *
|
---|
4 | * Copyright 2003 Innotek Systemberatung GmbH (sandervl@innotek.de)
|
---|
5 | * (stauff@innotek.de)
|
---|
6 | *
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /*****************************************************************************
|
---|
12 | * Includes *
|
---|
13 | *****************************************************************************/
|
---|
14 |
|
---|
15 | #define INCL_DOS
|
---|
16 | #define INCL_GPI
|
---|
17 | #define INCL_WIN
|
---|
18 | #define INCL_SHLERRORS
|
---|
19 | #define INCL_WINERRORS
|
---|
20 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
21 | #include <stdlib.h>
|
---|
22 | #include <string.h>
|
---|
23 | #include <win32type.h>
|
---|
24 | #include <dbglog.h>
|
---|
25 | #include <win32api.h>
|
---|
26 | #include <winconst.h>
|
---|
27 | #include <winnls.h>
|
---|
28 | #include <heapstring.h>
|
---|
29 | #include <winuser32.h>
|
---|
30 | #include <odinlx.h>
|
---|
31 | #include "oslibgpi.h"
|
---|
32 |
|
---|
33 | #include "ft2supp.h"
|
---|
34 |
|
---|
35 | CFT2Module FT2Module;
|
---|
36 |
|
---|
37 | static BOOL fFT2LIBIntegration = FALSE;
|
---|
38 |
|
---|
39 | //******************************************************************************
|
---|
40 | //******************************************************************************
|
---|
41 | void WIN32API SetFreeTypeIntegration(BOOL fEnabled)
|
---|
42 | {
|
---|
43 | fFT2LIBIntegration = fEnabled;
|
---|
44 |
|
---|
45 | FT2Module.init();
|
---|
46 | }
|
---|
47 | //******************************************************************************
|
---|
48 | // Constructor
|
---|
49 | //******************************************************************************
|
---|
50 | CFT2Module::CFT2Module(char* sModuleName): bEnabled(FALSE), hftModule(0), pfnGetGlyphIndices(NULL),
|
---|
51 | pfnFt2GetTextExtentW(NULL), pfnFt2EnableFontEngine(NULL),
|
---|
52 | pfnFt2GetGlyphOutline(NULL), pfnFt2CharStringPosAtA(NULL),
|
---|
53 | pfnFt2CharStringPosAtW(NULL), pfnFt2GetFontData(NULL),
|
---|
54 | pfnFt2RegisterUconv(NULL), pfnFt2QueryStringWidthW(NULL),
|
---|
55 | pfnFt2GetVersion(NULL)
|
---|
56 | {
|
---|
57 | pszModuleName = sModuleName; //must be static
|
---|
58 | }
|
---|
59 | //******************************************************************************
|
---|
60 | //******************************************************************************
|
---|
61 | void CFT2Module::init()
|
---|
62 | {
|
---|
63 | APIRET rc;
|
---|
64 | UCHAR Loaderror[ 256 ];
|
---|
65 | LONG major = 0, minor = 0, buildnr = 0;
|
---|
66 |
|
---|
67 | if(!fFT2LIBIntegration) {
|
---|
68 | dprintf(("No FT2LIB integration!!"));
|
---|
69 | goto failure;
|
---|
70 | }
|
---|
71 |
|
---|
72 | rc = DosLoadModule((PSZ)Loaderror, sizeof(Loaderror), pszModuleName, &hftModule);
|
---|
73 | if (rc != 0)
|
---|
74 | dprintf(("Freetype2 library load error: return code = %u\n", rc));
|
---|
75 | else
|
---|
76 | bEnabled = TRUE;
|
---|
77 |
|
---|
78 | if(bEnabled) {
|
---|
79 | pfnFt2GetVersion = (PFN_FT2GETVERSION)QueryProcAddress("Ft2GetVersion");
|
---|
80 | if(!pfnFt2GetVersion) {
|
---|
81 | dprintf(("Ft2GetVersion not found!!"));
|
---|
82 | goto failure;
|
---|
83 | }
|
---|
84 | pfnFt2GetVersion(&major, &minor, &buildnr);
|
---|
85 | if(major != FT2LIB_MAJOR_VERSION) {
|
---|
86 | dprintf(("Incorrect major version %d; expected %d!!", major, FT2LIB_MAJOR_VERSION));
|
---|
87 | goto failure;
|
---|
88 | }
|
---|
89 | if(minor < FT2LIB_MINOR_VERSION) {
|
---|
90 | dprintf(("Incorrect minor version %d; expected >= %d!!", minor, FT2LIB_MINOR_VERSION));
|
---|
91 | goto failure;
|
---|
92 | }
|
---|
93 |
|
---|
94 | pfnFt2EnableFontEngine = (PFN_FT2ENABLEFONTENGINE)QueryProcAddress("Ft2EnableFontEngine");
|
---|
95 | if(!pfnFt2EnableFontEngine) dprintf(("Ft2EnableFontEngine not found!!"));
|
---|
96 | else pfnFt2EnableFontEngine(bEnabled);
|
---|
97 |
|
---|
98 | pfnFt2GetTextExtentW = (PFN_FT2GETTEXTEXTENTW)QueryProcAddress("Ft2GetTextExtentW");
|
---|
99 | if(!pfnFt2GetTextExtentW) dprintf(("Ft2GetTextExtentW not found!!"));
|
---|
100 |
|
---|
101 | pfnFt2CharStringPosAtA = (PFN_FT2CHARSTRINGPOSATA)QueryProcAddress("Ft2CharStringPosAtA");
|
---|
102 | if(!pfnFt2CharStringPosAtA) dprintf(("Ft2CharStringPosAtA not found!!"));
|
---|
103 | pfnFt2CharStringPosAtW = (PFN_FT2CHARSTRINGPOSATW)QueryProcAddress("Ft2CharStringPosAtW");
|
---|
104 | if(!pfnFt2CharStringPosAtW) dprintf(("Ft2CharStringPosAtW not found!!"));
|
---|
105 |
|
---|
106 | pfnFt2QueryFontType = (PFN_FT2QUERYFONTTYPE)QueryProcAddress("Ft2QueryFontType");
|
---|
107 | if(!pfnFt2QueryFontType) dprintf(("Ft2QueryFontType not found!!"));
|
---|
108 |
|
---|
109 | pfnFt2QueryStringWidthW = (PFN_FT2QUERYSTRINGWIDTHW)QueryProcAddress("Ft2QueryStringWidthW");
|
---|
110 | if(!pfnFt2QueryStringWidthW) dprintf(("Ft2QueryStringWidthW not found!!"));
|
---|
111 |
|
---|
112 | pfnFt2GetCharacterPlacementW = (PFN_FT2GETCHARACTERPLACEMENTW)QueryProcAddress("Ft2GetCharacterPlacementW");
|
---|
113 | if(!pfnFt2GetCharacterPlacementW) dprintf(("pfnFt2GetCharacterPlacementW not found!!"));
|
---|
114 |
|
---|
115 | // Do not register functions for Mozilla plugins
|
---|
116 | if(IsDummyExeLoaded() == FALSE)
|
---|
117 | {
|
---|
118 | pfnFt2RegisterUconv = (PFN_FT2REGISTERUCONV)QueryProcAddress("Ft2RegisterUconv");
|
---|
119 | if(pfnFt2RegisterUconv)
|
---|
120 | pfnFt2RegisterUconv(WideCharToMultiByte, MultiByteToWideChar);
|
---|
121 | else dprintf(("Ft2QueryFontType not found!!"));
|
---|
122 | }
|
---|
123 | dprintf(("Freetype2 library enabled state %d",bEnabled));
|
---|
124 | }
|
---|
125 | return;
|
---|
126 |
|
---|
127 | failure:
|
---|
128 | if(pfnFt2RegisterUconv)
|
---|
129 | pfnFt2RegisterUconv(NULL, NULL);
|
---|
130 | if(pfnFt2EnableFontEngine)
|
---|
131 | pfnFt2EnableFontEngine(FALSE);
|
---|
132 |
|
---|
133 | pfnGetGlyphIndices = NULL;
|
---|
134 | pfnFt2GetTextExtentW = NULL;
|
---|
135 | pfnFt2EnableFontEngine = NULL;
|
---|
136 | pfnFt2GetGlyphOutline = NULL;
|
---|
137 | pfnFt2CharStringPosAtA = NULL;
|
---|
138 | pfnFt2CharStringPosAtW = NULL;
|
---|
139 | pfnFt2GetFontData = NULL;
|
---|
140 | pfnFt2RegisterUconv = NULL;
|
---|
141 | pfnFt2QueryStringWidthW= NULL;
|
---|
142 | pfnFt2GetVersion = NULL;
|
---|
143 | bEnabled = FALSE;
|
---|
144 | if (hftModule) {
|
---|
145 | DosFreeModule(hftModule);
|
---|
146 | hftModule = 0;
|
---|
147 | }
|
---|
148 | return;
|
---|
149 | }
|
---|
150 | //******************************************************************************
|
---|
151 | // Destructor
|
---|
152 | //******************************************************************************
|
---|
153 | CFT2Module::~CFT2Module()
|
---|
154 | {
|
---|
155 | if (hftModule)
|
---|
156 | DosFreeModule(hftModule);
|
---|
157 |
|
---|
158 | bEnabled = FALSE;
|
---|
159 | }
|
---|
160 | //******************************************************************************
|
---|
161 | //******************************************************************************
|
---|
162 | PFN CFT2Module::QueryProcAddress(int ordinal)
|
---|
163 | {
|
---|
164 | APIRET rc;
|
---|
165 | PFN ModuleAddr;
|
---|
166 |
|
---|
167 | rc = DosQueryProcAddr(hftModule, ordinal, NULL, &ModuleAddr);
|
---|
168 | if (rc != 0) {
|
---|
169 | dprintf(("FreeType2 QueryProcAddr error: return code = %u\n", rc));
|
---|
170 | return 0;
|
---|
171 | }
|
---|
172 | return ModuleAddr;
|
---|
173 | }
|
---|
174 | //******************************************************************************
|
---|
175 | //******************************************************************************
|
---|
176 | PFN CFT2Module::QueryProcAddress(char * procname)
|
---|
177 | {
|
---|
178 | APIRET rc;
|
---|
179 | PFN ModuleAddr;
|
---|
180 |
|
---|
181 | rc = DosQueryProcAddr(hftModule, 0, procname, &ModuleAddr);
|
---|
182 | if (rc != 0) {
|
---|
183 | dprintf(("FreeType2 QueryProcAddr error: return code = %u\n", rc));
|
---|
184 | return 0;
|
---|
185 | }
|
---|
186 | return ModuleAddr;
|
---|
187 | }
|
---|
188 | //******************************************************************************
|
---|
189 | //******************************************************************************
|
---|
190 | DWORD CFT2Module::Ft2GetGlyphIndices(HPS hps, LPCWSTR str, int c, LPWORD pgi, DWORD fl)
|
---|
191 | {
|
---|
192 | //no fallback
|
---|
193 | return GDI_ERROR;
|
---|
194 | }
|
---|
195 | //******************************************************************************
|
---|
196 | //******************************************************************************
|
---|
197 | DWORD CFT2Module::Ft2GetGlyphOutline(HPS hps, UINT glyph, UINT format, LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf, const MAT2* lpmat)
|
---|
198 | {
|
---|
199 | //no fallback
|
---|
200 | SetLastError(ERROR_INVALID_FUNCTION_W);
|
---|
201 | return GDI_ERROR;
|
---|
202 | }
|
---|
203 | //******************************************************************************
|
---|
204 | //
|
---|
205 | // This is basically the same as Ft2QueryTextBoxW, but it behaves as the Win32
|
---|
206 | // API GetTextExtent (which ignores character attributes and underhang/overhang)
|
---|
207 | //
|
---|
208 | // The fallback case is not accurate!! (but the same as our old code)
|
---|
209 | //
|
---|
210 | //******************************************************************************
|
---|
211 | BOOL CFT2Module::Ft2GetTextExtentW(HPS hps, LONG lCount1,LPCWSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints)
|
---|
212 | {
|
---|
213 | DWORD ret;
|
---|
214 | USHORT sel;
|
---|
215 |
|
---|
216 | // All FreeType calls should be wrapped for saving FS
|
---|
217 | if(pfnFt2GetTextExtentW)
|
---|
218 | {
|
---|
219 | sel = RestoreOS2FS();
|
---|
220 | ret = pfnFt2GetTextExtentW(hps, lCount1, pchString, lCount2, aptlPoints);
|
---|
221 | SetFS(sel);
|
---|
222 | if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
|
---|
223 | {
|
---|
224 | //No need for scaling for printer DCs here
|
---|
225 | return ret;
|
---|
226 | }
|
---|
227 | }
|
---|
228 | //else fall back to GPI
|
---|
229 | int len;
|
---|
230 | LPSTR astring;
|
---|
231 |
|
---|
232 | pDCData pHps = (pDCData)OSLibGpiQueryDCData(hps);
|
---|
233 |
|
---|
234 | len = WideCharToMultiByte( CP_ACP, 0, pchString, lCount1, 0, 0, NULL, NULL );
|
---|
235 | astring = (char *)malloc( len + 1 );
|
---|
236 | lstrcpynWtoA(astring, pchString, len + 1 );
|
---|
237 |
|
---|
238 | ret = OSLibGpiQueryTextBox(pHps, lCount1, astring, lCount2, aptlPoints);
|
---|
239 | free(astring);
|
---|
240 | return ret;
|
---|
241 | }
|
---|
242 | //******************************************************************************
|
---|
243 | //******************************************************************************
|
---|
244 | BOOL CFT2Module::Ft2CharStringPosAtA(HPS hps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx, DWORD fuWin32Options)
|
---|
245 | {
|
---|
246 | DWORD ret;
|
---|
247 | USHORT sel;
|
---|
248 |
|
---|
249 | // All FreeType calls should be wrapped for saving FS
|
---|
250 | if(pfnFt2CharStringPosAtA) {
|
---|
251 | sel = RestoreOS2FS();
|
---|
252 | ret = pfnFt2CharStringPosAtA(hps, ptl,rct,flOptions,lCount,pchString,alAdx, fuWin32Options);
|
---|
253 | SetFS(sel);
|
---|
254 | if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
|
---|
255 | return ret;
|
---|
256 | }
|
---|
257 | //else fall back to GPI
|
---|
258 | //NOTE: We don't support fuWin32Options in the fallback case
|
---|
259 | pDCData pHps = (pDCData)OSLibGpiQueryDCData(hps);
|
---|
260 | return OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,lCount,pchString,alAdx);
|
---|
261 | }
|
---|
262 | //******************************************************************************
|
---|
263 | //******************************************************************************
|
---|
264 | BOOL CFT2Module::Ft2CharStringPosAtW(HPS hps, PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCWSTR pchString,CONST INT *alAdx, DWORD fuWin32Options)
|
---|
265 | {
|
---|
266 | DWORD ret;
|
---|
267 | USHORT sel;
|
---|
268 |
|
---|
269 | // All FreeType calls should be wrapped for saving FS
|
---|
270 | if(pfnFt2CharStringPosAtW) {
|
---|
271 | sel = RestoreOS2FS();
|
---|
272 | ret = pfnFt2CharStringPosAtW(hps, ptl,rct,flOptions,lCount,pchString,alAdx, fuWin32Options);
|
---|
273 | SetFS(sel);
|
---|
274 | if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
|
---|
275 | return ret;
|
---|
276 | }
|
---|
277 | //else fall back to GPI
|
---|
278 | //NOTE: We don't support fuWin32Options in the fallback case
|
---|
279 | int len;
|
---|
280 | LPSTR astring;
|
---|
281 |
|
---|
282 | pDCData pHps = (pDCData)OSLibGpiQueryDCData(hps);
|
---|
283 |
|
---|
284 | len = WideCharToMultiByte( CP_ACP, 0, pchString, lCount, 0, 0, NULL, NULL );
|
---|
285 | astring = (char *)malloc( len + 1 );
|
---|
286 | lstrcpynWtoA(astring, pchString, len + 1 );
|
---|
287 |
|
---|
288 | ret = OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,lCount,astring,alAdx);
|
---|
289 | free(astring);
|
---|
290 | return ret;
|
---|
291 | }
|
---|
292 | //******************************************************************************
|
---|
293 | //******************************************************************************
|
---|
294 | DWORD CFT2Module::Ft2GetFontData(HPS hps, DWORD dwTable, DWORD dwOffset,
|
---|
295 | LPVOID lpvBuffer, DWORD cbData)
|
---|
296 | {
|
---|
297 | //no fallback
|
---|
298 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED_W);
|
---|
299 | return(GDI_ERROR);
|
---|
300 | }
|
---|
301 | //******************************************************************************
|
---|
302 | // Query the font type current selected into the presentation space, or,
|
---|
303 | // when hps == NULL, query the type of the font with the specified name
|
---|
304 | //******************************************************************************
|
---|
305 | DWORD CFT2Module::Ft2QueryFontType(HPS hps, LPCSTR lpszFontName)
|
---|
306 | {
|
---|
307 | DWORD ret;
|
---|
308 | USHORT sel;
|
---|
309 |
|
---|
310 | // All FreeType calls should be wrapped for saving FS
|
---|
311 | if(pfnFt2QueryFontType) {
|
---|
312 | sel = RestoreOS2FS();
|
---|
313 | ret = pfnFt2QueryFontType(hps, lpszFontName);
|
---|
314 | SetFS(sel);
|
---|
315 | if(ret || (ret == GDI_ERROR && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
|
---|
316 | return ret;
|
---|
317 | }
|
---|
318 | //no fallback
|
---|
319 | return FT2_FONTTYPE_UNKNOWN;
|
---|
320 | }
|
---|
321 | //******************************************************************************
|
---|
322 | //******************************************************************************
|
---|
323 | BOOL CFT2Module::Ft2GetStringWidthW(HDC hdc, LPWSTR lpszString, UINT cbString, PINT pWidthArray)
|
---|
324 | {
|
---|
325 | DWORD ret;
|
---|
326 | USHORT sel;
|
---|
327 | pDCData pHps;
|
---|
328 |
|
---|
329 | pHps = (pDCData)OSLibGpiQueryDCData(hdc);
|
---|
330 | if(pHps == NULL) {
|
---|
331 | DebugInt3();
|
---|
332 | SetLastError(ERROR_INVALID_HANDLE_W);
|
---|
333 | return 0;
|
---|
334 | }
|
---|
335 |
|
---|
336 | // All FreeType calls should be wrapped for saving FS
|
---|
337 | if(pfnFt2QueryStringWidthW) {
|
---|
338 | sel = RestoreOS2FS();
|
---|
339 | ret = pfnFt2QueryStringWidthW((HPS)hdc, lpszString, cbString, (LONG *)pWidthArray);
|
---|
340 | SetFS(sel);
|
---|
341 | if(ret || (ret == GDI_ERROR && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
|
---|
342 | {
|
---|
343 | if(pHps && pHps->isPrinter && pHps->hdc)
|
---|
344 | {//scale for printer dcs
|
---|
345 | LONG alArray[2];
|
---|
346 |
|
---|
347 | if(OSLibDevQueryCaps(pHps, OSLIB_CAPS_HORIZONTAL_RESOLUTION, 2, &alArray[0]) &&
|
---|
348 | alArray[0] != alArray[1])
|
---|
349 | {
|
---|
350 | dprintf(("Different hor/vert resolutions (%d,%d)", alArray[0], alArray[1]));
|
---|
351 | for (int i = 0; i < cbString; i++)
|
---|
352 | {
|
---|
353 | pWidthArray[i] = pWidthArray[i] * alArray[0] / alArray[1];
|
---|
354 | }
|
---|
355 | }
|
---|
356 | }
|
---|
357 | return ret;
|
---|
358 | }
|
---|
359 | }
|
---|
360 | //fallback method
|
---|
361 | int c, i;
|
---|
362 | for (i = 0; i < cbString; i++)
|
---|
363 | {
|
---|
364 | if (GetCharWidth32W(hdc, lpszString[i], lpszString[i], (LPINT)&c)) {
|
---|
365 | dprintf(("%c pWidthArray[%d] = %d", lpszString[i], i, c));
|
---|
366 | pWidthArray[i]= c;
|
---|
367 | }
|
---|
368 | else {
|
---|
369 | dprintf(("WARNING: GetCharWidth32W failed for %c!!!", lpszString[i]));
|
---|
370 | pWidthArray[i] = 0;
|
---|
371 | }
|
---|
372 | }
|
---|
373 | return TRUE;
|
---|
374 | }
|
---|
375 | /*****************************************************************************
|
---|
376 | * Name : DWORD GetCharacterPlacementW
|
---|
377 | * Purpose : The GetCharacterPlacementW function retrieves information about
|
---|
378 | * a character string, such as character widths, caret positioning,
|
---|
379 | * ordering within the string, and glyph rendering. The type of
|
---|
380 | * information returned depends on the dwFlags parameter and is
|
---|
381 | * based on the currently selected font in the given display context.
|
---|
382 | * The function copies the information to the specified GCP_RESULTSW
|
---|
383 | * structure or to one or more arrays specified by the structure.
|
---|
384 | * Parameters: HDC hdc handle to device context
|
---|
385 | * LPCSTR lpString pointer to string
|
---|
386 | * int nCount number of characters in string
|
---|
387 | * int nMaxExtent maximum extent for displayed string
|
---|
388 | * GCP_RESULTSW *lpResults pointer to buffer for placement result
|
---|
389 | * DWORD dwFlags placement flags
|
---|
390 | * Variables :
|
---|
391 | * Result :
|
---|
392 | * Remark :
|
---|
393 | * Status : Partly working
|
---|
394 | *
|
---|
395 | * Author : Borrowed Rewind Code
|
---|
396 | *****************************************************************************/
|
---|
397 | DWORD CFT2Module::Ft2GetCharacterPlacementW(HDC hdc,
|
---|
398 | LPCWSTR lpString,
|
---|
399 | int uCount,
|
---|
400 | int nMaxExtent,
|
---|
401 | GCP_RESULTSW *lpResults,
|
---|
402 | DWORD dwFlags)
|
---|
403 | {
|
---|
404 | DWORD ret;
|
---|
405 | USHORT sel;
|
---|
406 | SIZE size;
|
---|
407 | UINT i, nSet;
|
---|
408 | pDCData pHps;
|
---|
409 |
|
---|
410 | pHps = (pDCData)OSLibGpiQueryDCData(hdc);
|
---|
411 | if(pHps == NULL) {
|
---|
412 | DebugInt3();
|
---|
413 | SetLastError(ERROR_INVALID_HANDLE_W);
|
---|
414 | return 0;
|
---|
415 | }
|
---|
416 |
|
---|
417 | dprintf(("%ls, %d, %d, 0x%08lx\n", lpString, uCount, nMaxExtent, dwFlags));
|
---|
418 |
|
---|
419 | dprintf(("lStructSize=%ld, lpOutString=%p, lpOrder=%p, lpDx=%p, lpCaretPos=%p, lpClass=%p, lpGlyphs=%p, nGlyphs=%u, nMaxFit=%d\n",
|
---|
420 | lpResults->lStructSize, lpResults->lpOutString, lpResults->lpOrder,
|
---|
421 | lpResults->lpDx, lpResults->lpCaretPos, lpResults->lpClass,
|
---|
422 | lpResults->lpGlyphs, lpResults->nGlyphs, lpResults->nMaxFit));
|
---|
423 |
|
---|
424 | if(dwFlags&(~0)) dprintf(("unsupported flags 0x%08lx\n", dwFlags));
|
---|
425 | if(lpResults->lpCaretPos) dprintf(("caret positions not implemented\n"));
|
---|
426 | if(lpResults->lpClass) dprintf(("classes not implemented\n"));
|
---|
427 |
|
---|
428 | nSet = (UINT)uCount;
|
---|
429 | if(nSet > lpResults->nGlyphs)
|
---|
430 | nSet = lpResults->nGlyphs;
|
---|
431 |
|
---|
432 | /* return number of initialized fields */
|
---|
433 | lpResults->nGlyphs = nSet;
|
---|
434 | lpResults->nMaxFit = nSet;
|
---|
435 |
|
---|
436 | /* Treat the case where no special handling was requested in a fastpath way */
|
---|
437 | /* copy will do if the GCP_REORDER flag is not set */
|
---|
438 | if(lpResults->lpOutString)
|
---|
439 | strncpyW( lpResults->lpOutString, lpString, nSet );
|
---|
440 |
|
---|
441 | if(lpResults->lpOrder)
|
---|
442 | for(i = 0; i < nSet; i++)
|
---|
443 | lpResults->lpOrder[i] = i;
|
---|
444 |
|
---|
445 | //fallback method
|
---|
446 |
|
---|
447 | /* FIXME: Will use the placement chars */
|
---|
448 | if (lpResults->lpDx)
|
---|
449 | {
|
---|
450 | Ft2GetStringWidthW(hdc, (LPWSTR)lpString, nSet, lpResults->lpDx);
|
---|
451 | }
|
---|
452 |
|
---|
453 | if(lpResults->lpGlyphs)
|
---|
454 | GetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);
|
---|
455 |
|
---|
456 | if (GetTextExtentPoint32W(hdc, lpString, uCount, &size))
|
---|
457 | ret = MAKELONG(size.cx, size.cy);
|
---|
458 | else ret = 0;
|
---|
459 |
|
---|
460 | return ret;
|
---|
461 | }
|
---|
462 | //******************************************************************************
|
---|
463 | //******************************************************************************
|
---|