Commit 04e8b00a authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

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

parent a07966db
...@@ -5527,12 +5527,20 @@ static INT load_script_name( UINT id, WCHAR buffer[LF_FACESIZE] ) ...@@ -5527,12 +5527,20 @@ static INT load_script_name( UINT id, WCHAR buffer[LF_FACESIZE] )
return i; 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 * create_enum_charset_list
* *
* This function creates charset enumeration list because in DEFAULT_CHARSET * This function creates charset enumeration list because in DEFAULT_CHARSET
* case, the ANSI codepage's charset takes precedence over other charsets. * 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. * This function works as a filter other than DEFAULT_CHARSET case.
*/ */
static DWORD create_enum_charset_list(DWORD charset, struct enum_charset_list *list) 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 ...@@ -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. */ /* Set the current codepage's charset as the first element. */
acp = GetACP(); 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) { csi.fs.fsCsb[0] != 0) {
list->element[n].mask = csi.fs.fsCsb[0]; list->element[n].mask = csi.fs.fsCsb[0];
list->element[n].charset = csi.ciCharset; list->element[n].charset = csi.ciCharset;
......
...@@ -2957,7 +2957,7 @@ static INT CALLBACK enum_multi_charset_font_proc(const LOGFONTA *lf, const TEXTM ...@@ -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)) { if (TranslateCharsetInfo(ULongToPtr(target->lfCharSet), &csi, TCI_SRCCHARSET)) {
fs = ntm->ntmFontSig.fsCsb[0] & valid_bits; 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; *target = *lf;
return FALSE; return FALSE;
} }
...@@ -2998,13 +2998,13 @@ static void test_EnumFontFamiliesEx_default_charset(void) ...@@ -2998,13 +2998,13 @@ static void test_EnumFontFamiliesEx_default_charset(void)
{ {
struct enum_font_data efd; struct enum_font_data efd;
LOGFONTA target, enum_font; LOGFONTA target, enum_font;
DWORD ret; UINT acp;
HDC hdc; HDC hdc;
CHARSETINFO csi; CHARSETINFO csi;
ret = GetACP(); acp = GetACP();
if (!TranslateCharsetInfo(ULongToPtr(ret), &csi, TCI_SRCCODEPAGE)) { if (!TranslateCharsetInfo(ULongToPtr(acp), &csi, TCI_SRCCODEPAGE)) {
skip("TranslateCharsetInfo failed for code page %d.\n", ret); skip("TranslateCharsetInfo failed for code page %u.\n", acp);
return; return;
} }
...@@ -3018,6 +3018,10 @@ static void test_EnumFontFamiliesEx_default_charset(void) ...@@ -3018,6 +3018,10 @@ static void test_EnumFontFamiliesEx_default_charset(void)
skip("suitable font isn't found for charset %d.\n", enum_font.lfCharSet); skip("suitable font isn't found for charset %d.\n", enum_font.lfCharSet);
return; return;
} }
if (acp == 874 || acp == 1255 || acp == 1256) {
/* these codepage use complex script, expecting ANSI_CHARSET here. */
target.lfCharSet = ANSI_CHARSET;
}
efd.total = 0; efd.total = 0;
memset(&enum_font, 0, sizeof(enum_font)); memset(&enum_font, 0, sizeof(enum_font));
......
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