- Timestamp:
- Apr 21, 2011, 10:41:04 PM (14 years ago)
- Location:
- trunk/src/gdi32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/ft2supp.cpp
r21304 r21628 199 199 DWORD CFT2Module::Ft2GetGlyphIndices(HPS hps, LPCWSTR str, int c, LPWORD pgi, DWORD fl) 200 200 { 201 DWORD ret; 201 DWORD ret; 202 202 USHORT sel; 203 203 204 // All FreeType calls should be wrapped for saving FS 204 // All FreeType calls should be wrapped for saving FS 205 205 if(pfnGetGlyphIndices) { 206 206 sel = RestoreOS2FS(); 207 207 ret = pfnGetGlyphIndices(hps, (WCHAR*)str, c, (ULONG*)pgi, fl); 208 208 SetFS(sel); 209 return ret; 209 return ret; 210 210 } 211 211 //no fallback … … 217 217 DWORD CFT2Module::Ft2GetGlyphOutline(HPS hps, UINT glyph, UINT format, LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf, const MAT2* lpmat) 218 218 { 219 DWORD ret; 219 DWORD ret; 220 220 USHORT sel; 221 221 222 // All FreeType calls should be wrapped for saving FS 222 // All FreeType calls should be wrapped for saving FS 223 223 if (pfnFt2GetGlyphOutline) 224 224 { … … 226 226 ret = pfnFt2GetGlyphOutline (hps, glyph, format, lpgm, buflen, buf, lpmat); 227 227 SetFS(sel); 228 return ret; 229 } 230 228 return ret; 229 } 230 231 231 //no fallback 232 232 SetLastError(ERROR_INVALID_FUNCTION_W); … … 313 313 //****************************************************************************** 314 314 //****************************************************************************** 315 struct CTISTATE 316 { 317 pDCData pHps; 318 BOOL restoreInversion; 319 BOOL restoreMatrix; 320 LONG oldYInversion; 321 MATRIXLF mlf; 322 }; 323 324 static void CompensateTextInversion(pDCData pHps, PPOINTLOS2 ptl, PRECTLOS2 rct, 325 CTISTATE *state) 326 { 327 state->pHps = pHps; 328 state->restoreInversion = FALSE; 329 state->restoreMatrix = FALSE; 330 331 // The target HPS is most likely set up for Y inversion, to bring the origin 332 // from the bottom-left corner (PM) to the top-left (Win). However, PM text 333 // drawing routines make an exception for themselves and produce correct 334 // top-left oriented glyphs despite the bottom-left oriented coordinate 335 // space. Having the mentioned Y inversion makes them flip and display 336 // glyphs top to bottom. We need to cancel this flip to get the correct 337 // text orientation. 338 339 GpiQueryDefaultViewMatrix(pHps->hps, 9, &state->mlf); 340 341 if (state->mlf.fxM11 == MAKEFIXED(1, 0) && state->mlf.fxM12 == 0 && 342 state->mlf.lM13 == 0 && 343 state->mlf.fxM21 == 0 && state->mlf.fxM22 == MAKEFIXED(1, 0) && 344 state->mlf.lM23 == 0 && 345 state->mlf.lM31 == 0 && state->mlf.lM32 == 0 && state->mlf.lM33 == 1) 346 { 347 // the most common case: the identity matrix, the inversion is done... 348 #ifdef INVERT 349 // ...through the special GPI call, cancel it and correct ptl/rct 350 state->oldYInversion = GpiQueryYInversion(pHps->hps); 351 if (state->oldYInversion != 0) 352 { 353 ptl->y = state->oldYInversion - ptl->y; 354 if (rct) 355 { 356 LONG temp = state->oldYInversion - rct->yBottom; 357 rct->yBottom = state->oldYInversion - rct->yTop; 358 rct->yTop = temp; 359 } 360 361 GpiEnableYInversion(pHps->hps, 0); 362 363 state->restoreInversion = TRUE; 364 } 365 #else 366 // through the raw yInvert value 367 if (pHps->yInvert > 0) 368 { 369 LONG temp = pHps->yInvert - rct->yBottom; 370 rct->yBottom = pHps->yInvert - rct->yTop; 371 rct->yTop = temp; 372 } 373 #endif 374 } 375 else 376 { 377 // the complex case: append a matrix transformation that will flip the 378 // text along the ptl's Y coordinate 379 MATRIXLF mlf; 380 mlf.fxM11 = MAKEFIXED(1, 0); 381 mlf.fxM12 = 0; 382 mlf.lM13 = 0; 383 mlf.fxM21 = 0; 384 mlf.fxM22 = MAKEFIXED(-1, 0); 385 mlf.lM23 = 0; 386 mlf.lM31 = 0; 387 mlf.lM32 = ptl->y * 2; 388 GpiSetDefaultViewMatrix(pHps->hps, 8, &mlf, TRANSFORM_ADD); 389 390 state->restoreMatrix = TRUE; 391 } 392 } 393 394 static void UncompensateTextInversion(CTISTATE *state) 395 { 396 if (state->restoreInversion) 397 GpiEnableYInversion(state->pHps->hps, state->oldYInversion); 398 if (state->restoreMatrix) 399 GpiSetDefaultViewMatrix(state->pHps->hps, 9, &state->mlf, 400 TRANSFORM_REPLACE); 401 } 402 //****************************************************************************** 403 //****************************************************************************** 315 404 BOOL CFT2Module::Ft2CharStringPosAtA(HPS hps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx, DWORD fuWin32Options) 316 405 { 317 406 DWORD ret; 318 407 USHORT sel; 319 320 // All FreeType calls should be wrapped for saving FS 321 if(pfnFt2CharStringPosAtA) { 408 pDCData pHps; 409 410 pHps = (pDCData)OSLibGpiQueryDCData(hps); 411 412 CTISTATE ctiState; 413 CompensateTextInversion(pHps, ptl, rct, &ctiState); 414 415 BOOL fallback = TRUE; 416 417 if(pfnFt2CharStringPosAtA) 418 { 419 // All FreeType calls should be wrapped for saving FS 322 420 sel = RestoreOS2FS(); 323 421 ret = pfnFt2CharStringPosAtA(hps, ptl,rct,flOptions,lCount,pchString,alAdx, fuWin32Options); 324 422 SetFS(sel); 325 423 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); 424 fallback = FALSE; 425 } 426 427 if (fallback) 428 { 429 //else fall back to GPI 430 //NOTE: We don't support fuWin32Options in the fallback case 431 ret = OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,lCount,pchString,alAdx); 432 } 433 434 UncompensateTextInversion(&ctiState); 435 436 return ret; 332 437 } 333 438 //****************************************************************************** … … 337 442 DWORD ret; 338 443 USHORT sel; 339 340 // All FreeType calls should be wrapped for saving FS 341 if(pfnFt2CharStringPosAtW) { 444 pDCData pHps; 445 446 pHps = (pDCData)OSLibGpiQueryDCData(hps); 447 448 CTISTATE ctiState; 449 CompensateTextInversion(pHps, ptl, rct, &ctiState); 450 451 BOOL fallback = TRUE; 452 453 if (pfnFt2CharStringPosAtW) 454 { 455 // All FreeType calls should be wrapped for saving FS 342 456 sel = RestoreOS2FS(); 343 457 ret = pfnFt2CharStringPosAtW(hps, ptl,rct,flOptions,lCount,pchString,alAdx, fuWin32Options); 344 458 SetFS(sel); 345 459 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++ ) 460 fallback = FALSE; 461 } 462 463 if (fallback) 464 { 465 // fall back to GPI 466 // NOTE: We don't support fuWin32Options in the fallback case 467 int len; 468 LPSTR astring; 469 470 LPINT lpDx = NULL; 471 472 len = WideCharToMultiByte( CP_ACP, 0, pchString, lCount, 0, 0, NULL, NULL ); 473 astring = (char *)malloc( len + 1 ); 474 lstrcpynWtoA(astring, pchString, len + 1 ); 475 476 if( IsDBCSEnv() && alAdx ) 366 477 { 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); 478 int i, j; 479 480 lpDx = ( LPINT )malloc( len * sizeof( INT )); 481 for( i = j = 0; i < len; i++, j++ ) 482 { 483 lpDx[ i ] = alAdx[ j ]; 484 if( IsDBCSLeadByte( astring[ i ])) 485 lpDx[ ++i ] = 0; 486 } 487 488 alAdx = ( CONST INT * )lpDx; 489 } 490 491 ret = OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,len,astring,alAdx); 492 493 if( lpDx ) 494 free( lpDx ); 495 496 free(astring); 497 } 498 499 UncompensateTextInversion(&ctiState); 381 500 382 501 return ret; … … 387 506 LPVOID lpvBuffer, DWORD cbData) 388 507 { 389 DWORD ret; 508 DWORD ret; 390 509 USHORT sel; 391 510 392 // All FreeType calls should be wrapped for saving FS 511 // All FreeType calls should be wrapped for saving FS 393 512 if(pfnFt2GetFontData) { 394 513 sel = RestoreOS2FS(); … … 396 515 SetFS(sel); 397 516 if(ret || (ret == GDI_ERROR && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED)) 398 return ret; 517 return ret; 399 518 } 400 519 //no fallback … … 546 665 lpResults->lpOrder[i] = i; 547 666 548 // All FreeType calls should be wrapped for saving FS 667 // All FreeType calls should be wrapped for saving FS 549 668 if(pfnFt2GetCharacterPlacementW) { 550 669 sel = RestoreOS2FS(); … … 566 685 567 686 if(OSLibDevQueryCaps(pHps, OSLIB_CAPS_HORIZONTAL_RESOLUTION, 2, &alArray[0]) && 568 alArray[0] != alArray[1]) 687 alArray[0] != alArray[1]) 569 688 { 570 689 dprintf(("Different hor/vert resolutions (%d,%d)", alArray[0], alArray[1])); … … 581 700 } 582 701 } 583 return ret; 702 return ret; 584 703 } 585 704 } -
trunk/src/gdi32/text.cpp
r10600 r21628 95 95 //****************************************************************************** 96 96 // todo: metafile support 97 //#undef INVERT98 //#define INVERT_SETYINVERSION99 97 //****************************************************************************** 100 98 BOOL InternalTextOutAW(HDC hdc,int X,int Y,UINT fuOptions, … … 135 133 } 136 134 137 #if defined(INVERT) && !defined(INVERT_SETYINVERSION)138 if(pHps->yInvert > 0) {139 Y = pHps->yInvert - Y;140 }141 #endif142 143 #ifdef INVERT_SETYINVERSION144 int oldyinv = GpiQueryYInversion(pHps->hps);145 Y = oldyinv - Y;146 #endif147 148 135 // When using font association, the height of DBCS and SBCS chars may be different. 149 136 // In this case, background color make stair below chars … … 181 168 return TRUE; 182 169 } 183 #ifndef INVERT184 #ifdef INVERT_SETYINVERSION185 if (oldyinv) {186 int temp = oldyinv - pmRect.yTop;187 pmRect.yTop = oldyinv - pmRect.yBottom;188 pmRect.yBottom = temp;189 }190 #else191 if (pHps->yInvert > 0) {192 int temp = pHps->yInvert - pmRect.yTop;193 pmRect.yTop = pHps->yInvert - pmRect.yBottom;194 pmRect.yBottom = temp;195 }196 #endif197 #endif198 170 199 171 if (fuOptions & ETO_CLIPPED) flOptions |= CHSOS_CLIP; … … 244 216 } 245 217 } 246 247 #ifdef INVERT_SETYINVERSION248 GpiEnableYInversion(pHps->hps, 0);249 #endif250 218 251 219 if (lpDx) … … 341 309 if(hits == GPIOS_ERROR) { 342 310 dprintf(("InternalTextOutA: OSLibGpiCharStringPosAt returned GPIOS_ERROR")); 343 #ifdef INVERT_SETYINVERSION344 GpiEnableYInversion(pHps->hps, oldyinv);345 #endif346 311 return FALSE; 347 312 } … … 356 321 OSLibGpiSetCurrentPosition(pHps,&ptl); 357 322 } 358 359 #ifdef INVERT_SETYINVERSION360 GpiEnableYInversion(pHps->hps, oldyinv);361 #endif362 323 363 324 DIBSECTION_MARK_INVALID(hdc);
Note:
See TracChangeset
for help on using the changeset viewer.