gdi32: Improve the font enumeration order for complex script locales.

This commit is contained in:
Akihiro Sagawa 2014-03-07 01:22:19 +09:00 committed by Alexandre Julliard
parent a07966dba8
commit 04e8b00ab0
2 changed files with 19 additions and 6 deletions

View File

@ -5527,12 +5527,20 @@ static INT load_script_name( UINT id, WCHAR buffer[LF_FACESIZE] )
return i;
}
static inline BOOL is_complex_script_ansi_cp(UINT ansi_cp)
{
return (ansi_cp == 874 /* Thai */
|| ansi_cp == 1255 /* Hebrew */
|| ansi_cp == 1256 /* Arabic */
);
}
/***************************************************
* create_enum_charset_list
*
* This function creates charset enumeration list because in DEFAULT_CHARSET
* case, the ANSI codepage's charset takes precedence over other charsets.
* Above rule doesn't apply if the ANSI codepage uses complex script (e.g. Thai).
* This function works as a filter other than DEFAULT_CHARSET case.
*/
static DWORD create_enum_charset_list(DWORD charset, struct enum_charset_list *list)
@ -5553,7 +5561,8 @@ static DWORD create_enum_charset_list(DWORD charset, struct enum_charset_list *l
/* Set the current codepage's charset as the first element. */
acp = GetACP();
if (TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE) &&
if (!is_complex_script_ansi_cp(acp) &&
TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE) &&
csi.fs.fsCsb[0] != 0) {
list->element[n].mask = csi.fs.fsCsb[0];
list->element[n].charset = csi.ciCharset;

View File

@ -2957,7 +2957,7 @@ static INT CALLBACK enum_multi_charset_font_proc(const LOGFONTA *lf, const TEXTM
if (TranslateCharsetInfo(ULongToPtr(target->lfCharSet), &csi, TCI_SRCCHARSET)) {
fs = ntm->ntmFontSig.fsCsb[0] & valid_bits;
if ((fs & csi.fs.fsCsb[0]) && (fs & ~csi.fs.fsCsb[0])) {
if ((fs & csi.fs.fsCsb[0]) && (fs & ~csi.fs.fsCsb[0]) && (fs & FS_LATIN1)) {
*target = *lf;
return FALSE;
}
@ -2998,13 +2998,13 @@ static void test_EnumFontFamiliesEx_default_charset(void)
{
struct enum_font_data efd;
LOGFONTA target, enum_font;
DWORD ret;
UINT acp;
HDC hdc;
CHARSETINFO csi;
ret = GetACP();
if (!TranslateCharsetInfo(ULongToPtr(ret), &csi, TCI_SRCCODEPAGE)) {
skip("TranslateCharsetInfo failed for code page %d.\n", ret);
acp = GetACP();
if (!TranslateCharsetInfo(ULongToPtr(acp), &csi, TCI_SRCCODEPAGE)) {
skip("TranslateCharsetInfo failed for code page %u.\n", acp);
return;
}
@ -3018,6 +3018,10 @@ static void test_EnumFontFamiliesEx_default_charset(void)
skip("suitable font isn't found for charset %d.\n", enum_font.lfCharSet);
return;
}
if (acp == 874 || acp == 1255 || acp == 1256) {
/* these codepage use complex script, expecting ANSI_CHARSET here. */
target.lfCharSet = ANSI_CHARSET;
}
efd.total = 0;
memset(&enum_font, 0, sizeof(enum_font));