Ignore:
Timestamp:
Jan 14, 2004, 12:07:35 PM (22 years ago)
Author:
sandervl
Message:

KOM: Misc DBCS related text fixes

File:
1 edited

Legend:

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

    r10374 r10390  
    191191{
    192192    //no fallback
     193    SetLastError(ERROR_CALL_NOT_IMPLEMENTED_W);
    193194    return GDI_ERROR;
    194195}
     
    209210//
    210211//******************************************************************************
    211 BOOL CFT2Module::Ft2GetTextExtentW(HPS hps, LONG lCount1,LPCWSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints)
    212 {
    213     DWORD  ret;
    214     USHORT sel;
    215 
    216     // All FreeType calls should be wrapped for saving FS
    217     if(pfnFt2GetTextExtentW)
     212BOOL CFT2Module::Ft2GetTextExtentW(HPS hps, LONG lCount1,LPCWSTR pchString, PPOINTLOS2 pwidthHeight)
     213{
     214    DWORD      ret;
     215    USHORT     sel;
     216    POINTLOS2  aptlPoints[TXTBOX_COUNT];
     217
     218    // All FreeType calls should be wrapped for saving FS
     219    if(pfnFt2GetTextExtentW)
    218220    {
    219221        sel  = RestoreOS2FS();
    220         ret  = pfnFt2GetTextExtentW(hps, lCount1, pchString, lCount2, aptlPoints);
     222        ret  = pfnFt2GetTextExtentW(hps, lCount1, pchString, TXTBOX_COUNT, aptlPoints);
    221223        SetFS(sel);
    222224        if(ret || (ret == FALSE && ERRORIDERROR(WinGetLastError(0)) != PMERR_FUNCTION_NOT_SUPPORTED))
    223225        {
    224226            //No need for scaling for printer DCs here
    225             return ret;
    226         }
     227            calcDimensions(aptlPoints, pwidthHeight);
     228            return ret;
     229        }
    227230    }
    228231    //else fall back to GPI
    229     int   len;
    230     LPSTR astring;
     232    INT lenA;
     233    LPSTR strA;
     234    POINTLOS2 start = { 0, 0 };
     235    PPOINTLOS2 pplos2;
     236    INT cx;
     237    INT cy;
    231238
    232239    pDCData pHps = (pDCData)OSLibGpiQueryDCData(hps);
    233240
    234     len = WideCharToMultiByte( CP_ACP, 0, pchString, lCount1, 0, 0, NULL, NULL );
    235     astring = (char *)malloc( len + 1 );
    236     lstrcpynWtoA(astring, pchString, len + 1 );
    237 
    238     ret = OSLibGpiQueryTextBox(pHps, lCount1, astring, lCount2, aptlPoints);
    239     free(astring);
     241    lenA = WideCharToMultiByte( CP_ACP, 0, pchString, lCount1, 0, 0, 0, 0 );
     242    strA = ( LPSTR )malloc( lenA + 1 );
     243    lstrcpynWtoA( strA, pchString, lenA + 1 );
     244    pplos2 = ( PPOINTLOS2 )malloc(( lenA + 1 ) * sizeof( POINTLOS2 ));
     245
     246    ret = OSLibGpiQueryCharStringPosAt( pHps, &start, 0, lenA, strA, NULL, pplos2 );
     247
     248    cx = labs( pplos2[ lenA ].x - pplos2[ 0 ].x );
     249    cy = labs( pplos2[ lenA ].y - pplos2[ 0 ].y );
     250
     251    if( ret )
     252    {
     253        aptlPoints[ TXTBOX_BOTTOMLEFT ].x = 0;
     254        aptlPoints[ TXTBOX_BOTTOMLEFT ].y = 0;
     255        aptlPoints[ TXTBOX_BOTTOMRIGHT ].x = cx;
     256        aptlPoints[ TXTBOX_BOTTOMRIGHT ].y = cy;
     257        aptlPoints[ TXTBOX_TOPLEFT ].x = 0;
     258        aptlPoints[ TXTBOX_TOPLEFT ].y = 0;
     259        aptlPoints[ TXTBOX_TOPRIGHT ].x = cx;
     260        aptlPoints[ TXTBOX_TOPRIGHT ].y = cy;
     261        aptlPoints[ TXTBOX_CONCAT ].x = cx;
     262        aptlPoints[ TXTBOX_CONCAT ].y = cy;
     263    }
     264
     265    calcDimensions(aptlPoints, pwidthHeight);
     266
     267    TEXTMETRICW tmW;
     268    if(GetTextMetricsW( hps, &tmW ) == TRUE)
     269    {
     270        pwidthHeight->y = tmW.tmHeight;    // *Must* use the maximum height of the font
     271    }
     272#ifdef DEBUG
     273    else DebugInt3();
     274#endif
     275
     276    free( pplos2 );
     277    free( strA );
     278
    240279    return ret;
    241280}
     
    286325    lstrcpynWtoA(astring, pchString, len + 1 );
    287326
    288     ret = OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,lCount,astring,alAdx);
     327    ret = OSLibGpiCharStringPosAt(pHps,ptl,rct,flOptions,len,astring,alAdx);
    289328    free(astring);
    290329    return ret;
Note: See TracChangeset for help on using the changeset viewer.