Handle the codepage of fonts if supported by the graphics driver.

This commit is contained in:
Hidenori Takeshima 2000-08-20 20:08:35 +00:00 committed by Alexandre Julliard
parent 5b1b512020
commit 7901c0b505
5 changed files with 59 additions and 38 deletions

View File

@ -2995,6 +2995,10 @@ HFONT X11DRV_FONT_SelectObject( DC* dc, HFONT hfont, FONTOBJ* font )
hPrevFont = dc->w.hFont;
dc->w.hFont = hfont;
dc->w.codepage = CP_ACP;
/* NOTE: the codepage of UNICODE is treated as CP_ACP(=0) */
if ( CHECK_PFONT(physDev->font) )
dc->w.codepage = __PFONT(physDev->font)->fi->codepage;
LeaveCriticalSection( &crtsc_fonts_X11 );

View File

@ -134,6 +134,7 @@ typedef struct
XFORM xformWorld2Vport; /* World-to-viewport transformation */
XFORM xformVport2World; /* Inverse of the above transformation */
BOOL vport2WorldValid; /* Is xformVport2World valid? */
WORD codepage; /* codepage of the selected font */
} WIN_DC_INFO;

View File

@ -73,6 +73,7 @@ static void DC_Init_DC_INFO( WIN_DC_INFO *win_dc_info )
win_dc_info->xformWorld2Vport = win_dc_info->xformWorld2Wnd;
win_dc_info->xformVport2World = win_dc_info->xformWorld2Wnd;
win_dc_info->vport2WorldValid = TRUE;
win_dc_info->codepage = CP_ACP;
PATH_InitGdiPath(&win_dc_info->path);
}

View File

@ -889,22 +889,28 @@ BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count,
BOOL WINAPI GetTextExtentPoint32A( HDC hdc, LPCSTR str, INT count,
LPSIZE size )
{
LPWSTR p;
BOOL ret;
UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
UINT wlen;
BOOL ret = FALSE;
DC * dc = DC_GetDCPtr( hdc );
/* str may not be 0 terminated so we can't use HEAP_strdupWtoA.
* We allocate one more than we need so that lstrcpynWtoA can write a
* trailing 0 if it wants.
*/
if (!dc) return FALSE;
wlen = MultiByteToWideChar(codepage,0,str,count,NULL,0);
p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) );
wlen = MultiByteToWideChar(codepage,0,str,count,p,wlen);
ret = GetTextExtentPoint32W( hdc, p, wlen, size );
HeapFree( GetProcessHeap(), 0, p );
if (dc->funcs->pGetTextExtentPoint)
{
/* str may not be 0 terminated so we can't use HEAP_strdupWtoA.
* So we use MultiByteToWideChar.
*/
UINT wlen = MultiByteToWideChar(dc->w.codepage,0,str,count,NULL,0);
LPWSTR p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) );
if (p)
{
wlen = MultiByteToWideChar(dc->w.codepage,0,str,count,p,wlen);
ret = dc->funcs->pGetTextExtentPoint( dc, p, wlen, size );
HeapFree( GetProcessHeap(), 0, p );
}
}
GDI_ReleaseObj( hdc );
TRACE("(%08x %s %d %p): returning %d,%d\n",
hdc, debugstr_an (str, count), count, size, size->cx, size->cy );
return ret;
}

View File

@ -52,35 +52,44 @@ BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
const RECT *lprect, LPCSTR str, UINT count,
const INT *lpDx )
{
DC * dc = DC_GetDCUpdate( hdc );
LPWSTR p;
INT ret;
UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
UINT wlen;
BOOL ret = FALSE;
LPINT lpDxW = NULL;
wlen = MultiByteToWideChar(codepage,0,str,count,NULL,0);
if(lpDx){
int i, j;
i = 0; j = 0;
if (!dc) return FALSE;
lpDxW = (LPINT)HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(INT));
while(i < count){
if(IsDBCSLeadByteEx(codepage, str[i])){
lpDxW[j++] = lpDx[i] + lpDx[i+1];
i = i + 2;
}
else{
lpDxW[j++] = lpDx[i];
i = i + 1;
}
}
lpDx = lpDxW;
if (dc->funcs->pExtTextOut)
{
UINT wlen = MultiByteToWideChar(dc->w.codepage,0,str,count,NULL,0);
if (lpDx)
{
int i = 0, j = 0;
lpDxW = (LPINT)HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(INT));
while(i < count)
{
if(IsDBCSLeadByteEx(dc->w.codepage, str[i]))
{
lpDxW[j++] = lpDx[i] + lpDx[i+1];
i = i + 2;
}
else
{
lpDxW[j++] = lpDx[i];
i = i + 1;
}
}
}
if ((p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) )))
{
wlen = MultiByteToWideChar(dc->w.codepage,0,str,count,p,wlen);
ret = dc->funcs->pExtTextOut( dc, x, y, flags, lprect, p, wlen, lpDxW );
HeapFree( GetProcessHeap(), 0, p );
}
if (lpDxW) HeapFree( GetProcessHeap(), 0, lpDxW );
}
p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) );
wlen = MultiByteToWideChar(codepage,0,str,count,p,wlen);
ret = ExtTextOutW( hdc, x, y, flags, lprect, p, wlen, lpDxW );
if (lpDxW) HeapFree( GetProcessHeap(), 0, lpDxW );
HeapFree( GetProcessHeap(), 0, p );
GDI_ReleaseObj( hdc );
return ret;
}