Mercurial > emacs
comparison src/w32fns.c @ 34284:3a21ff35392b
(xlfd_charset_of_font): Don't overwrite fontname
argument.
(w32_codepage_for_font): Rename CP_INVALID to CP_UNKNOWN.
(w32_list_fonts): Don't choke if pattern doesn't specify a
codepage.
author | Andrew Innes <andrewi@gnu.org> |
---|---|
date | Wed, 06 Dec 2000 15:54:02 +0000 |
parents | f1063cc498e4 |
children | 8318a4ea6764 |
comparison
equal
deleted
inserted
replaced
34283:335a6482fca0 | 34284:3a21ff35392b |
---|---|
5457 char * xlfd_charset_of_font (char * fontname) | 5457 char * xlfd_charset_of_font (char * fontname) |
5458 { | 5458 { |
5459 char *charset, *encoding; | 5459 char *charset, *encoding; |
5460 | 5460 |
5461 encoding = strrchr(fontname, '-'); | 5461 encoding = strrchr(fontname, '-'); |
5462 if (!encoding) | 5462 if (!encoding || encoding == fontname) |
5463 return NULL; | 5463 return NULL; |
5464 | 5464 |
5465 *encoding = 0; | 5465 charset = strrchr(encoding - 1, '-'); |
5466 charset = strrchr(fontname, '-'); | |
5467 *encoding = '-'; | |
5468 | 5466 |
5469 if (!charset || strcmp(charset, "-*-*") == 0) | 5467 if (!charset || strcmp(charset, "-*-*") == 0) |
5470 return NULL; | 5468 return NULL; |
5471 | 5469 |
5472 return charset + 1; | 5470 return charset + 1; |
6028 | 6026 |
6029 /* Extract charset part of font string. */ | 6027 /* Extract charset part of font string. */ |
6030 charset = xlfd_charset_of_font (fontname); | 6028 charset = xlfd_charset_of_font (fontname); |
6031 | 6029 |
6032 if (!charset) | 6030 if (!charset) |
6033 return CP_INVALID; | 6031 return CP_UNKNOWN; |
6034 | 6032 |
6035 charset_str = (char *) alloca (strlen (charset)); | 6033 charset_str = (char *) alloca (strlen (charset)); |
6036 strcpy (charset_str, charset); | 6034 strcpy (charset_str, charset); |
6037 | 6035 |
6038 /* Remove leading "*-". */ | 6036 /* Remove leading "*-". */ |
6049 *end = '\0'; | 6047 *end = '\0'; |
6050 } | 6048 } |
6051 | 6049 |
6052 entry = Fassoc (build_string(charset), Vw32_charset_info_alist); | 6050 entry = Fassoc (build_string(charset), Vw32_charset_info_alist); |
6053 if (NILP (entry)) | 6051 if (NILP (entry)) |
6054 return CP_INVALID; | 6052 return CP_UNKNOWN; |
6055 | 6053 |
6056 codepage = Fcdr (Fcdr (entry)); | 6054 codepage = Fcdr (Fcdr (entry)); |
6057 | 6055 |
6058 if (NILP (codepage)) | 6056 if (NILP (codepage)) |
6059 return CP_8BIT; | 6057 return CP_8BIT; |
6060 else if (XFASTINT (codepage) == XFASTINT (Qt)) | 6058 else if (XFASTINT (codepage) == XFASTINT (Qt)) |
6061 return CP_UNICODE; | 6059 return CP_UNICODE; |
6062 else if (INTEGERP (codepage)) | 6060 else if (INTEGERP (codepage)) |
6063 return XINT (codepage); | 6061 return XINT (codepage); |
6064 else | 6062 else |
6065 return CP_INVALID; | 6063 return CP_UNKNOWN; |
6066 } | 6064 } |
6067 | 6065 |
6068 | 6066 |
6069 BOOL | 6067 BOOL |
6070 w32_to_x_font (lplogfont, lpxstr, len, specific_charset) | 6068 w32_to_x_font (lplogfont, lpxstr, len, specific_charset) |
6703 | 6701 |
6704 /* Avoid expensive EnumFontFamilies functions if we are not | 6702 /* Avoid expensive EnumFontFamilies functions if we are not |
6705 going to be able to output one of these anyway. */ | 6703 going to be able to output one of these anyway. */ |
6706 codepage = w32_codepage_for_font (XSTRING (tpat)->data); | 6704 codepage = w32_codepage_for_font (XSTRING (tpat)->data); |
6707 if (codepage != CP_8BIT && codepage != CP_UNICODE | 6705 if (codepage != CP_8BIT && codepage != CP_UNICODE |
6708 && codepage != CP_DEFAULT && !IsValidCodePage(codepage)) | 6706 && codepage != CP_DEFAULT && codepage != CP_UNKNOWN |
6707 && !IsValidCodePage(codepage)) | |
6709 continue; | 6708 continue; |
6710 | 6709 |
6711 /* See if we cached the result for this particular query. | 6710 /* See if we cached the result for this particular query. |
6712 The cache is an alist of the form: | 6711 The cache is an alist of the form: |
6713 ((PATTERN (FONTNAME . WIDTH) ...) ...) | 6712 ((PATTERN (FONTNAME . WIDTH) ...) ...) |