Changeset 10365 for trunk/src


Ignore:
Timestamp:
Dec 29, 2003, 12:54:54 PM (22 years ago)
Author:
sandervl
Message:

KOM: GetTextExtentPointW fix; GetTextExtentExPointA fix for DBCS leadbytes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/text.cpp

    r10363 r10365  
    1 /* $Id: text.cpp,v 1.36 2003-12-29 10:55:49 sandervl Exp $ */
     1/* $Id: text.cpp,v 1.37 2003-12-29 11:54:54 sandervl Exp $ */
    22
    33/*
     
    409409   pDCData    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
    410410
    411    dprintf(("GDI32: GetTextExtentPointW %x %.*ls %d", hdc, cbString, lpString, cbString));
     411   dprintf(("GDI32: GetTextExtentPointW %ls", lpString));
    412412   if(pHps == NULL)
    413413   {
     
    460460   lstrcpynWtoA(astring, lpString, len + 1 );
    461461
    462    rc = OSLibGpiQueryTextBox(pHps, cbString, astring, TXTBOXOS_COUNT, pts);
     462   rc = OSLibGpiQueryTextBox(pHps, len, astring, TXTBOXOS_COUNT, pts);
    463463   free(astring);
    464464
     
    480480   }
    481481
    482    dprintf(("GDI32: GetTextExtentPointW %x %.*ls %d returned %d (%d,%d)", hdc, cbString, lpString, cbString, rc, lpSize->cx, lpSize->cy));
     482   dprintf(("GDI32: GetTextExtentPointW %x %ls %d returned %d (%d,%d)", hdc, lpString, cbString, rc, lpSize->cx, lpSize->cy));
    483483   SetLastError(ERROR_SUCCESS);
    484484   return TRUE;
     
    511511    ret = GetTextExtentExPointW( hdc, p, wlen, maxExt, lpnFit, alpDx, size);
    512512    if (lpnFit) *lpnFit = WideCharToMultiByte(CP_ACP,0,p,*lpnFit,NULL,0,NULL,NULL);
     513    if( IsDBCSEnv() && alpDx ) /* index of alpDx between ansi and wide may not match in DBCS !!! */
     514    {
     515        LPINT alpDxNew = ( LPINT )HeapAlloc( GetProcessHeap(), 0, *lpnFit );
     516        int i, j;
     517
     518        for( i = j = 0; i < *lpnFit; i++, j++ )
     519        {
     520            if( IsDBCSLeadByte( str[ i ]))
     521            {
     522                alpDxNew[ i++ ] = alpDx[ j ] >> 1;
     523                if( i < *lpnFit )
     524                    alpDxNew[ i ] = alpDx[ j ] >> 1;
     525            }
     526            else
     527                alpDxNew[ i ] = alpDx[ j ];
     528
     529        }
     530
     531        memcpy( alpDx, alpDxNew, sizeof( alpDx[ 0 ] ) * *lpnFit );
     532
     533        HeapFree( GetProcessHeap(), 0, alpDxNew );
     534    }
    513535    HeapFree( GetProcessHeap(), 0, p );
    514536    return ret;
     
    531553    for(index = 0; index < count; index++)
    532554    {
    533         if(!GetTextExtentPoint32W( hdc, str, 1, &tSize )) goto done;
     555    if(!GetTextExtentPoint32W( hdc, str, 1, &tSize )) goto done;
    534556        /* GetTextExtentPoint includes intercharacter spacing. */
    535557        /* FIXME - justification needs doing yet.  Remember that the base
    536558         * data will not be in logical coordinates.
    537559         */
    538         extent += tSize.cx;
    539         if( !lpnFit || extent <= maxExt )
     560    extent += tSize.cx;
     561    if( !lpnFit || extent <= maxExt )
    540562        /* It is allowed to be equal. */
    541563        {
    542             nFit++;
    543             if( alpDx ) alpDx[index] = extent;
     564        nFit++;
     565        if( alpDx ) alpDx[index] = extent;
    544566        }
    545         if( tSize.cy > size->cy ) size->cy = tSize.cy;
    546         str++;
     567    if( tSize.cy > size->cy ) size->cy = tSize.cy;
     568    str++;
    547569    }
    548570    size->cx = extent;
Note: See TracChangeset for help on using the changeset viewer.