Convert GetCharWidth to Unicode.

This commit is contained in:
Dmitry Timoshkov 2001-11-05 23:56:22 +00:00 committed by Alexandre Julliard
parent 38a247fde9
commit 3f8e407d48
2 changed files with 41 additions and 10 deletions

View File

@ -3326,10 +3326,15 @@ BOOL X11DRV_GetCharWidth( DC *dc, UINT firstChar, UINT lastChar,
for (i = firstChar; i <= lastChar; i++)
{
if (i >= pfo->fs->min_char_or_byte2 &&
i <= pfo->fs->max_char_or_byte2)
WCHAR wch = i;
BYTE ch;
UINT ch_f; /* character code in the font encoding */
WideCharToMultiByte( pfo->fi->codepage, 0, &wch, 1, &ch, 1, NULL, NULL );
ch_f = ch;
if (ch_f >= pfo->fs->min_char_or_byte2 &&
ch_f <= pfo->fs->max_char_or_byte2)
{
cs = &pfo->fs->per_char[(i - pfo->fs->min_char_or_byte2)];
cs = &pfo->fs->per_char[(ch_f - pfo->fs->min_char_or_byte2)];
if (CI_NONEXISTCHAR(cs)) cs = def;
} else cs = def;
if(pfo->lpX11Trans)

View File

@ -1507,10 +1507,10 @@ BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
/***********************************************************************
* GetCharWidthA (GDI32.@)
* GetCharWidth32A (GDI32.@)
* GetCharWidthW (GDI32.@)
* GetCharWidth32W (GDI32.@)
*/
BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar,
LPINT buffer )
{
UINT i, extra;
@ -1538,13 +1538,39 @@ BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
/***********************************************************************
* GetCharWidthW (GDI32.@)
* GetCharWidth32W (GDI32.@)
* GetCharWidthA (GDI32.@)
* GetCharWidth32A (GDI32.@)
*/
BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar,
BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
LPINT buffer )
{
return GetCharWidth32A( hdc, firstChar, lastChar, buffer );
INT i, wlen, count = (INT)(lastChar - firstChar + 1);
LPSTR str;
LPWSTR wstr;
BOOL ret = TRUE;
if(count <= 0) return FALSE;
str = HeapAlloc(GetProcessHeap(), 0, count);
for(i = 0; i < count; i++)
str[i] = (BYTE)(firstChar + i);
wstr = FONT_mbtowc(hdc, str, count, &wlen, NULL);
for(i = 0; i < wlen; i++)
{
if(!GetCharWidth32W(hdc, wstr[i], wstr[i], buffer))
{
ret = FALSE;
break;
}
buffer++;
}
HeapFree(GetProcessHeap(), 0, str);
HeapFree(GetProcessHeap(), 0, wstr);
return ret;
}