diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c index ac9ab65e0b0..7821bc27d29 100644 --- a/graphics/x11drv/xfont.c +++ b/graphics/x11drv/xfont.c @@ -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) diff --git a/objects/font.c b/objects/font.c index df4afe18c56..52c71029177 100644 --- a/objects/font.c +++ b/objects/font.c @@ -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; }