Commit bdebdbaf authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Get codepages and OS version directly from PEB.

parent 0758578d
...@@ -435,7 +435,7 @@ INT WINAPI NtGdiGetRandomRgn( HDC hDC, HRGN hRgn, INT iCode ) ...@@ -435,7 +435,7 @@ INT WINAPI NtGdiGetRandomRgn( HDC hDC, HRGN hRgn, INT iCode )
{ {
NtGdiCombineRgn( hRgn, dc->hVisRgn, 0, RGN_COPY ); NtGdiCombineRgn( hRgn, dc->hVisRgn, 0, RGN_COPY );
/* On Windows NT/2000, the SYSRGN returned is in screen coordinates */ /* On Windows NT/2000, the SYSRGN returned is in screen coordinates */
if (!(GetVersion() & 0x80000000)) if (NtCurrentTeb()->Peb->OSPlatformId != VER_PLATFORM_WIN32s)
NtGdiOffsetRgn( hRgn, dc->attr->vis_rect.left, dc->attr->vis_rect.top ); NtGdiOffsetRgn( hRgn, dc->attr->vis_rect.left, dc->attr->vis_rect.top );
} }
else if (!is_rect_empty( &dc->device_rect )) else if (!is_rect_empty( &dc->device_rect ))
......
...@@ -202,6 +202,16 @@ static UINT asciiz_to_unicode( WCHAR *dst, const char *src ) ...@@ -202,6 +202,16 @@ static UINT asciiz_to_unicode( WCHAR *dst, const char *src )
return (p - dst) * sizeof(WCHAR); return (p - dst) * sizeof(WCHAR);
} }
UINT get_acp(void)
{
return ((const WORD *)NtCurrentTeb()->Peb->AnsiCodePageData)[1];
}
static UINT get_oemcp(void)
{
return ((const WORD *)NtCurrentTeb()->Peb->OemCodePageData)[1];
}
static inline WCHAR facename_tolower( WCHAR c ) static inline WCHAR facename_tolower( WCHAR c )
{ {
if (c >= 'A' && c <= 'Z') return c - 'A' + 'a'; if (c >= 'A' && c <= 'Z') return c - 'A' + 'a';
...@@ -272,7 +282,7 @@ static inline INT INTERNAL_YWSTODS(DC *dc, INT height) ...@@ -272,7 +282,7 @@ static inline INT INTERNAL_YWSTODS(DC *dc, INT height)
static inline BOOL is_win9x(void) static inline BOOL is_win9x(void)
{ {
return GetVersion() & 0x80000000; return NtCurrentTeb()->Peb->OSPlatformId == VER_PLATFORM_WIN32s;
} }
static inline WCHAR *strdupW( const WCHAR *p ) static inline WCHAR *strdupW( const WCHAR *p )
...@@ -1864,7 +1874,7 @@ static struct gdi_font_face *find_matching_face( const LOGFONTW *lf, CHARSETINFO ...@@ -1864,7 +1874,7 @@ static struct gdi_font_face *find_matching_face( const LOGFONTW *lf, CHARSETINFO
corresponding to the current ansi codepage */ corresponding to the current ansi codepage */
if (!csi->fs.fsCsb[0]) if (!csi->fs.fsCsb[0])
{ {
INT acp = GetACP(); INT acp = get_acp();
if (!translate_charset_info( (DWORD *)(INT_PTR)acp, csi, TCI_SRCCODEPAGE )) if (!translate_charset_info( (DWORD *)(INT_PTR)acp, csi, TCI_SRCCODEPAGE ))
{ {
FIXME( "TCI failed on codepage %d\n", acp ); FIXME( "TCI failed on codepage %d\n", acp );
...@@ -2464,7 +2474,7 @@ static void create_child_font_list( struct gdi_font *font ) ...@@ -2464,7 +2474,7 @@ static void create_child_font_list( struct gdi_font *font )
* if not SYMBOL or OEM then we also get all the fonts for Microsoft * if not SYMBOL or OEM then we also get all the fonts for Microsoft
* Sans Serif. This is how asian windows get default fallbacks for fonts * Sans Serif. This is how asian windows get default fallbacks for fonts
*/ */
if (is_dbcs_ansi_cp(GetACP()) && font->charset != SYMBOL_CHARSET && font->charset != OEM_CHARSET && if (is_dbcs_ansi_cp(get_acp()) && font->charset != SYMBOL_CHARSET && font->charset != OEM_CHARSET &&
facename_compare( font_name, microsoft_sans_serifW, -1 ) != 0) facename_compare( font_name, microsoft_sans_serifW, -1 ) != 0)
{ {
if ((font_link = find_gdi_font_link( microsoft_sans_serifW ))) if ((font_link = find_gdi_font_link( microsoft_sans_serifW )))
...@@ -2725,8 +2735,8 @@ static void update_codepage( UINT screen_dpi ) ...@@ -2725,8 +2735,8 @@ static void update_codepage( UINT screen_dpi )
if (size == sizeof(DWORD) && info->Type == REG_DWORD) if (size == sizeof(DWORD) && info->Type == REG_DWORD)
font_dpi = *(DWORD *)info->Data; font_dpi = *(DWORD *)info->Data;
ansi_cp = GetACP(); ansi_cp = get_acp();
oem_cp = GetOEMCP(); oem_cp = get_oemcp();
sprintf( cpbuf, "%u,%u", ansi_cp, oem_cp ); sprintf( cpbuf, "%u,%u", ansi_cp, oem_cp );
asciiz_to_unicode( cpbufW, cpbuf ); asciiz_to_unicode( cpbufW, cpbuf );
...@@ -2897,7 +2907,7 @@ static DWORD create_enum_charset_list(DWORD charset, struct enum_charset *list) ...@@ -2897,7 +2907,7 @@ static DWORD create_enum_charset_list(DWORD charset, struct enum_charset *list)
} }
else /* charset is DEFAULT_CHARSET or invalid. */ else /* charset is DEFAULT_CHARSET or invalid. */
{ {
int acp = GetACP(); int acp = get_acp();
DWORD mask = 0; DWORD mask = 0;
/* Set the current codepage's charset as the first element. */ /* Set the current codepage's charset as the first element. */
...@@ -3884,7 +3894,7 @@ static void get_nearest_charset( const WCHAR *family_name, struct gdi_font_face ...@@ -3884,7 +3894,7 @@ static void get_nearest_charset( const WCHAR *family_name, struct gdi_font_face
int i; int i;
if (translate_charset_info( (DWORD*)(INT_PTR)GetACP(), csi, TCI_SRCCODEPAGE )) if (translate_charset_info( (DWORD*)(INT_PTR)get_acp(), csi, TCI_SRCCODEPAGE ))
{ {
const struct gdi_font_link *font_link; const struct gdi_font_link *font_link;
...@@ -3904,7 +3914,7 @@ static void get_nearest_charset( const WCHAR *family_name, struct gdi_font_face ...@@ -3904,7 +3914,7 @@ static void get_nearest_charset( const WCHAR *family_name, struct gdi_font_face
FIXME("returning DEFAULT_CHARSET face->fs.fsCsb[0] = %08x file = %s\n", FIXME("returning DEFAULT_CHARSET face->fs.fsCsb[0] = %08x file = %s\n",
face->fs.fsCsb[0], debugstr_w(face->file)); face->fs.fsCsb[0], debugstr_w(face->file));
csi->ciACP = GetACP(); csi->ciACP = get_acp();
csi->ciCharset = DEFAULT_CHARSET; csi->ciCharset = DEFAULT_CHARSET;
} }
...@@ -4497,10 +4507,10 @@ static void update_font_code_page( DC *dc, HANDLE font ) ...@@ -4497,10 +4507,10 @@ static void update_font_code_page( DC *dc, HANDLE font )
else { else {
switch(charset) { switch(charset) {
case OEM_CHARSET: case OEM_CHARSET:
dc->attr->font_code_page = GetOEMCP(); dc->attr->font_code_page = get_oemcp();
break; break;
case DEFAULT_CHARSET: case DEFAULT_CHARSET:
dc->attr->font_code_page = GetACP(); dc->attr->font_code_page = get_acp();
break; break;
case VISCII_CHARSET: case VISCII_CHARSET:
......
...@@ -497,7 +497,7 @@ static UINT get_default_charset( void ) ...@@ -497,7 +497,7 @@ static UINT get_default_charset( void )
CHARSETINFO csi; CHARSETINFO csi;
UINT uACP; UINT uACP;
uACP = GetACP(); uACP = get_acp();
csi.ciCharset = ANSI_CHARSET; csi.ciCharset = ANSI_CHARSET;
if ( !translate_charset_info( ULongToPtr(uACP), &csi, TCI_SRCCODEPAGE ) ) if ( !translate_charset_info( ULongToPtr(uACP), &csi, TCI_SRCCODEPAGE ) )
{ {
......
...@@ -339,6 +339,7 @@ struct font_callback_funcs ...@@ -339,6 +339,7 @@ struct font_callback_funcs
}; };
extern UINT font_init(void) DECLSPEC_HIDDEN; extern UINT font_init(void) DECLSPEC_HIDDEN;
extern UINT get_acp(void) DECLSPEC_HIDDEN;
/* opentype.c */ /* opentype.c */
......
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