Ignore:
Timestamp:
Jul 14, 2003, 3:43:33 PM (22 years ago)
Author:
sandervl
Message:

KOM: Fixed InternalTextOutW() and GetTextExtentPointW() to support unicode correctly. (DBCS)

File:
1 edited

Legend:

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

    r9886 r10163  
    1 /* $Id: text.cpp,v 1.33 2003-03-03 16:33:35 sandervl Exp $ */
     1/* $Id: text.cpp,v 1.34 2003-07-14 13:43:15 sandervl Exp $ */
    22
    33/*
     
    107107  if(pHps->yInvert > 0) {
    108108     Y = pHps->yInvert - Y;
    109   } 
     109  }
    110110#endif
    111111
     
    139139          pmRect.yTop    = pHps->yInvert - pmRect.yBottom;
    140140          pmRect.yBottom = temp;
    141       }   
     141      }
    142142#endif
    143143#endif
     
    210210    BOOL rc;
    211211    PPOINTLOS2 pts = (PPOINTLOS2)malloc((cbCount+1)*sizeof(POINTLOS2));
    212  
     212
    213213    rc = OSLibGpiQueryCharStringPosAt(pHps,&ptl,flOptions & CHSOS_VECTOR,cbCount,lpszString,lpDx,pts);
    214214    if(rc) {
     
    236236
    237237  int vertAdjust = 0;
    238   if ((pHps->taMode & 0x18) != TA_TOP) 
     238  if ((pHps->taMode & 0x18) != TA_TOP)
    239239  {
    240240      vertAdjust = OSLibGpiQueryFontMaxHeight(pHps->hps);
     
    281281     astring = UnicodeToAsciiString((LPWSTR)lpszString);
    282282  }
    283   else
    284   if(cbCount) {
    285      astring = (char *)HEAP_malloc(cbCount+1);
    286      UnicodeToAsciiN((LPWSTR)lpszString, astring, cbCount+1);
    287      astring[cbCount] = 0;
    288   }
    289   rc = InternalTextOutA(hdc,X,Y,fuOptions,lprc,(LPCSTR)astring,cbCount,lpDx,IsExtTextOut);
     283  else
     284  if(cbCount >= 0) {
     285     int n = WideCharToMultiByte( CP_ACP, 0, lpszString, cbCount, 0, 0, NULL, NULL ) + 1;
     286
     287     astring = (char *)HEAP_malloc( n );
     288     UnicodeToAsciiN((LPWSTR)lpszString, astring, n );
     289  }
     290
     291  rc = InternalTextOutA(hdc,X,Y,fuOptions,lprc,(LPCSTR)astring, strlen( astring ),lpDx,IsExtTextOut);
    290292  if(astring) {
    291293      FreeAsciiString(astring);
     
    320322  if(astring)
    321323      free(astring);
    322  
     324
    323325  return(rc);
    324326}
     
    443445      return TRUE;
    444446   }
    445    if(cbString > 512) 
     447   if(cbString > 512)
    446448   {
    447449      DWORD cbStringNew;
     
    468470   if(rc == FALSE)
    469471   {
    470       SetLastError(ERROR_INVALID_PARAMETER);    //todo wrong error
     472      SetLastError(ERROR_INVALID_PARAMETER);    //todo wrong error
    471473      return FALSE;
    472474   }
     
    496498{
    497499  char *astring;
    498   BOOL  rc;
     500  int  len;
     501  BOOL rc;
    499502
    500503   if(lpString == NULL || cbString < 0 || lpSize == NULL)
     
    518521   dprintf(("GDI32: GetTextExtentPointW %x %.*ls %d %x", hdc, cbString, lpString, cbString, lpSize));
    519522
    520    astring = (char *)malloc((cbString+1)*sizeof(WCHAR));
    521    UnicodeToAsciiN(lpString, astring, cbString+1);
    522 
     523   len = WideCharToMultiByte( CP_ACP, 0, lpString, cbString, 0, 0, NULL, NULL );
     524   astring = (char *)malloc( len + 1 );
     525   UnicodeToAsciiN(lpString, astring, len + 1 );
    523526   rc = GetTextExtentPointA(hdc, astring,
    524                             cbString, lpSize);
     527                            len, lpSize);
    525528
    526529   free(astring);
Note: See TracChangeset for help on using the changeset viewer.