# HG changeset patch # User Andrew Innes # Date 1002215641 0 # Node ID 6192be04845982954f61cc40b08f27340e199be2 # Parent 99e89f7ad24e346770eb84e00b0c9f0dfa3457aa (x_to_w32_color): Fix argument to alloca. (w32_load_system_font): Don't believe what GetLanguageFontInfo says; query codepage info directly to determine if font is double byte. (x_to_w32_charset): Handle private format for unknown charsets. Handle wildcards in charset spec, by ignoring them. (w32_codepage_for_font): Fix argument to alloca. Don't remove "*-" prefix from charset. (x_to_w32_font): Enlarge remainder array for safety. Specifically handle the truncated font spec form constructed by font_list_1, so that we correctly identify the charset fields. Don't remove "*-" prefix from charset. (w32_list_synthesized_fonts): Fix argument to alloca. diff -r 99e89f7ad24e -r 6192be048459 src/w32fns.c --- a/src/w32fns.c Thu Oct 04 10:38:36 2001 +0000 +++ b/src/w32fns.c Thu Oct 04 17:14:01 2001 +0000 @@ -1646,7 +1646,7 @@ if (isdigit (colorname[len - 1])) { - char *ptr, *approx = alloca (len); + char *ptr, *approx = alloca (len + 1); strcpy (approx, colorname); ptr = &approx[len - 1]; @@ -5625,7 +5625,18 @@ if (codepage == CP_UNICODE) font->double_byte_p = 1; else - font->double_byte_p = GetFontLanguageInfo(hdc) & GCP_DBCS; + { + /* Unfortunately, some fonts (eg. MingLiU, a big5 ttf font) + don't report themselves as double byte fonts, when + patently they are. So instead of trusting + GetFontLanguageInfo, we check the properties of the + codepage directly, since that is ultimately what we are + working from anyway. */ + /* font->double_byte_p = GetFontLanguageInfo(hdc) & GCP_DBCS; */ + CPINFO cpi = {0}; + GetCPInfo (codepage, &cpi); + font->double_byte_p = cpi.MaxCharSize > 1; + } SelectObject (hdc, oldobj); ReleaseDC (dpyinfo->root_window, hdc); @@ -5846,17 +5857,30 @@ char * lpcs; { Lisp_Object this_entry, w32_charset; + char *charset; + int len = strlen (lpcs); + + /* Support "*-#nnn" format for unknown charsets. */ + if (strncmp (lpcs, "*-#", 3) == 0) + return atoi (lpcs + 3); + + /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */ + charset = alloca (len + 1); + strcpy (charset, lpcs); + lpcs = strchr (charset, '*'); + if (lpcs) + *lpcs = 0; /* Look through w32-charset-info-alist for the character set. Format of each entry is (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). */ - this_entry = Fassoc (build_string(lpcs), Vw32_charset_info_alist); + this_entry = Fassoc (build_string(charset), Vw32_charset_info_alist); if (NILP(this_entry)) { /* At startup, we want iso8859-1 fonts to come up properly. */ - if (stricmp(lpcs, "iso8859-1") == 0) + if (stricmp(charset, "iso8859-1") == 0) return ANSI_CHARSET; else return DEFAULT_CHARSET; @@ -6088,13 +6112,15 @@ if (!charset) return CP_UNKNOWN; - charset_str = (char *) alloca (strlen (charset)); + charset_str = (char *) alloca (strlen (charset) + 1); strcpy (charset_str, charset); +#if 0 /* Remove leading "*-". */ if (strncmp ("*-", charset_str, 2) == 0) charset = charset_str + 2; else +#endif charset = charset_str; /* Stop match at wildcard (including preceding '-'). */ @@ -6250,20 +6276,33 @@ { int fields, tem; char name[50], weight[20], slant, pitch, pixels[10], height[10], - width[10], resy[10], remainder[20]; + width[10], resy[10], remainder[50]; char * encoding; int dpi = one_w32_display_info.resy; fields = sscanf (lpxstr, - "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%19s", + "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%49s", name, weight, &slant, pixels, height, resy, &pitch, width, remainder); - if (fields == EOF) return (FALSE); - - /* If wildcards cover more than one field, we don't know which - field is which, so don't fill any in. */ - - if (fields < 9) - fields = 0; + if (fields == EOF) + return (FALSE); + + /* In the general case when wildcards cover more than one field, + we don't know which field is which, so don't fill any in. + However, we need to cope with this particular form, which is + generated by font_list_1 (invoked by try_font_list): + "-raster-6x10-*-gb2312*-*" + and make sure to correctly parse the charset field. */ + if (fields == 3) + { + fields = sscanf (lpxstr, + "-%*[^-]-%49[^-]-*-%49s", + name, remainder); + } + else if (fields < 9) + { + fields = 0; + remainder[0] = 0; + } if (fields > 0 && name[0] != '*') { @@ -6331,9 +6370,11 @@ remainder[len-1] = 0; } encoding = remainder; +#if 0 if (strncmp (encoding, "*-", 2) == 0) encoding += 2; - lplogfont->lfCharSet = x_to_w32_charset (fields > 0 ? encoding : ""); +#endif + lplogfont->lfCharSet = x_to_w32_charset (encoding); } else { @@ -6953,7 +6994,7 @@ full_pattn = XSTRING (pattern)->data; - pattn_part2 = alloca (XSTRING (pattern)->size); + pattn_part2 = alloca (XSTRING (pattern)->size + 1); /* Allow some space for wildcard expansion. */ new_pattn = alloca (XSTRING (pattern)->size + 100);