Commit 4bb8d9c1 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdi32: Cache current font code page in the DC structure.

parent 301b5d27
...@@ -110,6 +110,7 @@ DC *alloc_dc_ptr( const DC_FUNCTIONS *funcs, WORD magic ) ...@@ -110,6 +110,7 @@ DC *alloc_dc_ptr( const DC_FUNCTIONS *funcs, WORD magic )
dc->hDevice = 0; dc->hDevice = 0;
dc->hPalette = GetStockObject( DEFAULT_PALETTE ); dc->hPalette = GetStockObject( DEFAULT_PALETTE );
dc->gdiFont = 0; dc->gdiFont = 0;
dc->font_code_page = CP_ACP;
dc->ROPmode = R2_COPYPEN; dc->ROPmode = R2_COPYPEN;
dc->polyFillMode = ALTERNATE; dc->polyFillMode = ALTERNATE;
dc->stretchBltMode = BLACKONWHITE; dc->stretchBltMode = BLACKONWHITE;
......
...@@ -247,45 +247,13 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC ...@@ -247,45 +247,13 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC
DWORD WINAPI GdiGetCodePage( HDC hdc ) DWORD WINAPI GdiGetCodePage( HDC hdc )
{ {
UINT cp = CP_ACP; UINT cp = CP_ACP;
CHARSETINFO csi; DC *dc = get_dc_ptr( hdc );
int charset = GetTextCharset(hdc);
/* Hmm, nicely designed api this one! */
if(TranslateCharsetInfo(ULongToPtr(charset), &csi, TCI_SRCCHARSET))
cp = csi.ciACP;
else {
switch(charset) {
case OEM_CHARSET:
cp = GetOEMCP();
break;
case DEFAULT_CHARSET:
cp = GetACP();
break;
case VISCII_CHARSET:
case TCVN_CHARSET:
case KOI8_CHARSET:
case ISO3_CHARSET:
case ISO4_CHARSET:
case ISO10_CHARSET:
case CELTIC_CHARSET:
/* FIXME: These have no place here, but because x11drv
enumerates fonts with these (made up) charsets some apps
might use them and then the FIXME below would become
annoying. Now we could pick the intended codepage for
each of these, but since it's broken anyway we'll just
use CP_ACP and hope it'll go away...
*/
cp = CP_ACP;
break;
default: if (dc)
FIXME("Can't find codepage for charset %d\n", charset); {
break; cp = dc->font_code_page;
} release_dc_ptr( dc );
} }
TRACE("charset %d => cp %d\n", charset, cp);
return cp; return cp;
} }
...@@ -465,6 +433,52 @@ HFONT WINAPI CreateFontW( INT height, INT width, INT esc, ...@@ -465,6 +433,52 @@ HFONT WINAPI CreateFontW( INT height, INT width, INT esc,
return CreateFontIndirectW( &logfont ); return CreateFontIndirectW( &logfont );
} }
static void update_font_code_page( DC *dc )
{
CHARSETINFO csi;
int charset = DEFAULT_CHARSET;
if (dc->gdiFont)
charset = WineEngGetTextCharsetInfo( dc->gdiFont, NULL, 0 );
/* Hmm, nicely designed api this one! */
if (TranslateCharsetInfo( ULongToPtr(charset), &csi, TCI_SRCCHARSET) )
dc->font_code_page = csi.ciACP;
else {
switch(charset) {
case OEM_CHARSET:
dc->font_code_page = GetOEMCP();
break;
case DEFAULT_CHARSET:
dc->font_code_page = GetACP();
break;
case VISCII_CHARSET:
case TCVN_CHARSET:
case KOI8_CHARSET:
case ISO3_CHARSET:
case ISO4_CHARSET:
case ISO10_CHARSET:
case CELTIC_CHARSET:
/* FIXME: These have no place here, but because x11drv
enumerates fonts with these (made up) charsets some apps
might use them and then the FIXME below would become
annoying. Now we could pick the intended codepage for
each of these, but since it's broken anyway we'll just
use CP_ACP and hope it'll go away...
*/
dc->font_code_page = CP_ACP;
break;
default:
FIXME("Can't find codepage for charset %d\n", charset);
dc->font_code_page = CP_ACP;
break;
}
}
TRACE("charset %d => cp %d\n", charset, dc->font_code_page);
}
/*********************************************************************** /***********************************************************************
* FONT_SelectObject * FONT_SelectObject
...@@ -506,6 +520,7 @@ static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc ) ...@@ -506,6 +520,7 @@ static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc )
{ {
ret = dc->hFont; ret = dc->hFont;
dc->hFont = handle; dc->hFont = handle;
update_font_code_page( dc );
GDI_dec_ref_count( ret ); GDI_dec_ref_count( ret );
} }
release_dc_ptr( dc ); release_dc_ptr( dc );
......
...@@ -281,6 +281,7 @@ typedef struct tagDC ...@@ -281,6 +281,7 @@ typedef struct tagDC
GdiFont *gdiFont; GdiFont *gdiFont;
GdiPath path; GdiPath path;
UINT font_code_page;
WORD ROPmode; WORD ROPmode;
WORD polyFillMode; WORD polyFillMode;
WORD stretchBltMode; WORD stretchBltMode;
......
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