Changeset 20936
- Timestamp:
- Jan 15, 2004, 12:18:58 PM (21 years ago)
- Location:
- tags/trunk/src/gdi32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tags/trunk/src/gdi32/ft2supp.cpp ¶
r20927 r20936 41 41 void WIN32API SetFreeTypeIntegration(BOOL fEnabled) 42 42 { 43 fFT2LIBIntegration = fEnabled; 43 fFT2LIBIntegration = fEnabled; 44 44 45 45 FT2Module.init(); … … 48 48 // Constructor 49 49 //****************************************************************************** 50 CFT2Module::CFT2Module(char* sModuleName): bEnabled(FALSE), hftModule(0), pfnGetGlyphIndices(NULL), 50 CFT2Module::CFT2Module(char* sModuleName): bEnabled(FALSE), hftModule(0), pfnGetGlyphIndices(NULL), 51 51 pfnFt2GetTextExtentW(NULL), pfnFt2EnableFontEngine(NULL), 52 pfnFt2GetGlyphOutline(NULL), pfnFt2CharStringPosAtA(NULL), 52 pfnFt2GetGlyphOutline(NULL), pfnFt2CharStringPosAtA(NULL), 53 53 pfnFt2CharStringPosAtW(NULL), pfnFt2GetFontData(NULL), 54 54 pfnFt2RegisterUconv(NULL), pfnFt2QueryStringWidthW(NULL), … … 71 71 72 72 rc = DosLoadModule((PSZ)Loaderror, sizeof(Loaderror), pszModuleName, &hftModule); 73 if (rc != 0) 73 if (rc != 0) 74 74 dprintf(("Freetype2 library load error: return code = %u\n", rc)); 75 75 else 76 bEnabled = TRUE; 76 bEnabled = TRUE; 77 77 78 78 if(bEnabled) { … … 111 111 112 112 // Do not register functions for Mozilla plugins 113 if(IsDummyExeLoaded() == FALSE) 113 if(IsDummyExeLoaded() == FALSE) 114 114 { 115 115 pfnFt2RegisterUconv = (PFN_FT2REGISTERUCONV)QueryProcAddress("Ft2RegisterUconv"); 116 if(pfnFt2RegisterUconv) 116 if(pfnFt2RegisterUconv) 117 117 pfnFt2RegisterUconv(WideCharToMultiByte, MultiByteToWideChar); 118 118 else dprintf(("Ft2QueryFontType not found!!")); … … 123 123 124 124 failure: 125 if(pfnFt2RegisterUconv) 125 if(pfnFt2RegisterUconv) 126 126 pfnFt2RegisterUconv(NULL, NULL); 127 127 if(pfnFt2EnableFontEngine) … … 131 131 pfnFt2GetTextExtentW = NULL; 132 132 pfnFt2EnableFontEngine = NULL; 133 pfnFt2GetGlyphOutline = NULL; 134 pfnFt2CharStringPosAtA = NULL; 135 pfnFt2CharStringPosAtW = NULL; 133 pfnFt2GetGlyphOutline = NULL; 134 pfnFt2CharStringPosAtA = NULL; 135 pfnFt2CharStringPosAtW = NULL; 136 136 pfnFt2GetFontData = NULL; 137 pfnFt2RegisterUconv = NULL; 137 pfnFt2RegisterUconv = NULL; 138 138 pfnFt2QueryStringWidthW= NULL; 139 139 pfnFt2GetVersion = NULL; … … 162 162 PFN ModuleAddr; 163 163 164 rc = DosQueryProcAddr(hftModule, ordinal, NULL, &ModuleAddr); 164 rc = DosQueryProcAddr(hftModule, ordinal, NULL, &ModuleAddr); 165 165 if (rc != 0) { 166 166 dprintf(("FreeType2 QueryProcAddr error: return code = %u\n", rc)); … … 176 176 PFN ModuleAddr; 177 177 178 rc = DosQueryProcAddr(hftModule, 0, procname, &ModuleAddr); 178 rc = DosQueryProcAddr(hftModule, 0, procname, &ModuleAddr); 179 179 if (rc != 0) { 180 180 dprintf(("FreeType2 QueryProcAddr error: return code = %u\n", rc)); … … 203 203 // This is basically the same as Ft2QueryTextBoxW, but it behaves as the Win32 204 204 // API GetTextExtent (which ignores character attributes and underhang/overhang) 205 // 205 // 206 206 // The fallback case is not accurate!! (but the same as our old code) 207 207 // … … 242 242 243 243 ret = OSLibGpiQueryCharStringPosAt( pHps, &start, 0, lenA, strA, NULL, pplos2 ); 244 245 cx = labs( pplos2[ lenA ].x - pplos2[ 0 ].x );246 cy = labs( pplos2[ lenA ].y - pplos2[ 0 ].y );247 248 244 if( ret ) 249 245 { 246 TEXTMETRICW tmW; 247 248 cx = labs( pplos2[ lenA ].x - pplos2[ 0 ].x ); 249 cy = labs( pplos2[ lenA ].y - pplos2[ 0 ].y ); 250 250 251 aptlPoints[ TXTBOX_BOTTOMLEFT ].x = 0; 251 252 aptlPoints[ TXTBOX_BOTTOMLEFT ].y = 0; … … 258 259 aptlPoints[ TXTBOX_CONCAT ].x = cx; 259 260 aptlPoints[ TXTBOX_CONCAT ].y = cy; 260 } 261 262 calcDimensions(aptlPoints, pwidthHeight); 263 264 TEXTMETRICW tmW; 265 if(GetTextMetricsW( hps, &tmW ) == TRUE) 266 { 267 pwidthHeight->y = tmW.tmHeight; // *Must* use the maximum height of the font 268 } 261 262 calcDimensions(aptlPoints, pwidthHeight); 263 264 if(GetTextMetricsW( hps, &tmW ) == TRUE) 265 { 266 pwidthHeight->y = tmW.tmHeight; // *Must* use the maximum height of the font 267 } 269 268 #ifdef DEBUG 270 else DebugInt3();269 else DebugInt3(); 271 270 #endif 271 } 272 272 273 273 free( pplos2 ); … … 280 280 BOOL CFT2Module::Ft2CharStringPosAtA(HPS hps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx, DWORD fuWin32Options) 281 281 { 282 DWORD ret; 282 DWORD ret; 283 283 USHORT sel; 284 284 285 // All FreeType calls should be wrapped for saving FS 285 // All FreeType calls should be wrapped for saving FS 286 286 if(pfnFt2CharStringPosAtA) { 287 287 sel = RestoreOS2FS(); … … 289 289 SetFS(sel); 290 290 if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED)) 291 return ret; 291 return ret; 292 292 } 293 293 //else fall back to GPI … … 300 300 BOOL CFT2Module::Ft2CharStringPosAtW(HPS hps, PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCWSTR pchString,CONST INT *alAdx, DWORD fuWin32Options) 301 301 { 302 DWORD ret; 302 DWORD ret; 303 303 USHORT sel; 304 304 305 // All FreeType calls should be wrapped for saving FS 305 // All FreeType calls should be wrapped for saving FS 306 306 if(pfnFt2CharStringPosAtW) { 307 307 sel = RestoreOS2FS(); … … 309 309 SetFS(sel); 310 310 if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED)) 311 return ret; 311 return ret; 312 312 } 313 313 //else fall back to GPI … … 336 336 } 337 337 //****************************************************************************** 338 // Query the font type current selected into the presentation space, or, 338 // Query the font type current selected into the presentation space, or, 339 339 // when hps == NULL, query the type of the font with the specified name 340 340 //****************************************************************************** 341 341 DWORD CFT2Module::Ft2QueryFontType(HPS hps, LPCSTR lpszFontName) 342 342 { 343 DWORD ret; 343 DWORD ret; 344 344 USHORT sel; 345 345 346 // All FreeType calls should be wrapped for saving FS 346 // All FreeType calls should be wrapped for saving FS 347 347 if(pfnFt2QueryFontType) { 348 348 sel = RestoreOS2FS(); … … 350 350 SetFS(sel); 351 351 if(ret || (ret == GDI_ERROR && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED)) 352 return ret; 352 return ret; 353 353 } 354 354 //no fallback … … 359 359 BOOL CFT2Module::Ft2GetStringWidthW(HDC hdc, LPWSTR lpszString, UINT cbString, PINT pWidthArray) 360 360 { 361 DWORD ret; 361 DWORD ret; 362 362 USHORT sel; 363 363 pDCData pHps; … … 370 370 } 371 371 372 // All FreeType calls should be wrapped for saving FS 372 // All FreeType calls should be wrapped for saving FS 373 373 if(pfnFt2QueryStringWidthW) { 374 374 sel = RestoreOS2FS(); … … 382 382 383 383 if(OSLibDevQueryCaps(pHps, OSLIB_CAPS_HORIZONTAL_RESOLUTION, 2, &alArray[0]) && 384 alArray[0] != alArray[1]) 384 alArray[0] != alArray[1]) 385 385 { 386 386 dprintf(("Different hor/vert resolutions (%d,%d)", alArray[0], alArray[1])); … … 391 391 } 392 392 } 393 return ret; 393 return ret; 394 394 } 395 395 } … … 438 438 DWORD dwFlags) 439 439 { 440 DWORD ret; 440 DWORD ret; 441 441 USHORT sel; 442 442 SIZE size; … … 454 454 455 455 dprintf(("lStructSize=%ld, lpOutString=%p, lpOrder=%p, lpDx=%p, lpCaretPos=%p, lpClass=%p, lpGlyphs=%p, nGlyphs=%u, nMaxFit=%d\n", 456 457 458 456 lpResults->lStructSize, lpResults->lpOutString, lpResults->lpOrder, 457 lpResults->lpDx, lpResults->lpCaretPos, lpResults->lpClass, 458 lpResults->lpGlyphs, lpResults->nGlyphs, lpResults->nMaxFit)); 459 459 460 460 if(dwFlags&(~0)) dprintf(("unsupported flags 0x%08lx\n", dwFlags)); 461 if(lpResults->lpCaretPos) 462 if(lpResults->lpClass) 461 if(lpResults->lpCaretPos) dprintf(("caret positions not implemented\n")); 462 if(lpResults->lpClass) dprintf(("classes not implemented\n")); 463 463 464 464 nSet = (UINT)uCount; 465 465 if(nSet > lpResults->nGlyphs) 466 466 nSet = lpResults->nGlyphs; 467 467 468 468 /* return number of initialized fields */ … … 488 488 489 489 if(lpResults->lpGlyphs) 490 490 GetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0); 491 491 492 492 if (GetTextExtentPoint32W(hdc, lpString, uCount, &size)) -
TabularUnified tags/trunk/src/gdi32/text.cpp ¶
r20928 r20936 1 /* $Id: text.cpp,v 1.4 2 2004-01-14 16:53:25sandervl Exp $ */1 /* $Id: text.cpp,v 1.43 2004-01-15 11:18:58 sandervl Exp $ */ 2 2 3 3 /* … … 543 543 return GetTextExtentPointW(hdc, lpsz, cbString, lpSize); 544 544 } 545 546 typedef BOOL ( WIN32API *PFN_GETTEXTEXTENTPOINT32 )( HDC, PVOID, INT, LPSIZE ); 547 548 BOOL InternalGetTextExtentExPointAW(HDC hdc, 549 PVOID str, 550 INT count, 551 INT maxExt, 552 LPINT lpnFit, 553 LPINT alpDx, 554 LPSIZE size, 555 BOOL fUnicode) 556 { 557 int i, nFit; 558 SIZE tSize; 559 BOOL ret = FALSE; 560 561 PFN_GETTEXTEXTENTPOINT32 pfnGetTextExtentPoint32; 562 563 if( fUnicode ) 564 pfnGetTextExtentPoint32 = ( PFN_GETTEXTEXTENTPOINT32 )GetTextExtentPoint32W; 565 else 566 pfnGetTextExtentPoint32 = ( PFN_GETTEXTEXTENTPOINT32 )GetTextExtentPoint32A; 567 568 size->cx = size->cy = nFit = i = 0; 569 570 if( lpnFit || alpDx ) 571 { 572 for( i = 1; i <= count; i++ ) 573 { 574 if( !pfnGetTextExtentPoint32( hdc, str, i, &tSize )) goto done; 575 576 if( lpnFit && ( maxExt < tSize.cx )) 577 break; 578 579 if( alpDx ) 580 alpDx[ nFit ] = tSize.cx; 581 582 nFit++; 583 } 584 } 585 586 if(( count > 0 ) && ( i >= count )) 587 { 588 size->cx = tSize.cx; 589 size->cy = tSize.cy; // The height of a font is constant. 590 } 591 else if( !pfnGetTextExtentPoint32( hdc, str, count, size )) goto done; 592 593 if(lpnFit) *lpnFit = nFit; 594 ret = TRUE; 595 596 dprintf(("returning %d %ld x %ld\n",nFit,size->cx,size->cy)); 597 598 done: 599 return ret; 600 } 601 545 602 //****************************************************************************** 546 603 //****************************************************************************** … … 553 610 LPSIZE size) 554 611 { 555 BOOL ret; 556 INT wlen; 557 LPWSTR p; 558 INT nFit; 559 TEXTMETRICA tmA; 560 CHAR brokenDBCS = 0; 561 562 if( IsDBCSEnv()) 563 { 564 brokenDBCS = getBrokenDBCS( str, count ); 565 566 GetTextMetricsA( hdc, &tmA ); 567 } 568 569 if( brokenDBCS ) 570 count--; 571 572 p = FONT_mbtowc( hdc, str, count, &wlen, NULL); 573 ret = GetTextExtentExPointW( hdc, p, wlen, maxExt, &nFit, alpDx, size); 574 nFit = WideCharToMultiByte(CP_ACP,0,p,nFit,NULL,0,NULL,NULL); 575 if( IsDBCSEnv() && alpDx ) // index of alpDx between ansi and wide may not match in DBCS !!! 576 { 577 LPINT alpDxNew = ( LPINT )HeapAlloc( GetProcessHeap(), 0, sizeof( alpDx[ 0 ] ) * ( nFit + 1 )); 578 INT prevDx; 579 int i, j; 580 581 for( i = j = 0; i < nFit; i++, j++ ) 582 { 583 if( IsDBCSLeadByte( str[ i ])) 584 { 585 prevDx = ( i > 0 ) ? alpDxNew[ i - 1 ] : 0; 586 alpDxNew[ i++ ] = prevDx + tmA.tmAveCharWidth; 587 if( i >= nFit ) 588 break; 589 } 590 alpDxNew[ i ] = alpDx[ j ]; 591 } 592 593 if(( nFit < count ) && IsDBCSLeadByte( str[ nFit ])) 594 { 595 prevDx = ( nFit > 0 ) ? alpDxNew[ nFit - 1 ] : 0; 596 if( maxExt >= prevDx + tmA.tmAveCharWidth ) 597 alpDxNew[ nFit++ ] = prevDx + tmA.tmAveCharWidth; 598 } 599 600 memcpy( alpDx, alpDxNew, sizeof( alpDx[ 0 ] ) * nFit ); 601 602 HeapFree( GetProcessHeap(), 0, alpDxNew ); 603 } 604 605 // for broken DBCS. correct for FIXED WIDTH, not approx. for VARIABLE WIDTH 606 if( brokenDBCS ) 607 { 608 size->cx += tmA.tmAveCharWidth; 609 if( count == 0 ) 610 size->cy = tmA.tmHeight; 611 612 if(( maxExt > size->cx ) && ( nFit <= count )) // decreaed count by 1 above 613 { 614 if( alpDx ) 615 alpDx[ nFit ] = size->cx; 616 617 nFit++; 618 } 619 } 620 621 if (lpnFit) *lpnFit = nFit; 622 623 HeapFree( GetProcessHeap(), 0, p ); 624 return ret; 612 return InternalGetTextExtentExPointAW( hdc, ( PVOID )str, count, maxExt, lpnFit, alpDx, size, FALSE ); 625 613 } 626 614 //****************************************************************************** … … 634 622 LPSIZE size) 635 623 { 636 int i, nFit, extent; 637 SIZE tSize; 638 BOOL ret = FALSE; 639 640 size->cx = size->cy = nFit = extent = 0; 641 642 for( i = 1; i <= count; i++ ) 643 { 644 if( !GetTextExtentPoint32W( hdc, str, i, &tSize )) goto done; 645 646 if( maxExt < tSize.cx ) 647 break; 648 649 if( alpDx ) 650 alpDx[ nFit ] = tSize.cx; 651 652 nFit++; 653 } 654 655 if( i >= count ) 656 size->cx = tSize.cx; 657 else if( !GetTextExtentPoint32W( hdc, str, count, size )) goto done; 658 659 size->cy = tSize.cy; // The height of a font is constant. 660 661 if(lpnFit) *lpnFit = nFit; 662 ret = TRUE; 663 664 dprintf(("returning %d %ld x %ld\n",nFit,size->cx,size->cy)); 665 666 done: 667 return ret; 624 return InternalGetTextExtentExPointAW( hdc, ( PVOID )str, count, maxExt, lpnFit, alpDx, size, TRUE ); 668 625 } 669 626 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.