Commit 3f8e407d authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Convert GetCharWidth to Unicode.

parent 38a247fd
......@@ -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)
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment