diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 66072afa23e..af3ea5bddbe 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -653,12 +653,15 @@ static DWORD get_associated_charset_info(void) return associated_charset; } -static void update_font_code_page( DC *dc ) +static void update_font_code_page( DC *dc, HANDLE font ) { CHARSETINFO csi; int charset = GetTextCharsetInfo( dc->hSelf, NULL, 0 ); + LOGFONTW lf; - if (charset == ANSI_CHARSET && + GetObjectW( font, sizeof(lf), &lf ); + + if (charset == ANSI_CHARSET && !(lf.lfClipPrecision & CLIP_DFA_DISABLE) && get_associated_charset_info() & ASSOC_CHARSET_ANSI) charset = DEFAULT_CHARSET; @@ -725,7 +728,7 @@ static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc ) ret = dc->hFont; dc->hFont = handle; dc->aa_flags = aa_flags ? aa_flags : GGO_BITMAP; - update_font_code_page( dc ); + update_font_code_page( dc, handle ); GDI_dec_ref_count( ret ); } else GDI_dec_ref_count( handle ); diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index e978166d24d..dd632972c4f 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -2570,6 +2570,22 @@ static void test_GdiGetCodePage(void) hfont = SelectObject(hdc, hfont); DeleteObject(hfont); + + /* CLIP_DFA_DISABLE turns off the font association */ + lf.lfClipPrecision = CLIP_DFA_DISABLE; + hfont = CreateFontIndirectA(&lf); + ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError()); + + hfont = SelectObject(hdc, hfont); + charset = GetTextCharset(hdc); + codepage = pGdiGetCodePage(hdc); + trace("acp=%d, lfFaceName=%s, lfCharSet=%d, GetTextCharset=%d, GdiGetCodePage=%d\n", + acp, lf.lfFaceName, lf.lfCharSet, charset, codepage); + ok(codepage == 1252, "GdiGetCodePage returned %d\n", codepage); + + hfont = SelectObject(hdc, hfont); + DeleteObject(hfont); + ReleaseDC(NULL, hdc); } }