source: trunk/src/gdi32/ft2supp.cpp@ 21997

Last change on this file since 21997 was 21997, checked in by dmik, 13 years ago

gdi32: Fix lost text in TextOut when used with non-identity trasformation matrix.

This was a regression of r21628 wchich I completely reverted. See #81 for details.

File size: 21.7 KB
Line 
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
35CFT2Module FT2Module;
36
37static BOOL fFT2LIBIntegration = FALSE;
38
39//******************************************************************************
40//******************************************************************************
41void WIN32API SetFreeTypeIntegration(BOOL fEnabled)
42{
43 fFT2LIBIntegration = fEnabled;
44
45 FT2Module.init();
46}
47//******************************************************************************
48// Constructor
49//******************************************************************************
50CFT2Module::CFT2Module(const 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//******************************************************************************
61void 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 pfnGetGlyphIndices = (PFN_FT2GETGLYPHINDICES)QueryProcAddress("Ft2GetGlyphIndices");
99 if(!pfnGetGlyphIndices) dprintf(("Ft2GetGlyphIndices not found!!"));
100
101 pfnFt2GetTextExtentW = (PFN_FT2GETTEXTEXTENTW)QueryProcAddress("Ft2GetTextExtentW");
102 if(!pfnFt2GetTextExtentW) dprintf(("Ft2GetTextExtentW not found!!"));
103
104 pfnFt2CharStringPosAtA = (PFN_FT2CHARSTRINGPOSATA)QueryProcAddress("Ft2CharStringPosAtA");
105 if(!pfnFt2CharStringPosAtA) dprintf(("Ft2CharStringPosAtA not found!!"));
106 pfnFt2CharStringPosAtW = (PFN_FT2CHARSTRINGPOSATW)QueryProcAddress("Ft2CharStringPosAtW");
107 if(!pfnFt2CharStringPosAtW) dprintf(("Ft2CharStringPosAtW not found!!"));
108
109 pfnFt2GetGlyphOutline = (PFN_FT2GETGLYPHOUTLINE)QueryProcAddress("Ft2GetGlyphOutline");
110 if(!pfnFt2GetGlyphOutline) dprintf(("Ft2GetGlyphOutline not found!!"));
111
112 pfnFt2GetFontData = (PFN_FT2GETFONTDATA)QueryProcAddress("Ft2GetFontData");
113 if(!pfnFt2GetFontData) dprintf(("Ft2GetFontData not found!!"));
114
115 pfnFt2QueryFontType = (PFN_FT2QUERYFONTTYPE)QueryProcAddress("Ft2QueryFontType");
116 if(!pfnFt2QueryFontType) dprintf(("Ft2QueryFontType not found!!"));
117
118 pfnFt2QueryStringWidthW = (PFN_FT2QUERYSTRINGWIDTHW)QueryProcAddress("Ft2QueryStringWidthW");
119 if(!pfnFt2QueryStringWidthW) dprintf(("Ft2QueryStringWidthW not found!!"));
120
121 pfnFt2GetCharacterPlacementW = (PFN_FT2GETCHARACTERPLACEMENTW)QueryProcAddress("Ft2GetCharacterPlacementW");
122 if(!pfnFt2GetCharacterPlacementW) dprintf(("pfnFt2GetCharacterPlacementW not found!!"));
123
124 // Do not register functions for Mozilla plugins
125 if(IsDummyExeLoaded() == FALSE)
126 {
127 pfnFt2RegisterUconv = (PFN_FT2REGISTERUCONV)QueryProcAddress("Ft2RegisterUconv");
128 if(pfnFt2RegisterUconv)
129 pfnFt2RegisterUconv(WideCharToMultiByte, MultiByteToWideChar);
130 else dprintf(("Ft2QueryFontType not found!!"));
131 }
132 dprintf(("Freetype2 library enabled state %d",bEnabled));
133 }
134 return;
135
136failure:
137 if(pfnFt2RegisterUconv)
138 pfnFt2RegisterUconv(NULL, NULL);
139 if(pfnFt2EnableFontEngine)
140 pfnFt2EnableFontEngine(FALSE);
141
142 pfnGetGlyphIndices = NULL;
143 pfnFt2GetTextExtentW = NULL;
144 pfnFt2EnableFontEngine = NULL;
145 pfnFt2GetGlyphOutline = NULL;
146 pfnFt2CharStringPosAtA = NULL;
147 pfnFt2CharStringPosAtW = NULL;
148 pfnFt2GetFontData = NULL;
149 pfnFt2RegisterUconv = NULL;
150 pfnFt2QueryStringWidthW= NULL;
151 pfnFt2GetVersion = NULL;
152 bEnabled = FALSE;
153 if (hftModule) {
154 DosFreeModule(hftModule);
155 hftModule = 0;
156 }
157 return;
158}
159//******************************************************************************
160// Destructor
161//******************************************************************************
162CFT2Module::~CFT2Module()
163{
164 if (hftModule)
165 DosFreeModule(hftModule);
166
167 bEnabled = FALSE;
168}
169//******************************************************************************
170//******************************************************************************
171PFN CFT2Module::QueryProcAddress(int ordinal)
172{
173 APIRET rc;
174 PFN ModuleAddr;
175
176 rc = DosQueryProcAddr(hftModule, ordinal, NULL, &ModuleAddr);
177 if (rc != 0) {
178 dprintf(("FreeType2 QueryProcAddr error: return code = %u\n", rc));
179 return 0;
180 }
181 return ModuleAddr;
182}
183//******************************************************************************
184//******************************************************************************
185PFN CFT2Module::QueryProcAddress(const char * procname)
186{
187 APIRET rc;
188 PFN ModuleAddr;
189
190 rc = DosQueryProcAddr(hftModule, 0, procname, &ModuleAddr);
191 if (rc != 0) {
192 dprintf(("FreeType2 QueryProcAddr error: return code = %u\n", rc));
193 return 0;
194 }
195 return ModuleAddr;
196}
197//******************************************************************************
198//******************************************************************************
199DWORD CFT2Module::Ft2GetGlyphIndices(HPS hps, LPCWSTR str, int c, LPWORD pgi, DWORD fl)
200{
201 DWORD ret;
202 USHORT sel;
203
204 // All FreeType calls should be wrapped for saving FS
205 if(pfnGetGlyphIndices) {
206 sel = RestoreOS2FS();
207 ret = pfnGetGlyphIndices(hps, (WCHAR*)str, c, (ULONG*)pgi, fl);
208 SetFS(sel);
209 return ret;
210 }
211 //no fallback
212 SetLastError(ERROR_CALL_NOT_IMPLEMENTED_W);
213 return GDI_ERROR;
214}
215//******************************************************************************
216//******************************************************************************
217DWORD CFT2Module::Ft2GetGlyphOutline(HPS hps, UINT glyph, UINT format, LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf, const MAT2* lpmat)
218{
219 DWORD ret;
220 USHORT sel;
221
222 // All FreeType calls should be wrapped for saving FS
223 if (pfnFt2GetGlyphOutline)
224 {
225 sel = RestoreOS2FS();
226 ret = pfnFt2GetGlyphOutline (hps, glyph, format, lpgm, buflen, buf, lpmat);
227 SetFS(sel);
228 return ret;
229 }
230
231 //no fallback
232 SetLastError(ERROR_INVALID_FUNCTION_W);
233 return GDI_ERROR;
234}
235//******************************************************************************
236//
237// This is basically the same as Ft2QueryTextBoxW, but it behaves as the Win32
238// API GetTextExtent (which ignores character attributes and underhang/overhang)
239//
240// The fallback case is not accurate!! (but the same as our old code)
241//
242//******************************************************************************
243BOOL CFT2Module::Ft2GetTextExtentW(HPS hps, LONG lCount1,LPCWSTR pchString, PPOINTLOS2 pwidthHeight)
244{
245 DWORD ret;
246 USHORT sel;
247 POINTLOS2 aptlPoints[TXTBOX_COUNT];
248
249 // All FreeType calls should be wrapped for saving FS
250 if(pfnFt2GetTextExtentW)
251 {
252 sel = RestoreOS2FS();
253 ret = pfnFt2GetTextExtentW(hps, lCount1, pchString, TXTBOX_COUNT, aptlPoints);
254 SetFS(sel);
255 if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
256 {
257 calcDimensions(aptlPoints, pwidthHeight);
258 return ret;
259 }
260 }
261 //else fall back to GPI
262 INT lenA;
263 LPSTR strA;
264 POINTLOS2 start = { 0, 0 };
265 PPOINTLOS2 pplos2;
266 INT cx;
267 INT cy;
268
269 pDCData pHps = (pDCData)OSLibGpiQueryDCData(hps);
270
271 lenA = WideCharToMultiByte( CP_ACP, 0, pchString, lCount1, 0, 0, 0, 0 );
272 strA = ( LPSTR )malloc( lenA + 1 );
273 lstrcpynWtoA( strA, pchString, lenA + 1 );
274 pplos2 = ( PPOINTLOS2 )malloc(( lenA + 1 ) * sizeof( POINTLOS2 ));
275
276 ret = OSLibGpiQueryCharStringPosAt( pHps, &start, 0, lenA, strA, NULL, pplos2 );
277 if( ret )
278 {
279 TEXTMETRICW tmW;
280
281 cx = labs( pplos2[ lenA ].x - pplos2[ 0 ].x );
282 cy = labs( pplos2[ lenA ].y - pplos2[ 0 ].y );
283
284 aptlPoints[ TXTBOX_BOTTOMLEFT ].x = 0;
285 aptlPoints[ TXTBOX_BOTTOMLEFT ].y = 0;
286 aptlPoints[ TXTBOX_BOTTOMRIGHT ].x = cx;
287 aptlPoints[ TXTBOX_BOTTOMRIGHT ].y = cy;
288 aptlPoints[ TXTBOX_TOPLEFT ].x = 0;
289 aptlPoints[ TXTBOX_TOPLEFT ].y = 0;
290 aptlPoints[ TXTBOX_TOPRIGHT ].x = cx;
291 aptlPoints[ TXTBOX_TOPRIGHT ].y = cy;
292 aptlPoints[ TXTBOX_CONCAT ].x = cx;
293 aptlPoints[ TXTBOX_CONCAT ].y = cy;
294
295 calcDimensions(aptlPoints, pwidthHeight);
296
297 DecreaseLogCount();
298 if(GetTextMetricsW( hps, &tmW ) == TRUE)
299 {
300 pwidthHeight->y = tmW.tmHeight; // *Must* use the maximum height of the font
301 }
302#ifdef DEBUG
303 else DebugInt3();
304#endif
305 IncreaseLogCount();
306 }
307
308 free( pplos2 );
309 free( strA );
310
311 return ret;
312}
313//******************************************************************************
314//******************************************************************************
315BOOL CFT2Module::Ft2CharStringPosAtA(HPS hps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx, DWORD fuWin32Options)
316{
317 DWORD ret;
318 USHORT sel;
319
320 // All FreeType calls should be wrapped for saving FS
321 if(pfnFt2CharStringPosAtA) {
322 sel = RestoreOS2FS();
323 ret = pfnFt2CharStringPosAtA(hps, ptl,rct,flOptions,lCount,pchString,alAdx, fuWin32Options);
324 SetFS(sel);
325 if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
326 return ret;
327 }
328 //else fall back to GPI
329 //NOTE: We don't support fuWin32Options in the fallback case
330 pDCData pHps = (pDCData)OSLibGpiQueryDCData(hps);
331 return OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,lCount,pchString,alAdx);
332}
333//******************************************************************************
334//******************************************************************************
335BOOL CFT2Module::Ft2CharStringPosAtW(HPS hps, PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCWSTR pchString,CONST INT *alAdx, DWORD fuWin32Options)
336{
337 DWORD ret;
338 USHORT sel;
339
340 // All FreeType calls should be wrapped for saving FS
341 if(pfnFt2CharStringPosAtW) {
342 sel = RestoreOS2FS();
343 ret = pfnFt2CharStringPosAtW(hps, ptl,rct,flOptions,lCount,pchString,alAdx, fuWin32Options);
344 SetFS(sel);
345 if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
346 return ret;
347 }
348 //else fall back to GPI
349 //NOTE: We don't support fuWin32Options in the fallback case
350 int len;
351 LPSTR astring;
352 LPINT lpDx = NULL;
353
354 pDCData pHps = (pDCData)OSLibGpiQueryDCData(hps);
355
356 len = WideCharToMultiByte( CP_ACP, 0, pchString, lCount, 0, 0, NULL, NULL );
357 astring = (char *)malloc( len + 1 );
358 lstrcpynWtoA(astring, pchString, len + 1 );
359
360 if( IsDBCSEnv() && alAdx )
361 {
362 int i, j;
363
364 lpDx = ( LPINT )malloc( len * sizeof( INT ));
365 for( i = j = 0; i < len; i++, j++ )
366 {
367 lpDx[ i ] = alAdx[ j ];
368 if( IsDBCSLeadByte( astring[ i ]))
369 lpDx[ ++i ] = 0;
370 }
371
372 alAdx = ( CONST INT * )lpDx;
373 }
374
375 ret = OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,len,astring,alAdx);
376
377 if( lpDx )
378 free( lpDx );
379
380 free(astring);
381
382 return ret;
383}
384//******************************************************************************
385//******************************************************************************
386DWORD CFT2Module::Ft2GetFontData(HPS hps, DWORD dwTable, DWORD dwOffset,
387 LPVOID lpvBuffer, DWORD cbData)
388{
389 DWORD ret;
390 USHORT sel;
391
392 // All FreeType calls should be wrapped for saving FS
393 if(pfnFt2GetFontData) {
394 sel = RestoreOS2FS();
395 ret = pfnFt2GetFontData(hps, dwTable, dwOffset, lpvBuffer, cbData);
396 SetFS(sel);
397 if(ret || (ret == GDI_ERROR && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
398 return ret;
399 }
400 //no fallback
401 SetLastError(ERROR_CALL_NOT_IMPLEMENTED_W);
402 return(GDI_ERROR);
403}
404//******************************************************************************
405// Query the font type current selected into the presentation space, or,
406// when hps == NULL, query the type of the font with the specified name
407//******************************************************************************
408DWORD CFT2Module::Ft2QueryFontType(HPS hps, LPCSTR lpszFontName)
409{
410 DWORD ret;
411 USHORT sel;
412
413 // All FreeType calls should be wrapped for saving FS
414 if(pfnFt2QueryFontType) {
415 sel = RestoreOS2FS();
416 ret = pfnFt2QueryFontType(hps, lpszFontName);
417 SetFS(sel);
418 if(ret || (ret == GDI_ERROR && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
419 return ret;
420 }
421 //no fallback
422 return FT2_FONTTYPE_UNKNOWN;
423}
424//******************************************************************************
425//******************************************************************************
426BOOL CFT2Module::Ft2GetStringWidthW(HDC hdc, LPWSTR lpszString, UINT cbString, PINT pWidthArray)
427{
428 DWORD ret;
429 USHORT sel;
430 pDCData pHps;
431
432 pHps = (pDCData)OSLibGpiQueryDCData(hdc);
433 if(pHps == NULL) {
434 DebugInt3();
435 SetLastError(ERROR_INVALID_HANDLE_W);
436 return 0;
437 }
438
439 // All FreeType calls should be wrapped for saving FS
440 if(pfnFt2QueryStringWidthW) {
441 sel = RestoreOS2FS();
442 ret = pfnFt2QueryStringWidthW((HPS)hdc, lpszString, cbString, (LONG *)pWidthArray);
443 SetFS(sel);
444 if(ret || (ret == GDI_ERROR && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
445 {
446 if(pHps && pHps->isPrinter && pHps->hdc)
447 {//scale for printer dcs
448 LONG alArray[2];
449
450 if(OSLibDevQueryCaps(pHps, OSLIB_CAPS_HORIZONTAL_RESOLUTION, 2, &alArray[0]) &&
451 alArray[0] != alArray[1])
452 {
453 dprintf(("Different hor/vert resolutions (%d,%d)", alArray[0], alArray[1]));
454 for (int i = 0; i < cbString; i++)
455 {
456 pWidthArray[i] = pWidthArray[i] * alArray[0] / alArray[1];
457 }
458 }
459 }
460 return ret;
461 }
462 }
463 //fallback method
464 int c, i;
465 for (i = 0; i < cbString; i++)
466 {
467 if (GetCharWidth32W(hdc, lpszString[i], lpszString[i], (LPINT)&c)) {
468 dprintf(("%c pWidthArray[%d] = %d", lpszString[i], i, c));
469 pWidthArray[i]= c;
470 }
471 else {
472 dprintf(("WARNING: GetCharWidth32W failed for %c!!!", lpszString[i]));
473 pWidthArray[i] = 0;
474 }
475 }
476 return TRUE;
477}
478/*****************************************************************************
479 * Name : DWORD GetCharacterPlacementW
480 * Purpose : The GetCharacterPlacementW function retrieves information about
481 * a character string, such as character widths, caret positioning,
482 * ordering within the string, and glyph rendering. The type of
483 * information returned depends on the dwFlags parameter and is
484 * based on the currently selected font in the given display context.
485 * The function copies the information to the specified GCP_RESULTSW
486 * structure or to one or more arrays specified by the structure.
487 * Parameters: HDC hdc handle to device context
488 * LPCSTR lpString pointer to string
489 * int nCount number of characters in string
490 * int nMaxExtent maximum extent for displayed string
491 * GCP_RESULTSW *lpResults pointer to buffer for placement result
492 * DWORD dwFlags placement flags
493 * Variables :
494 * Result :
495 * Remark :
496 * Status : Partly working
497 *
498 * Author : Borrowed Rewind Code
499 *****************************************************************************/
500DWORD CFT2Module::Ft2GetCharacterPlacementW(HDC hdc,
501 LPCWSTR lpString,
502 int uCount,
503 int nMaxExtent,
504 GCP_RESULTSW *lpResults,
505 DWORD dwFlags)
506{
507 DWORD ret;
508 USHORT sel;
509 SIZE size;
510 UINT i, nSet;
511 pDCData pHps;
512
513 pHps = (pDCData)OSLibGpiQueryDCData(hdc);
514 if(pHps == NULL) {
515 DebugInt3();
516 SetLastError(ERROR_INVALID_HANDLE_W);
517 return 0;
518 }
519
520 dprintf(("%ls, %d, %d, 0x%08lx\n", lpString, uCount, nMaxExtent, dwFlags));
521
522 dprintf(("lStructSize=%ld, lpOutString=%p, lpOrder=%p, lpDx=%p, lpCaretPos=%p, lpClass=%p, lpGlyphs=%p, nGlyphs=%u, nMaxFit=%d\n",
523 lpResults->lStructSize, lpResults->lpOutString, lpResults->lpOrder,
524 lpResults->lpDx, lpResults->lpCaretPos, lpResults->lpClass,
525 lpResults->lpGlyphs, lpResults->nGlyphs, lpResults->nMaxFit));
526
527 if(dwFlags&(~0)) dprintf(("unsupported flags 0x%08lx\n", dwFlags));
528 if(lpResults->lpCaretPos) dprintf(("caret positions not implemented\n"));
529 if(lpResults->lpClass) dprintf(("classes not implemented\n"));
530
531 nSet = (UINT)uCount;
532 if(nSet > lpResults->nGlyphs)
533 nSet = lpResults->nGlyphs;
534
535 /* return number of initialized fields */
536 lpResults->nGlyphs = nSet;
537 lpResults->nMaxFit = nSet;
538
539 /* Treat the case where no special handling was requested in a fastpath way */
540 /* copy will do if the GCP_REORDER flag is not set */
541 if(lpResults->lpOutString)
542 strncpyW( lpResults->lpOutString, lpString, nSet );
543
544 if(lpResults->lpOrder)
545 for(i = 0; i < nSet; i++)
546 lpResults->lpOrder[i] = i;
547
548 // All FreeType calls should be wrapped for saving FS
549 if(pfnFt2GetCharacterPlacementW) {
550 sel = RestoreOS2FS();
551 ret = pfnFt2GetCharacterPlacementW((HPS)hdc, lpString, nSet, nMaxExtent, lpResults, dwFlags);
552 SetFS(sel);
553 if(ret || (ret == 0 && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
554 {
555#ifdef DEBUG
556 if(ret && lpResults->lpDx) {
557 for (i = 0; i < nSet; i++)
558 {
559 dprintf(("%c pWidthArray[%d] = %d", lpString[i], i, lpResults->lpDx[i]));
560 }
561 }
562#endif
563 if(pHps && pHps->isPrinter && pHps->hdc)
564 {//scale for printer dcs
565 LONG alArray[2];
566
567 if(OSLibDevQueryCaps(pHps, OSLIB_CAPS_HORIZONTAL_RESOLUTION, 2, &alArray[0]) &&
568 alArray[0] != alArray[1])
569 {
570 dprintf(("Different hor/vert resolutions (%d,%d)", alArray[0], alArray[1]));
571 if(lpResults->lpDx) {
572 for (i = 0; i < nSet; i++)
573 {
574 lpResults->lpDx[i] = lpResults->lpDx[i] * alArray[0] / alArray[1];
575 }
576 }
577 ULONG x = (ret & 0xffff);
578 x = x * alArray[0] / alArray[1];
579 ret &= ~0xffff;
580 ret |= (x & 0xffff);
581 }
582 }
583 return ret;
584 }
585 }
586 //fallback method
587
588 /* FIXME: Will use the placement chars */
589 if (lpResults->lpDx)
590 {
591 Ft2GetStringWidthW(hdc, (LPWSTR)lpString, nSet, lpResults->lpDx);
592 }
593
594 if(lpResults->lpGlyphs)
595 GetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);
596
597 if (GetTextExtentPoint32W(hdc, lpString, uCount, &size))
598 ret = MAKELONG(size.cx, size.cy);
599 else ret = 0;
600
601 return ret;
602}
603//******************************************************************************
604//******************************************************************************
Note: See TracBrowser for help on using the repository browser.