diff options
| author | Andrew Innes | 2001-10-04 17:14:01 +0000 |
|---|---|---|
| committer | Andrew Innes | 2001-10-04 17:14:01 +0000 |
| commit | 8b77111c23f43bbca94b65e0ca0777708a930211 (patch) | |
| tree | fc1ddd0202a7a267c16d4fce67c373f00b6c0565 | |
| parent | 9c5becd89aee50c301f5a70a03e8728ce5400bb9 (diff) | |
| download | emacs-8b77111c23f43bbca94b65e0ca0777708a930211.tar.gz emacs-8b77111c23f43bbca94b65e0ca0777708a930211.zip | |
(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.
| -rw-r--r-- | src/w32fns.c | 73 |
1 files changed, 57 insertions, 16 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index a1c79a07831..5173a25fe93 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1646,7 +1646,7 @@ x_to_w32_color (colorname) | |||
| 1646 | 1646 | ||
| 1647 | if (isdigit (colorname[len - 1])) | 1647 | if (isdigit (colorname[len - 1])) |
| 1648 | { | 1648 | { |
| 1649 | char *ptr, *approx = alloca (len); | 1649 | char *ptr, *approx = alloca (len + 1); |
| 1650 | 1650 | ||
| 1651 | strcpy (approx, colorname); | 1651 | strcpy (approx, colorname); |
| 1652 | ptr = &approx[len - 1]; | 1652 | ptr = &approx[len - 1]; |
| @@ -5625,7 +5625,18 @@ w32_load_system_font (f,fontname,size) | |||
| 5625 | if (codepage == CP_UNICODE) | 5625 | if (codepage == CP_UNICODE) |
| 5626 | font->double_byte_p = 1; | 5626 | font->double_byte_p = 1; |
| 5627 | else | 5627 | else |
| 5628 | font->double_byte_p = GetFontLanguageInfo(hdc) & GCP_DBCS; | 5628 | { |
| 5629 | /* Unfortunately, some fonts (eg. MingLiU, a big5 ttf font) | ||
| 5630 | don't report themselves as double byte fonts, when | ||
| 5631 | patently they are. So instead of trusting | ||
| 5632 | GetFontLanguageInfo, we check the properties of the | ||
| 5633 | codepage directly, since that is ultimately what we are | ||
| 5634 | working from anyway. */ | ||
| 5635 | /* font->double_byte_p = GetFontLanguageInfo(hdc) & GCP_DBCS; */ | ||
| 5636 | CPINFO cpi = {0}; | ||
| 5637 | GetCPInfo (codepage, &cpi); | ||
| 5638 | font->double_byte_p = cpi.MaxCharSize > 1; | ||
| 5639 | } | ||
| 5629 | 5640 | ||
| 5630 | SelectObject (hdc, oldobj); | 5641 | SelectObject (hdc, oldobj); |
| 5631 | ReleaseDC (dpyinfo->root_window, hdc); | 5642 | ReleaseDC (dpyinfo->root_window, hdc); |
| @@ -5846,17 +5857,30 @@ x_to_w32_charset (lpcs) | |||
| 5846 | char * lpcs; | 5857 | char * lpcs; |
| 5847 | { | 5858 | { |
| 5848 | Lisp_Object this_entry, w32_charset; | 5859 | Lisp_Object this_entry, w32_charset; |
| 5860 | char *charset; | ||
| 5861 | int len = strlen (lpcs); | ||
| 5862 | |||
| 5863 | /* Support "*-#nnn" format for unknown charsets. */ | ||
| 5864 | if (strncmp (lpcs, "*-#", 3) == 0) | ||
| 5865 | return atoi (lpcs + 3); | ||
| 5866 | |||
| 5867 | /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */ | ||
| 5868 | charset = alloca (len + 1); | ||
| 5869 | strcpy (charset, lpcs); | ||
| 5870 | lpcs = strchr (charset, '*'); | ||
| 5871 | if (lpcs) | ||
| 5872 | *lpcs = 0; | ||
| 5849 | 5873 | ||
| 5850 | /* Look through w32-charset-info-alist for the character set. | 5874 | /* Look through w32-charset-info-alist for the character set. |
| 5851 | Format of each entry is | 5875 | Format of each entry is |
| 5852 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). | 5876 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). |
| 5853 | */ | 5877 | */ |
| 5854 | this_entry = Fassoc (build_string(lpcs), Vw32_charset_info_alist); | 5878 | this_entry = Fassoc (build_string(charset), Vw32_charset_info_alist); |
| 5855 | 5879 | ||
| 5856 | if (NILP(this_entry)) | 5880 | if (NILP(this_entry)) |
| 5857 | { | 5881 | { |
| 5858 | /* At startup, we want iso8859-1 fonts to come up properly. */ | 5882 | /* At startup, we want iso8859-1 fonts to come up properly. */ |
| 5859 | if (stricmp(lpcs, "iso8859-1") == 0) | 5883 | if (stricmp(charset, "iso8859-1") == 0) |
| 5860 | return ANSI_CHARSET; | 5884 | return ANSI_CHARSET; |
| 5861 | else | 5885 | else |
| 5862 | return DEFAULT_CHARSET; | 5886 | return DEFAULT_CHARSET; |
| @@ -6088,13 +6112,15 @@ w32_codepage_for_font (char *fontname) | |||
| 6088 | if (!charset) | 6112 | if (!charset) |
| 6089 | return CP_UNKNOWN; | 6113 | return CP_UNKNOWN; |
| 6090 | 6114 | ||
| 6091 | charset_str = (char *) alloca (strlen (charset)); | 6115 | charset_str = (char *) alloca (strlen (charset) + 1); |
| 6092 | strcpy (charset_str, charset); | 6116 | strcpy (charset_str, charset); |
| 6093 | 6117 | ||
| 6118 | #if 0 | ||
| 6094 | /* Remove leading "*-". */ | 6119 | /* Remove leading "*-". */ |
| 6095 | if (strncmp ("*-", charset_str, 2) == 0) | 6120 | if (strncmp ("*-", charset_str, 2) == 0) |
| 6096 | charset = charset_str + 2; | 6121 | charset = charset_str + 2; |
| 6097 | else | 6122 | else |
| 6123 | #endif | ||
| 6098 | charset = charset_str; | 6124 | charset = charset_str; |
| 6099 | 6125 | ||
| 6100 | /* Stop match at wildcard (including preceding '-'). */ | 6126 | /* Stop match at wildcard (including preceding '-'). */ |
| @@ -6250,20 +6276,33 @@ x_to_w32_font (lpxstr, lplogfont) | |||
| 6250 | { | 6276 | { |
| 6251 | int fields, tem; | 6277 | int fields, tem; |
| 6252 | char name[50], weight[20], slant, pitch, pixels[10], height[10], | 6278 | char name[50], weight[20], slant, pitch, pixels[10], height[10], |
| 6253 | width[10], resy[10], remainder[20]; | 6279 | width[10], resy[10], remainder[50]; |
| 6254 | char * encoding; | 6280 | char * encoding; |
| 6255 | int dpi = one_w32_display_info.resy; | 6281 | int dpi = one_w32_display_info.resy; |
| 6256 | 6282 | ||
| 6257 | fields = sscanf (lpxstr, | 6283 | fields = sscanf (lpxstr, |
| 6258 | "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%19s", | 6284 | "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%49s", |
| 6259 | name, weight, &slant, pixels, height, resy, &pitch, width, remainder); | 6285 | name, weight, &slant, pixels, height, resy, &pitch, width, remainder); |
| 6260 | if (fields == EOF) return (FALSE); | 6286 | if (fields == EOF) |
| 6261 | 6287 | return (FALSE); | |
| 6262 | /* If wildcards cover more than one field, we don't know which | 6288 | |
| 6263 | field is which, so don't fill any in. */ | 6289 | /* In the general case when wildcards cover more than one field, |
| 6264 | 6290 | we don't know which field is which, so don't fill any in. | |
| 6265 | if (fields < 9) | 6291 | However, we need to cope with this particular form, which is |
| 6266 | fields = 0; | 6292 | generated by font_list_1 (invoked by try_font_list): |
| 6293 | "-raster-6x10-*-gb2312*-*" | ||
| 6294 | and make sure to correctly parse the charset field. */ | ||
| 6295 | if (fields == 3) | ||
| 6296 | { | ||
| 6297 | fields = sscanf (lpxstr, | ||
| 6298 | "-%*[^-]-%49[^-]-*-%49s", | ||
| 6299 | name, remainder); | ||
| 6300 | } | ||
| 6301 | else if (fields < 9) | ||
| 6302 | { | ||
| 6303 | fields = 0; | ||
| 6304 | remainder[0] = 0; | ||
| 6305 | } | ||
| 6267 | 6306 | ||
| 6268 | if (fields > 0 && name[0] != '*') | 6307 | if (fields > 0 && name[0] != '*') |
| 6269 | { | 6308 | { |
| @@ -6331,9 +6370,11 @@ x_to_w32_font (lpxstr, lplogfont) | |||
| 6331 | remainder[len-1] = 0; | 6370 | remainder[len-1] = 0; |
| 6332 | } | 6371 | } |
| 6333 | encoding = remainder; | 6372 | encoding = remainder; |
| 6373 | #if 0 | ||
| 6334 | if (strncmp (encoding, "*-", 2) == 0) | 6374 | if (strncmp (encoding, "*-", 2) == 0) |
| 6335 | encoding += 2; | 6375 | encoding += 2; |
| 6336 | lplogfont->lfCharSet = x_to_w32_charset (fields > 0 ? encoding : ""); | 6376 | #endif |
| 6377 | lplogfont->lfCharSet = x_to_w32_charset (encoding); | ||
| 6337 | } | 6378 | } |
| 6338 | else | 6379 | else |
| 6339 | { | 6380 | { |
| @@ -6953,7 +6994,7 @@ w32_list_synthesized_fonts (f, pattern, size, max_names) | |||
| 6953 | 6994 | ||
| 6954 | full_pattn = XSTRING (pattern)->data; | 6995 | full_pattn = XSTRING (pattern)->data; |
| 6955 | 6996 | ||
| 6956 | pattn_part2 = alloca (XSTRING (pattern)->size); | 6997 | pattn_part2 = alloca (XSTRING (pattern)->size + 1); |
| 6957 | /* Allow some space for wildcard expansion. */ | 6998 | /* Allow some space for wildcard expansion. */ |
| 6958 | new_pattn = alloca (XSTRING (pattern)->size + 100); | 6999 | new_pattn = alloca (XSTRING (pattern)->size + 100); |
| 6959 | 7000 | ||