4791 |
fontp->name = (char *) xmalloc (strlen (fontname) + 1); |
fontp->name = (char *) xmalloc (strlen (fontname) + 1); |
4792 |
bcopy (fontname, fontp->name, strlen (fontname) + 1); |
bcopy (fontname, fontp->name, strlen (fontname) + 1); |
4793 |
|
|
4794 |
fontp->charset = charset_unicode; |
fontp->charset = -1; |
4795 |
charset = xlfd_charset_of_font (fontname); |
charset = xlfd_charset_of_font (fontname); |
4796 |
|
|
4797 |
/* Cache the W32 codepage for a font. This makes w32_encode_char |
/* Cache the W32 codepage for a font. This makes w32_encode_char |
4970 |
if (strncmp (lpcs, "*-#", 3) == 0) |
if (strncmp (lpcs, "*-#", 3) == 0) |
4971 |
return atoi (lpcs + 3); |
return atoi (lpcs + 3); |
4972 |
|
|
4973 |
|
/* All Windows fonts qualify as unicode. */ |
4974 |
|
if (!strncmp (lpcs, "iso10646", 8)) |
4975 |
|
return DEFAULT_CHARSET; |
4976 |
|
|
4977 |
/* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */ |
/* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */ |
4978 |
charset = alloca (len + 1); |
charset = alloca (len + 1); |
4979 |
strcpy (charset, lpcs); |
strcpy (charset, lpcs); |
4980 |
lpcs = strchr (charset, '*'); |
lpcs = strchr (charset, '*'); |
4981 |
if (lpcs) |
if (lpcs) |
4982 |
*lpcs = 0; |
*lpcs = '\0'; |
4983 |
|
|
4984 |
/* Look through w32-charset-info-alist for the character set. |
/* Look through w32-charset-info-alist for the character set. |
4985 |
Format of each entry is |
Format of each entry is |
5047 |
|
|
5048 |
|
|
5049 |
static char * |
static char * |
5050 |
w32_to_x_charset (fncharset) |
w32_to_x_charset (fncharset, matching) |
5051 |
int fncharset; |
int fncharset; |
5052 |
|
char *matching; |
5053 |
{ |
{ |
5054 |
static char buf[32]; |
static char buf[32]; |
5055 |
Lisp_Object charset_type; |
Lisp_Object charset_type; |
5056 |
|
int match_len = 0; |
5057 |
|
|
5058 |
|
if (matching) |
5059 |
|
{ |
5060 |
|
/* If fully specified, accept it as it is. Otherwise use a |
5061 |
|
substring match. */ |
5062 |
|
char *wildcard = strchr (matching, '*'); |
5063 |
|
if (wildcard) |
5064 |
|
*wildcard = '\0'; |
5065 |
|
else if (strchr (matching, '-')) |
5066 |
|
return matching; |
5067 |
|
|
5068 |
|
match_len = strlen (matching); |
5069 |
|
} |
5070 |
|
|
5071 |
switch (fncharset) |
switch (fncharset) |
5072 |
{ |
{ |
5151 |
{ |
{ |
5152 |
Lisp_Object rest; |
Lisp_Object rest; |
5153 |
char * best_match = NULL; |
char * best_match = NULL; |
5154 |
|
int matching_found = 0; |
5155 |
|
|
5156 |
/* Look through w32-charset-info-alist for the character set. |
/* Look through w32-charset-info-alist for the character set. |
5157 |
Prefer ISO codepages, and prefer lower numbers in the ISO |
Prefer ISO codepages, and prefer lower numbers in the ISO |
5187 |
/* If we don't have a match already, then this is the |
/* If we don't have a match already, then this is the |
5188 |
best. */ |
best. */ |
5189 |
if (!best_match) |
if (!best_match) |
5190 |
best_match = x_charset; |
{ |
5191 |
/* If this is an ISO codepage, and the best so far isn't, |
best_match = x_charset; |
5192 |
then this is better. */ |
if (matching && !strnicmp (x_charset, matching, match_len)) |
5193 |
else if (strnicmp (best_match, "iso", 3) != 0 |
matching_found = 1; |
5194 |
&& strnicmp (x_charset, "iso", 3) == 0) |
} |
5195 |
best_match = x_charset; |
/* If we already found a match for MATCHING, then |
5196 |
|
only consider other matches. */ |
5197 |
|
else if (matching_found |
5198 |
|
&& strnicmp (x_charset, matching, match_len)) |
5199 |
|
continue; |
5200 |
|
/* If this matches what we want, and the best so far doesn't, |
5201 |
|
then this is better. */ |
5202 |
|
else if (!matching_found && matching |
5203 |
|
&& !strnicmp (x_charset, matching, match_len)) |
5204 |
|
{ |
5205 |
|
best_match = x_charset; |
5206 |
|
matching_found = 1; |
5207 |
|
} |
5208 |
|
/* If this is fully specified, and the best so far isn't, |
5209 |
|
then this is better. */ |
5210 |
|
else if ((!strchr (best_match, '-') && strchr (x_charset, '-')) |
5211 |
|
/* If this is an ISO codepage, and the best so far isn't, |
5212 |
|
then this is better, but only if it fully specifies the |
5213 |
|
encoding. */ |
5214 |
|
|| (strnicmp (best_match, "iso", 3) != 0 |
5215 |
|
&& strnicmp (x_charset, "iso", 3) == 0 |
5216 |
|
&& strchr (x_charset, '-'))) |
5217 |
|
best_match = x_charset; |
5218 |
/* If both are ISO8859 codepages, choose the one with the |
/* If both are ISO8859 codepages, choose the one with the |
5219 |
lowest number in the encoding field. */ |
lowest number in the encoding field. */ |
5220 |
else if (strnicmp (best_match, "iso8859-", 8) == 0 |
else if (strnicmp (best_match, "iso8859-", 8) == 0 |
5235 |
return buf; |
return buf; |
5236 |
} |
} |
5237 |
|
|
5238 |
strncpy(buf, best_match, 31); |
strncpy (buf, best_match, 31); |
5239 |
|
/* If the charset is not fully specified, put -0 on the end. */ |
5240 |
|
if (!strchr (best_match, '-')) |
5241 |
|
{ |
5242 |
|
int pos = strlen (best_match); |
5243 |
|
/* Charset specifiers shouldn't be very long. If it is a made |
5244 |
|
up one, truncating it should not do any harm since it isn't |
5245 |
|
recognized anyway. */ |
5246 |
|
if (pos > 29) |
5247 |
|
pos = 29; |
5248 |
|
strcpy (buf + pos, "-0"); |
5249 |
|
} |
5250 |
buf[31] = '\0'; |
buf[31] = '\0'; |
5251 |
return buf; |
return buf; |
5252 |
} |
} |
5346 |
{ |
{ |
5347 |
Lisp_Object rest; |
Lisp_Object rest; |
5348 |
/* Look through w32-charset-info-alist for the character set. |
/* Look through w32-charset-info-alist for the character set. |
5349 |
Only return charsets for codepages which are installed. |
Only return fully specified charsets for codepages which are |
5350 |
|
installed. |
5351 |
|
|
5352 |
Format of each entry in Vw32_charset_info_alist is |
Format of each entry in Vw32_charset_info_alist is |
5353 |
(CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). |
(CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). |
5370 |
w32_charset = XCAR (XCDR (this_entry)); |
w32_charset = XCAR (XCDR (this_entry)); |
5371 |
codepage = XCDR (XCDR (this_entry)); |
codepage = XCDR (XCDR (this_entry)); |
5372 |
|
|
5373 |
|
if (!strchr (SDATA (x_charset), '-')) |
5374 |
|
continue; |
5375 |
|
|
5376 |
/* Look for Same charset and a valid codepage (or non-int |
/* Look for Same charset and a valid codepage (or non-int |
5377 |
which means ignore). */ |
which means ignore). */ |
5378 |
if (w32_charset == charset_type |
if (w32_charset == charset_type |
5403 |
Lisp_Object codepage, entry; |
Lisp_Object codepage, entry; |
5404 |
char *charset_str, *charset, *end; |
char *charset_str, *charset, *end; |
5405 |
|
|
|
if (NILP (Vw32_charset_info_alist)) |
|
|
return CP_DEFAULT; |
|
|
|
|
5406 |
/* Extract charset part of font string. */ |
/* Extract charset part of font string. */ |
5407 |
charset = xlfd_charset_of_font (fontname); |
charset = xlfd_charset_of_font (fontname); |
5408 |
|
|
5428 |
*end = '\0'; |
*end = '\0'; |
5429 |
} |
} |
5430 |
|
|
5431 |
|
if (!strcmp (charset, "iso10646")) |
5432 |
|
return CP_UNICODE; |
5433 |
|
|
5434 |
|
if (NILP (Vw32_charset_info_alist)) |
5435 |
|
return CP_DEFAULT; |
5436 |
|
|
5437 |
entry = Fassoc (build_string(charset), Vw32_charset_info_alist); |
entry = Fassoc (build_string(charset), Vw32_charset_info_alist); |
5438 |
if (NILP (entry)) |
if (NILP (entry)) |
5439 |
return CP_UNKNOWN; |
return CP_UNKNOWN; |
5534 |
((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) |
((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) |
5535 |
? 'p' : 'c', /* spacing */ |
? 'p' : 'c', /* spacing */ |
5536 |
width_pixels, /* avg width */ |
width_pixels, /* avg width */ |
5537 |
specific_charset ? specific_charset |
w32_to_x_charset (lplogfont->lfCharSet, specific_charset) |
|
: w32_to_x_charset (lplogfont->lfCharSet) |
|
5538 |
/* charset registry and encoding */ |
/* charset registry and encoding */ |
5539 |
); |
); |
5540 |
|
|
6005 |
if (charset |
if (charset |
6006 |
&& strncmp (charset, "*-*", 3) != 0 |
&& strncmp (charset, "*-*", 3) != 0 |
6007 |
&& lpef->logfont.lfCharSet == DEFAULT_CHARSET |
&& lpef->logfont.lfCharSet == DEFAULT_CHARSET |
6008 |
&& strcmp (charset, w32_to_x_charset (DEFAULT_CHARSET)) != 0) |
&& strcmp (charset, w32_to_x_charset (DEFAULT_CHARSET, NULL)) != 0) |
6009 |
return 1; |
return 1; |
6010 |
} |
} |
6011 |
|
|
6012 |
if (charset) |
if (charset) |
6013 |
charset_list = Fcons (build_string (charset), Qnil); |
charset_list = Fcons (build_string (charset), Qnil); |
6014 |
else |
else |
6015 |
charset_list = w32_to_all_x_charsets (lplf->elfLogFont.lfCharSet); |
/* Always prefer unicode. */ |
6016 |
|
charset_list |
6017 |
|
= Fcons (build_string ("iso10646-1"), |
6018 |
|
w32_to_all_x_charsets (lplf->elfLogFont.lfCharSet)); |
6019 |
|
|
6020 |
/* Loop through the charsets. */ |
/* Loop through the charsets. */ |
6021 |
for ( ; CONSP (charset_list); charset_list = Fcdr (charset_list)) |
for ( ; CONSP (charset_list); charset_list = Fcdr (charset_list)) |
6023 |
Lisp_Object this_charset = Fcar (charset_list); |
Lisp_Object this_charset = Fcar (charset_list); |
6024 |
charset = SDATA (this_charset); |
charset = SDATA (this_charset); |
6025 |
|
|
6026 |
|
enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont), |
6027 |
|
charset, width); |
6028 |
|
|
6029 |
/* List bold and italic variations if w32-enable-synthesized-fonts |
/* List bold and italic variations if w32-enable-synthesized-fonts |
6030 |
is non-nil and this is a plain font. */ |
is non-nil and this is a plain font. */ |
6031 |
if (w32_enable_synthesized_fonts |
if (w32_enable_synthesized_fonts |
6032 |
&& lplf->elfLogFont.lfWeight == FW_NORMAL |
&& lplf->elfLogFont.lfWeight == FW_NORMAL |
6033 |
&& lplf->elfLogFont.lfItalic == FALSE) |
&& lplf->elfLogFont.lfItalic == FALSE) |
6034 |
{ |
{ |
|
enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont), |
|
|
charset, width); |
|
6035 |
/* bold. */ |
/* bold. */ |
6036 |
lplf->elfLogFont.lfWeight = FW_BOLD; |
lplf->elfLogFont.lfWeight = FW_BOLD; |
6037 |
enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont), |
enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont), |
6045 |
enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont), |
enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont), |
6046 |
charset, width); |
charset, width); |
6047 |
} |
} |
|
else |
|
|
enum_font_maybe_add_to_list (lpef, &(lplf->elfLogFont), |
|
|
charset, width); |
|
6048 |
} |
} |
6049 |
} |
} |
6050 |
|
|