Changeset 20927
- Timestamp:
- Jan 14, 2004, 12:08:08 PM (21 years ago)
- Location:
- tags/trunk/src/gdi32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tags/trunk/src/gdi32/ft2supp.cpp ¶
r20926 r20927 109 109 pfnFt2QueryStringWidthW = (PFN_FT2QUERYSTRINGWIDTHW)QueryProcAddress("Ft2QueryStringWidthW"); 110 110 if(!pfnFt2QueryStringWidthW) dprintf(("Ft2QueryStringWidthW not found!!")); 111 112 pfnFt2GetCharacterPlacementW = (PFN_FT2GETCHARACTERPLACEMENTW)QueryProcAddress("Ft2GetCharacterPlacementW");113 if(!pfnFt2GetCharacterPlacementW) dprintf(("pfnFt2GetCharacterPlacementW not found!!"));114 111 115 112 // Do not register functions for Mozilla plugins -
TabularUnified tags/trunk/src/gdi32/ft2supp.h ¶
r20910 r20927 94 94 DWORD Ft2GetGlyphOutline(HPS hps, UINT glyph, UINT format, LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf, const MAT2* lpmat); 95 95 96 BOOL Ft2GetTextExtentW(HPS hps, LONG lCount1,LPCWSTR pchString, LONG lCount2,PPOINTLOS2 aptlPoints);96 BOOL Ft2GetTextExtentW(HPS hps, LONG lCount1,LPCWSTR pchString, PPOINTLOS2 pwidthHeight); 97 97 BOOL Ft2CharStringPosAtA(HPS hps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx, ULONG fuWin32Options); 98 98 BOOL Ft2CharStringPosAtW(HPS hps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCWSTR pchString,CONST INT *alAdx, ULONG fuWin32Options); -
TabularUnified tags/trunk/src/gdi32/text.cpp ¶
r20910 r20927 1 /* $Id: text.cpp,v 1.4 0 2004-01-11 11:42:22sandervl Exp $ */1 /* $Id: text.cpp,v 1.41 2004-01-14 11:07:35 sandervl Exp $ */ 2 2 3 3 /* … … 27 27 #include "ft2supp.h" 28 28 #include "font.h" 29 #include <math.h> 29 30 30 31 #define DBG_LOCALLOG DBG_text … … 34 35 #define ELLIPSISLEN 3 35 36 37 //****************************************************************************** 38 //****************************************************************************** 39 CHAR getBrokenDBCS( LPCSTR strA, INT lenA ) 40 { 41 int i; 42 43 for( i = 0; i < lenA; i++ ) 44 if( IsDBCSLeadByte( strA[ i ])) 45 i++; 46 47 if( lenA < i ) // terminated at DBCS lead byte 48 return strA[ lenA ]; 49 50 return 0; 51 } 36 52 //****************************************************************************** 37 53 //****************************************************************************** … … 91 107 POINTLOS2 ptl; 92 108 LONG hits; 109 RECT rect; 93 110 94 111 if (!pHps || (cbCount < 0) || (((lpszStringA == NULL && !fUnicode) || (lpszStringW == NULL && fUnicode)) && (cbCount != 0))) … … 100 117 101 118 if(cbCount == -1) { 102 if(fUnicode) 119 if(fUnicode) 103 120 cbCount = lstrlenW(lpszStringW); 104 121 else cbCount = lstrlenA(lpszStringA); … … 128 145 Y = oldyinv - Y; 129 146 #endif 147 148 // When using font association, the height of DBCS and SBCS chars may be different. 149 // In this case, background color make stair below chars 150 if( IsDBCSEnv() && !lprc && ( GetBkMode( hdc ) & OPAQUE )) 151 { 152 SIZE size; 153 TEXTMETRICA tmA; 154 155 if( fUnicode ) 156 GetTextExtentPointW( hdc, lpszStringW, cbCount, &size ); 157 else 158 GetTextExtentPointA( hdc, lpszStringA, cbCount, &size ); 159 160 GetTextMetricsA( hdc, &tmA ); 161 162 rect.left = X; 163 rect.right = X + size.cx; 164 rect.top = Y; 165 rect.bottom = Y + tmA.tmHeight; 166 167 lprc = ▭ 168 fuOptions |= ETO_OPAQUE; 169 } 130 170 131 171 //CB: add metafile info … … 264 304 #endif 265 305 266 if(fUnicode) 306 if(fUnicode) 267 307 hits = FT2Module.Ft2CharStringPosAtW(pHps->hps,&ptl,&pmRect,flOptions,cbCount,lpszStringW,lpDx, fuOptions & ETO_GLYPH_INDEX); 268 308 else hits = FT2Module.Ft2CharStringPosAtA(pHps->hps,&ptl,&pmRect,flOptions,cbCount,lpszStringA,lpDx, fuOptions & ETO_GLYPH_INDEX); … … 383 423 BOOL ret = FALSE; 384 424 INT wlen; 385 LPWSTR p = FONT_mbtowc(hdc, lpsz, cbString, &wlen, NULL); 425 LPWSTR p; 426 CHAR brokenDBCS = 0; 427 428 if( IsDBCSEnv()) 429 brokenDBCS = getBrokenDBCS( lpsz, cbString ); 430 431 if( brokenDBCS ) 432 cbString--; 433 434 p = FONT_mbtowc(hdc, lpsz, cbString, &wlen, NULL); 386 435 if (p) { 387 436 ret = GetTextExtentPointW( hdc, p, wlen, lpsSize ); 437 // For broken DBCS. Correct for FIXED WIDTH, but approx. for VARIABLE WIDTH 438 if( brokenDBCS ) 439 { 440 TEXTMETRICA tmA; 441 442 GetTextMetricsA( hdc, &tmA ); 443 lpsSize->cx += tmA.tmAveCharWidth; 444 445 if( cbString == 0 ) 446 lpsSize->cy = tmA.tmHeight; 447 } 448 388 449 HeapFree( GetProcessHeap(), 0, p ); 389 450 } … … 399 460 { 400 461 BOOL rc; 401 POINTLOS2 pts[TXTBOXOS_COUNT];402 462 POINTLOS2 widthHeight = { 0, 0}; 403 463 pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc); … … 436 496 437 497 dprintf(("WARNING: string longer than 512 chars; splitting up")); 438 lpSize->cx = 0;439 lpSize->cy = 0;440 498 while(cbString) { 441 499 cbStringNew = min(500, cbString); … … 452 510 } 453 511 454 rc = FT2Module.Ft2GetTextExtentW(pHps->hps, cbString, lpString, TXTBOXOS_COUNT, pts);512 rc = FT2Module.Ft2GetTextExtentW(pHps->hps, cbString, lpString, &widthHeight); 455 513 if(rc == FALSE) 456 514 { … … 458 516 return FALSE; 459 517 } 460 calcDimensions(pts, &widthHeight);461 518 lpSize->cx = widthHeight.x; 462 519 lpSize->cy = widthHeight.y; … … 498 555 BOOL ret; 499 556 INT wlen; 500 LPWSTR p = FONT_mbtowc( hdc, str, count, &wlen, NULL); 501 ret = GetTextExtentExPointW( hdc, p, wlen, maxExt, lpnFit, alpDx, size); 502 if (lpnFit) *lpnFit = WideCharToMultiByte(CP_ACP,0,p,*lpnFit,NULL,0,NULL,NULL); 503 if( IsDBCSEnv() && alpDx ) /* index of alpDx between ansi and wide may not match in DBCS !!! */ 504 { 505 LPINT alpDxNew = ( LPINT )HeapAlloc( GetProcessHeap(), 0, sizeof( alpDx[ 0 ] ) * *lpnFit ); 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; 506 579 int i, j; 507 580 508 for( i = j = 0; i < *lpnFit; i++, j++ )581 for( i = j = 0; i < nFit; i++, j++ ) 509 582 { 510 583 if( IsDBCSLeadByte( str[ i ])) 511 584 { 512 alpDxNew[ i++ ] = alpDx[ j ] >> 1; 513 if( i < *lpnFit ) 514 alpDxNew[ i ] = alpDx[ j ] >> 1; 585 prevDx = ( i > 0 ) ? alpDxNew[ i - 1 ] : 0; 586 alpDxNew[ i++ ] = prevDx + tmA.tmAveCharWidth; 587 if( i >= nFit ) 588 break; 515 589 } 516 else 517 alpDxNew[ i ] = alpDx[ j ]; 518 590 alpDxNew[ i ] = alpDx[ j ]; 519 591 } 520 592 521 memcpy( alpDx, alpDxNew, sizeof( alpDx[ 0 ] ) * *lpnFit ); 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 ); 522 601 523 602 HeapFree( GetProcessHeap(), 0, alpDxNew ); 524 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 525 623 HeapFree( GetProcessHeap(), 0, p ); 526 624 return ret; … … 536 634 LPSIZE size) 537 635 { 538 int i ndex, nFit, extent;636 int i, nFit, extent; 539 637 SIZE tSize; 540 638 BOOL ret = FALSE; 541 639 542 640 size->cx = size->cy = nFit = extent = 0; 543 for(index = 0; index < count; index++) 544 { 545 if(!GetTextExtentPoint32W( hdc, str, 1, &tSize )) goto done; 546 /* GetTextExtentPoint includes intercharacter spacing. */ 547 /* FIXME - justification needs doing yet. Remember that the base 548 * data will not be in logical coordinates. 549 */ 550 extent += tSize.cx; 551 if( !lpnFit || extent <= maxExt ) 552 /* It is allowed to be equal. */ 553 { 554 nFit++; 555 if( alpDx ) alpDx[index] = extent; 556 } 557 if( tSize.cy > size->cy ) size->cy = tSize.cy; 558 str++; 559 } 560 size->cx = extent; 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 561 661 if(lpnFit) *lpnFit = nFit; 562 662 ret = TRUE; … … 572 672 { 573 673 BOOL ret = FALSE; 574 674 575 675 for (int i = iFirstChar; i <= iLastChar; i++) 576 676 { 577 677 SIZE size; 578 678 CHAR c = i; 579 679 580 680 if (GetTextExtentPointA(hdc, &c, 1, &size)) 581 681 { … … 589 689 pWidthArray[i-iFirstChar] = 0; 590 690 } 591 691 592 692 dprintf2(("Char 0x%x('%c') -> width %d", i, i<256? i: '.', pWidthArray[i-iFirstChar])); 593 693 } 594 694 595 695 return ret; 596 696 } … … 600 700 { 601 701 BOOL ret = FALSE; 602 702 603 703 for (int i = iFirstChar; i <= iLastChar; i++) 604 704 { 605 705 SIZE size; 606 706 WCHAR wc = i; 607 707 608 708 if (GetTextExtentPointW(hdc, &wc, 1, &size)) 609 709 { … … 617 717 pWidthArray[i-iFirstChar] = 0; 618 718 } 619 719 620 720 dprintf2(("Char 0x%x('%c') -> width %d", i, i<256? i: '.', pWidthArray[i-iFirstChar])); 621 721 } 622 722 623 723 return ret; 624 724 } … … 632 732 // LPWSTR lpszString - unicod string pointer 633 733 // UINT cbString - number of valid characters in string 634 // PINT pWidthArray - array that receives the character width (must be 734 // PINT pWidthArray - array that receives the character width (must be 635 735 // large enough to contain cbString elements 636 // 736 // 637 737 // Returns: 638 738 // FALSE - failure … … 664 764 BOOL WIN32API GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar, LPABC abc) 665 765 { 666 if(FT2Module.isEnabled() == FALSE) 766 if(FT2Module.isEnabled() == FALSE) 667 767 {//fallback method 668 768 return O32_GetCharABCWidths(hdc, firstChar, lastChar, abc); … … 682 782 str = (LPSTR)HeapAlloc(GetProcessHeap(), 0, count); 683 783 for(i = 0; i < count; i++) 684 784 str[i] = (BYTE)(firstChar + i); 685 785 686 786 wstr = FONT_mbtowc(hdc, str, count, &wlen, NULL); … … 688 788 for(i = 0; i < wlen; i++) 689 789 { 690 691 692 693 694 695 790 if(!GetCharABCWidthsW(hdc, wstr[i], wstr[i], abc)) 791 { 792 ret = FALSE; 793 break; 794 } 795 abc++; 696 796 } 697 797 … … 705 805 BOOL WIN32API GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar, LPABC abc) 706 806 { 707 if(FT2Module.isEnabled() == FALSE) 807 if(FT2Module.isEnabled() == FALSE) 708 808 {//no fallback method (yet) 709 809 DebugInt3(); … … 714 814 GLYPHMETRICS gm; 715 815 716 for (i=firstChar;i<=lastChar;i++) 717 { 718 if(GetGlyphOutlineW(hdc, i, GGO_METRICS, &gm, 0, NULL, NULL) == GDI_ERROR) 816 for (i=firstChar;i<=lastChar;i++) 817 { 818 if(GetGlyphOutlineW(hdc, i, GGO_METRICS, &gm, 0, NULL, NULL) == GDI_ERROR) 719 819 { 720 820 dprintf(("ERROR: GetGlyphOutlineW failed!!")); … … 749 849 //****************************************************************************** 750 850 //****************************************************************************** 851
Note:
See TracChangeset
for help on using the changeset viewer.