diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 33 | ||||
| -rw-r--r-- | src/w32fns.c | 883 | ||||
| -rw-r--r-- | src/w32font.c | 351 |
3 files changed, 377 insertions, 890 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index bd4ae006704..85931f7abd1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,28 @@ | |||
| 1 | 2008-06-27 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * w32fns.c (x_to_w32_font, w32_to_x_font, x_to_w32_weight) | ||
| 4 | (w32_to_x_weight, w32_to_all_x_charsets): Remove obsolete functions. | ||
| 5 | (w32_to_x_charset, x_to_w32_charset) | ||
| 6 | (Qw32_charset_ansi, Qw32_charset_symbol, Qw32_charset_default) | ||
| 7 | (Qw32_charset_shiftjis, Qw32_charset_hangeul, Qw32_charset_johab) | ||
| 8 | (Qw32_charset_chinesebig5, Qw32_charset_gb2312, Qw32_charset_oem) | ||
| 9 | (Qw32_charset_easteurope, Qw32_charset_turkish, Qw32_charset_baltic) | ||
| 10 | (Qw32_charset_russian, Qw32_charset_arabic, Qw32_charset_greek) | ||
| 11 | (Qw32_charset_hebrew, Qw32_charset_vietnamese, Qw32_charset_thai) | ||
| 12 | (Qw32_charset_mac, Vw32_charset_info_alist): Move to w32font.c. | ||
| 13 | (Qw32_charset_unicode): Remove. | ||
| 14 | (syms_of_w32fns): Update for above changes. | ||
| 15 | |||
| 16 | * w32font.c (w32_to_x_charset, x_to_w32_charset) | ||
| 17 | (Qw32_charset_ansi, Qw32_charset_symbol, Qw32_charset_default) | ||
| 18 | (Qw32_charset_shiftjis, Qw32_charset_hangeul, Qw32_charset_johab) | ||
| 19 | (Qw32_charset_chinesebig5, Qw32_charset_gb2312, Qw32_charset_oem) | ||
| 20 | (Qw32_charset_easteurope, Qw32_charset_turkish, Qw32_charset_baltic) | ||
| 21 | (Qw32_charset_russian, Qw32_charset_arabic, Qw32_charset_greek) | ||
| 22 | (Qw32_charset_hebrew, Qw32_charset_vietnamese, Qw32_charset_thai) | ||
| 23 | (Qw32_charset_mac, Vw32_charset_info_alist): Move from w32fns.c. | ||
| 24 | (syms_of_w32font): Update for above changes. | ||
| 25 | |||
| 1 | 2008-06-27 Dan Nicolaescu <dann@ics.uci.edu> | 26 | 2008-06-27 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 27 | ||
| 3 | * s/usg5-4.h: Fix previous change: keep the correct branch of a | 28 | * s/usg5-4.h: Fix previous change: keep the correct branch of a |
| @@ -20,12 +45,12 @@ | |||
| 20 | 45 | ||
| 21 | * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros. | 46 | * w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros. |
| 22 | 47 | ||
| 23 | * w32term.c (x_draw_glyph_string_foreground): | 48 | * w32term.c (x_draw_glyph_string_foreground) |
| 24 | (x_draw_composite_glyph_string_foreground): Sync with xterm.c. | 49 | (x_draw_composite_glyph_string_foreground): Sync with xterm.c. |
| 25 | Use FONT_HANDLE macro. | 50 | Use FONT_HANDLE macro. |
| 26 | (x_draw_glyph_string): Use FONT_TEXTMETRIC macro. | 51 | (x_draw_glyph_string): Use FONT_TEXTMETRIC macro. |
| 27 | 52 | ||
| 28 | * w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape): | 53 | * w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape) |
| 29 | (uniscribe_encode_char): Use FONT_HANDLE macro. | 54 | (uniscribe_encode_char): Use FONT_HANDLE macro. |
| 30 | 55 | ||
| 31 | * w32font.c (Fx_select_font): Use FONT_HANDLE macro. | 56 | * w32font.c (Fx_select_font): Use FONT_HANDLE macro. |
| @@ -65,10 +90,10 @@ | |||
| 65 | (w32font_open_internal): Remove compat code. Set new hfont member. | 90 | (w32font_open_internal): Remove compat code. Set new hfont member. |
| 66 | (Fx_select_font): Use new hfont member. | 91 | (Fx_select_font): Use new hfont member. |
| 67 | 92 | ||
| 68 | * w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape): | 93 | * w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape) |
| 69 | (uniscribe_encode_char): Use new hfont member. | 94 | (uniscribe_encode_char): Use new hfont member. |
| 70 | 95 | ||
| 71 | * w32term.c (x_draw_glyph_string_foreground): | 96 | * w32term.c (x_draw_glyph_string_foreground) |
| 72 | (x_draw_composite_glyph_string_foreground): Use new hfont member. | 97 | (x_draw_composite_glyph_string_foreground): Use new hfont member. |
| 73 | (x_draw_glyph_string): Use metrics in w32font_info. | 98 | (x_draw_glyph_string): Use metrics in w32font_info. |
| 74 | 99 | ||
diff --git a/src/w32fns.c b/src/w32fns.c index df229789d55..2a042717ac1 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -191,14 +191,6 @@ static int w32_strict_fontnames; | |||
| 191 | indicates there is an update region. */ | 191 | indicates there is an update region. */ |
| 192 | static int w32_strict_painting; | 192 | static int w32_strict_painting; |
| 193 | 193 | ||
| 194 | /* Associative list linking character set strings to Windows codepages. */ | ||
| 195 | static Lisp_Object Vw32_charset_info_alist; | ||
| 196 | |||
| 197 | /* VIETNAMESE_CHARSET is not defined in some versions of MSVC. */ | ||
| 198 | #ifndef VIETNAMESE_CHARSET | ||
| 199 | #define VIETNAMESE_CHARSET 163 | ||
| 200 | #endif | ||
| 201 | |||
| 202 | Lisp_Object Qnone; | 194 | Lisp_Object Qnone; |
| 203 | Lisp_Object Qsuppress_icon; | 195 | Lisp_Object Qsuppress_icon; |
| 204 | Lisp_Object Qundefined_color; | 196 | Lisp_Object Qundefined_color; |
| @@ -212,35 +204,6 @@ Lisp_Object Qctrl; | |||
| 212 | Lisp_Object Qcontrol; | 204 | Lisp_Object Qcontrol; |
| 213 | Lisp_Object Qshift; | 205 | Lisp_Object Qshift; |
| 214 | 206 | ||
| 215 | Lisp_Object Qw32_charset_ansi; | ||
| 216 | Lisp_Object Qw32_charset_default; | ||
| 217 | Lisp_Object Qw32_charset_symbol; | ||
| 218 | Lisp_Object Qw32_charset_shiftjis; | ||
| 219 | Lisp_Object Qw32_charset_hangeul; | ||
| 220 | Lisp_Object Qw32_charset_gb2312; | ||
| 221 | Lisp_Object Qw32_charset_chinesebig5; | ||
| 222 | Lisp_Object Qw32_charset_oem; | ||
| 223 | |||
| 224 | #ifndef JOHAB_CHARSET | ||
| 225 | #define JOHAB_CHARSET 130 | ||
| 226 | #endif | ||
| 227 | #ifdef JOHAB_CHARSET | ||
| 228 | Lisp_Object Qw32_charset_easteurope; | ||
| 229 | Lisp_Object Qw32_charset_turkish; | ||
| 230 | Lisp_Object Qw32_charset_baltic; | ||
| 231 | Lisp_Object Qw32_charset_russian; | ||
| 232 | Lisp_Object Qw32_charset_arabic; | ||
| 233 | Lisp_Object Qw32_charset_greek; | ||
| 234 | Lisp_Object Qw32_charset_hebrew; | ||
| 235 | Lisp_Object Qw32_charset_vietnamese; | ||
| 236 | Lisp_Object Qw32_charset_thai; | ||
| 237 | Lisp_Object Qw32_charset_johab; | ||
| 238 | Lisp_Object Qw32_charset_mac; | ||
| 239 | #endif | ||
| 240 | |||
| 241 | #ifdef UNICODE_CHARSET | ||
| 242 | Lisp_Object Qw32_charset_unicode; | ||
| 243 | #endif | ||
| 244 | 207 | ||
| 245 | /* The ANSI codepage. */ | 208 | /* The ANSI codepage. */ |
| 246 | int w32_ansi_code_page; | 209 | int w32_ansi_code_page; |
| @@ -4644,789 +4607,6 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, | |||
| 4644 | } | 4607 | } |
| 4645 | 4608 | ||
| 4646 | 4609 | ||
| 4647 | /* The font conversion stuff between x and w32 */ | ||
| 4648 | |||
| 4649 | /* X font string is as follows (from faces.el) | ||
| 4650 | * (let ((- "[-?]") | ||
| 4651 | * (foundry "[^-]+") | ||
| 4652 | * (family "[^-]+") | ||
| 4653 | * (weight "\\(bold\\|demibold\\|medium\\)") ; 1 | ||
| 4654 | * (weight\? "\\([^-]*\\)") ; 1 | ||
| 4655 | * (slant "\\([ior]\\)") ; 2 | ||
| 4656 | * (slant\? "\\([^-]?\\)") ; 2 | ||
| 4657 | * (swidth "\\([^-]*\\)") ; 3 | ||
| 4658 | * (adstyle "[^-]*") ; 4 | ||
| 4659 | * (pixelsize "[0-9]+") | ||
| 4660 | * (pointsize "[0-9][0-9]+") | ||
| 4661 | * (resx "[0-9][0-9]+") | ||
| 4662 | * (resy "[0-9][0-9]+") | ||
| 4663 | * (spacing "[cmp?*]") | ||
| 4664 | * (avgwidth "[0-9]+") | ||
| 4665 | * (registry "[^-]+") | ||
| 4666 | * (encoding "[^-]+") | ||
| 4667 | * ) | ||
| 4668 | */ | ||
| 4669 | |||
| 4670 | static LONG | ||
| 4671 | x_to_w32_weight (lpw) | ||
| 4672 | char * lpw; | ||
| 4673 | { | ||
| 4674 | if (!lpw) return (FW_DONTCARE); | ||
| 4675 | |||
| 4676 | if (xstrcasecmp (lpw, "heavy") == 0) return FW_HEAVY; | ||
| 4677 | else if (xstrcasecmp (lpw, "extrabold") == 0) return FW_EXTRABOLD; | ||
| 4678 | else if (xstrcasecmp (lpw, "bold") == 0) return FW_BOLD; | ||
| 4679 | else if (xstrcasecmp (lpw, "demibold") == 0) return FW_SEMIBOLD; | ||
| 4680 | else if (xstrcasecmp (lpw, "semibold") == 0) return FW_SEMIBOLD; | ||
| 4681 | else if (xstrcasecmp (lpw, "medium") == 0) return FW_MEDIUM; | ||
| 4682 | else if (xstrcasecmp (lpw, "normal") == 0) return FW_NORMAL; | ||
| 4683 | else if (xstrcasecmp (lpw, "light") == 0) return FW_LIGHT; | ||
| 4684 | else if (xstrcasecmp (lpw, "extralight") == 0) return FW_EXTRALIGHT; | ||
| 4685 | else if (xstrcasecmp (lpw, "thin") == 0) return FW_THIN; | ||
| 4686 | else | ||
| 4687 | return FW_DONTCARE; | ||
| 4688 | } | ||
| 4689 | |||
| 4690 | |||
| 4691 | static char * | ||
| 4692 | w32_to_x_weight (fnweight) | ||
| 4693 | int fnweight; | ||
| 4694 | { | ||
| 4695 | if (fnweight >= FW_HEAVY) return "heavy"; | ||
| 4696 | if (fnweight >= FW_EXTRABOLD) return "extrabold"; | ||
| 4697 | if (fnweight >= FW_BOLD) return "bold"; | ||
| 4698 | if (fnweight >= FW_SEMIBOLD) return "demibold"; | ||
| 4699 | if (fnweight >= FW_MEDIUM) return "medium"; | ||
| 4700 | if (fnweight >= FW_NORMAL) return "normal"; | ||
| 4701 | if (fnweight >= FW_LIGHT) return "light"; | ||
| 4702 | if (fnweight >= FW_EXTRALIGHT) return "extralight"; | ||
| 4703 | if (fnweight >= FW_THIN) return "thin"; | ||
| 4704 | else | ||
| 4705 | return "*"; | ||
| 4706 | } | ||
| 4707 | |||
| 4708 | LONG | ||
| 4709 | x_to_w32_charset (lpcs) | ||
| 4710 | char * lpcs; | ||
| 4711 | { | ||
| 4712 | Lisp_Object this_entry, w32_charset; | ||
| 4713 | char *charset; | ||
| 4714 | int len = strlen (lpcs); | ||
| 4715 | |||
| 4716 | /* Support "*-#nnn" format for unknown charsets. */ | ||
| 4717 | if (strncmp (lpcs, "*-#", 3) == 0) | ||
| 4718 | return atoi (lpcs + 3); | ||
| 4719 | |||
| 4720 | /* All Windows fonts qualify as unicode. */ | ||
| 4721 | if (!strncmp (lpcs, "iso10646", 8)) | ||
| 4722 | return DEFAULT_CHARSET; | ||
| 4723 | |||
| 4724 | /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */ | ||
| 4725 | charset = alloca (len + 1); | ||
| 4726 | strcpy (charset, lpcs); | ||
| 4727 | lpcs = strchr (charset, '*'); | ||
| 4728 | if (lpcs) | ||
| 4729 | *lpcs = '\0'; | ||
| 4730 | |||
| 4731 | /* Look through w32-charset-info-alist for the character set. | ||
| 4732 | Format of each entry is | ||
| 4733 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). | ||
| 4734 | */ | ||
| 4735 | this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist); | ||
| 4736 | |||
| 4737 | if (NILP (this_entry)) | ||
| 4738 | { | ||
| 4739 | /* At startup, we want iso8859-1 fonts to come up properly. */ | ||
| 4740 | if (xstrcasecmp (charset, "iso8859-1") == 0) | ||
| 4741 | return ANSI_CHARSET; | ||
| 4742 | else | ||
| 4743 | return DEFAULT_CHARSET; | ||
| 4744 | } | ||
| 4745 | |||
| 4746 | w32_charset = Fcar (Fcdr (this_entry)); | ||
| 4747 | |||
| 4748 | /* Translate Lisp symbol to number. */ | ||
| 4749 | if (EQ (w32_charset, Qw32_charset_ansi)) | ||
| 4750 | return ANSI_CHARSET; | ||
| 4751 | if (EQ (w32_charset, Qw32_charset_symbol)) | ||
| 4752 | return SYMBOL_CHARSET; | ||
| 4753 | if (EQ (w32_charset, Qw32_charset_shiftjis)) | ||
| 4754 | return SHIFTJIS_CHARSET; | ||
| 4755 | if (EQ (w32_charset, Qw32_charset_hangeul)) | ||
| 4756 | return HANGEUL_CHARSET; | ||
| 4757 | if (EQ (w32_charset, Qw32_charset_chinesebig5)) | ||
| 4758 | return CHINESEBIG5_CHARSET; | ||
| 4759 | if (EQ (w32_charset, Qw32_charset_gb2312)) | ||
| 4760 | return GB2312_CHARSET; | ||
| 4761 | if (EQ (w32_charset, Qw32_charset_oem)) | ||
| 4762 | return OEM_CHARSET; | ||
| 4763 | #ifdef JOHAB_CHARSET | ||
| 4764 | if (EQ (w32_charset, Qw32_charset_johab)) | ||
| 4765 | return JOHAB_CHARSET; | ||
| 4766 | if (EQ (w32_charset, Qw32_charset_easteurope)) | ||
| 4767 | return EASTEUROPE_CHARSET; | ||
| 4768 | if (EQ (w32_charset, Qw32_charset_turkish)) | ||
| 4769 | return TURKISH_CHARSET; | ||
| 4770 | if (EQ (w32_charset, Qw32_charset_baltic)) | ||
| 4771 | return BALTIC_CHARSET; | ||
| 4772 | if (EQ (w32_charset, Qw32_charset_russian)) | ||
| 4773 | return RUSSIAN_CHARSET; | ||
| 4774 | if (EQ (w32_charset, Qw32_charset_arabic)) | ||
| 4775 | return ARABIC_CHARSET; | ||
| 4776 | if (EQ (w32_charset, Qw32_charset_greek)) | ||
| 4777 | return GREEK_CHARSET; | ||
| 4778 | if (EQ (w32_charset, Qw32_charset_hebrew)) | ||
| 4779 | return HEBREW_CHARSET; | ||
| 4780 | if (EQ (w32_charset, Qw32_charset_vietnamese)) | ||
| 4781 | return VIETNAMESE_CHARSET; | ||
| 4782 | if (EQ (w32_charset, Qw32_charset_thai)) | ||
| 4783 | return THAI_CHARSET; | ||
| 4784 | if (EQ (w32_charset, Qw32_charset_mac)) | ||
| 4785 | return MAC_CHARSET; | ||
| 4786 | #endif /* JOHAB_CHARSET */ | ||
| 4787 | #ifdef UNICODE_CHARSET | ||
| 4788 | if (EQ (w32_charset, Qw32_charset_unicode)) | ||
| 4789 | return UNICODE_CHARSET; | ||
| 4790 | #endif | ||
| 4791 | |||
| 4792 | return DEFAULT_CHARSET; | ||
| 4793 | } | ||
| 4794 | |||
| 4795 | |||
| 4796 | char * | ||
| 4797 | w32_to_x_charset (fncharset, matching) | ||
| 4798 | int fncharset; | ||
| 4799 | char *matching; | ||
| 4800 | { | ||
| 4801 | static char buf[32]; | ||
| 4802 | Lisp_Object charset_type; | ||
| 4803 | int match_len = 0; | ||
| 4804 | |||
| 4805 | if (matching) | ||
| 4806 | { | ||
| 4807 | /* If fully specified, accept it as it is. Otherwise use a | ||
| 4808 | substring match. */ | ||
| 4809 | char *wildcard = strchr (matching, '*'); | ||
| 4810 | if (wildcard) | ||
| 4811 | *wildcard = '\0'; | ||
| 4812 | else if (strchr (matching, '-')) | ||
| 4813 | return matching; | ||
| 4814 | |||
| 4815 | match_len = strlen (matching); | ||
| 4816 | } | ||
| 4817 | |||
| 4818 | switch (fncharset) | ||
| 4819 | { | ||
| 4820 | case ANSI_CHARSET: | ||
| 4821 | /* Handle startup case of w32-charset-info-alist not | ||
| 4822 | being set up yet. */ | ||
| 4823 | if (NILP (Vw32_charset_info_alist)) | ||
| 4824 | return "iso8859-1"; | ||
| 4825 | charset_type = Qw32_charset_ansi; | ||
| 4826 | break; | ||
| 4827 | case DEFAULT_CHARSET: | ||
| 4828 | charset_type = Qw32_charset_default; | ||
| 4829 | break; | ||
| 4830 | case SYMBOL_CHARSET: | ||
| 4831 | charset_type = Qw32_charset_symbol; | ||
| 4832 | break; | ||
| 4833 | case SHIFTJIS_CHARSET: | ||
| 4834 | charset_type = Qw32_charset_shiftjis; | ||
| 4835 | break; | ||
| 4836 | case HANGEUL_CHARSET: | ||
| 4837 | charset_type = Qw32_charset_hangeul; | ||
| 4838 | break; | ||
| 4839 | case GB2312_CHARSET: | ||
| 4840 | charset_type = Qw32_charset_gb2312; | ||
| 4841 | break; | ||
| 4842 | case CHINESEBIG5_CHARSET: | ||
| 4843 | charset_type = Qw32_charset_chinesebig5; | ||
| 4844 | break; | ||
| 4845 | case OEM_CHARSET: | ||
| 4846 | charset_type = Qw32_charset_oem; | ||
| 4847 | break; | ||
| 4848 | |||
| 4849 | /* More recent versions of Windows (95 and NT4.0) define more | ||
| 4850 | character sets. */ | ||
| 4851 | #ifdef EASTEUROPE_CHARSET | ||
| 4852 | case EASTEUROPE_CHARSET: | ||
| 4853 | charset_type = Qw32_charset_easteurope; | ||
| 4854 | break; | ||
| 4855 | case TURKISH_CHARSET: | ||
| 4856 | charset_type = Qw32_charset_turkish; | ||
| 4857 | break; | ||
| 4858 | case BALTIC_CHARSET: | ||
| 4859 | charset_type = Qw32_charset_baltic; | ||
| 4860 | break; | ||
| 4861 | case RUSSIAN_CHARSET: | ||
| 4862 | charset_type = Qw32_charset_russian; | ||
| 4863 | break; | ||
| 4864 | case ARABIC_CHARSET: | ||
| 4865 | charset_type = Qw32_charset_arabic; | ||
| 4866 | break; | ||
| 4867 | case GREEK_CHARSET: | ||
| 4868 | charset_type = Qw32_charset_greek; | ||
| 4869 | break; | ||
| 4870 | case HEBREW_CHARSET: | ||
| 4871 | charset_type = Qw32_charset_hebrew; | ||
| 4872 | break; | ||
| 4873 | case VIETNAMESE_CHARSET: | ||
| 4874 | charset_type = Qw32_charset_vietnamese; | ||
| 4875 | break; | ||
| 4876 | case THAI_CHARSET: | ||
| 4877 | charset_type = Qw32_charset_thai; | ||
| 4878 | break; | ||
| 4879 | case MAC_CHARSET: | ||
| 4880 | charset_type = Qw32_charset_mac; | ||
| 4881 | break; | ||
| 4882 | case JOHAB_CHARSET: | ||
| 4883 | charset_type = Qw32_charset_johab; | ||
| 4884 | break; | ||
| 4885 | #endif | ||
| 4886 | |||
| 4887 | #ifdef UNICODE_CHARSET | ||
| 4888 | case UNICODE_CHARSET: | ||
| 4889 | charset_type = Qw32_charset_unicode; | ||
| 4890 | break; | ||
| 4891 | #endif | ||
| 4892 | default: | ||
| 4893 | /* Encode numerical value of unknown charset. */ | ||
| 4894 | sprintf (buf, "*-#%u", fncharset); | ||
| 4895 | return buf; | ||
| 4896 | } | ||
| 4897 | |||
| 4898 | { | ||
| 4899 | Lisp_Object rest; | ||
| 4900 | char * best_match = NULL; | ||
| 4901 | int matching_found = 0; | ||
| 4902 | |||
| 4903 | /* Look through w32-charset-info-alist for the character set. | ||
| 4904 | Prefer ISO codepages, and prefer lower numbers in the ISO | ||
| 4905 | range. Only return charsets for codepages which are installed. | ||
| 4906 | |||
| 4907 | Format of each entry is | ||
| 4908 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). | ||
| 4909 | */ | ||
| 4910 | for (rest = Vw32_charset_info_alist; CONSP (rest); rest = XCDR (rest)) | ||
| 4911 | { | ||
| 4912 | char * x_charset; | ||
| 4913 | Lisp_Object w32_charset; | ||
| 4914 | Lisp_Object codepage; | ||
| 4915 | |||
| 4916 | Lisp_Object this_entry = XCAR (rest); | ||
| 4917 | |||
| 4918 | /* Skip invalid entries in alist. */ | ||
| 4919 | if (!CONSP (this_entry) || !STRINGP (XCAR (this_entry)) | ||
| 4920 | || !CONSP (XCDR (this_entry)) | ||
| 4921 | || !SYMBOLP (XCAR (XCDR (this_entry)))) | ||
| 4922 | continue; | ||
| 4923 | |||
| 4924 | x_charset = SDATA (XCAR (this_entry)); | ||
| 4925 | w32_charset = XCAR (XCDR (this_entry)); | ||
| 4926 | codepage = XCDR (XCDR (this_entry)); | ||
| 4927 | |||
| 4928 | /* Look for Same charset and a valid codepage (or non-int | ||
| 4929 | which means ignore). */ | ||
| 4930 | if (EQ (w32_charset, charset_type) | ||
| 4931 | && (!INTEGERP (codepage) || XINT (codepage) == CP_DEFAULT | ||
| 4932 | || IsValidCodePage (XINT (codepage)))) | ||
| 4933 | { | ||
| 4934 | /* If we don't have a match already, then this is the | ||
| 4935 | best. */ | ||
| 4936 | if (!best_match) | ||
| 4937 | { | ||
| 4938 | best_match = x_charset; | ||
| 4939 | if (matching && !strnicmp (x_charset, matching, match_len)) | ||
| 4940 | matching_found = 1; | ||
| 4941 | } | ||
| 4942 | /* If we already found a match for MATCHING, then | ||
| 4943 | only consider other matches. */ | ||
| 4944 | else if (matching_found | ||
| 4945 | && strnicmp (x_charset, matching, match_len)) | ||
| 4946 | continue; | ||
| 4947 | /* If this matches what we want, and the best so far doesn't, | ||
| 4948 | then this is better. */ | ||
| 4949 | else if (!matching_found && matching | ||
| 4950 | && !strnicmp (x_charset, matching, match_len)) | ||
| 4951 | { | ||
| 4952 | best_match = x_charset; | ||
| 4953 | matching_found = 1; | ||
| 4954 | } | ||
| 4955 | /* If this is fully specified, and the best so far isn't, | ||
| 4956 | then this is better. */ | ||
| 4957 | else if ((!strchr (best_match, '-') && strchr (x_charset, '-')) | ||
| 4958 | /* If this is an ISO codepage, and the best so far isn't, | ||
| 4959 | then this is better, but only if it fully specifies the | ||
| 4960 | encoding. */ | ||
| 4961 | || (strnicmp (best_match, "iso", 3) != 0 | ||
| 4962 | && strnicmp (x_charset, "iso", 3) == 0 | ||
| 4963 | && strchr (x_charset, '-'))) | ||
| 4964 | best_match = x_charset; | ||
| 4965 | /* If both are ISO8859 codepages, choose the one with the | ||
| 4966 | lowest number in the encoding field. */ | ||
| 4967 | else if (strnicmp (best_match, "iso8859-", 8) == 0 | ||
| 4968 | && strnicmp (x_charset, "iso8859-", 8) == 0) | ||
| 4969 | { | ||
| 4970 | int best_enc = atoi (best_match + 8); | ||
| 4971 | int this_enc = atoi (x_charset + 8); | ||
| 4972 | if (this_enc > 0 && this_enc < best_enc) | ||
| 4973 | best_match = x_charset; | ||
| 4974 | } | ||
| 4975 | } | ||
| 4976 | } | ||
| 4977 | |||
| 4978 | /* If no match, encode the numeric value. */ | ||
| 4979 | if (!best_match) | ||
| 4980 | { | ||
| 4981 | sprintf (buf, "*-#%u", fncharset); | ||
| 4982 | return buf; | ||
| 4983 | } | ||
| 4984 | |||
| 4985 | strncpy (buf, best_match, 31); | ||
| 4986 | /* If the charset is not fully specified, put -0 on the end. */ | ||
| 4987 | if (!strchr (best_match, '-')) | ||
| 4988 | { | ||
| 4989 | int pos = strlen (best_match); | ||
| 4990 | /* Charset specifiers shouldn't be very long. If it is a made | ||
| 4991 | up one, truncating it should not do any harm since it isn't | ||
| 4992 | recognized anyway. */ | ||
| 4993 | if (pos > 29) | ||
| 4994 | pos = 29; | ||
| 4995 | strcpy (buf + pos, "-0"); | ||
| 4996 | } | ||
| 4997 | buf[31] = '\0'; | ||
| 4998 | return buf; | ||
| 4999 | } | ||
| 5000 | } | ||
| 5001 | |||
| 5002 | |||
| 5003 | /* Return all the X charsets that map to a font. */ | ||
| 5004 | static Lisp_Object | ||
| 5005 | w32_to_all_x_charsets (fncharset) | ||
| 5006 | int fncharset; | ||
| 5007 | { | ||
| 5008 | static char buf[32]; | ||
| 5009 | Lisp_Object charset_type; | ||
| 5010 | Lisp_Object retval = Qnil; | ||
| 5011 | |||
| 5012 | switch (fncharset) | ||
| 5013 | { | ||
| 5014 | case ANSI_CHARSET: | ||
| 5015 | /* Handle startup case of w32-charset-info-alist not | ||
| 5016 | being set up yet. */ | ||
| 5017 | if (NILP (Vw32_charset_info_alist)) | ||
| 5018 | return Fcons (build_string ("iso8859-1"), Qnil); | ||
| 5019 | |||
| 5020 | charset_type = Qw32_charset_ansi; | ||
| 5021 | break; | ||
| 5022 | case DEFAULT_CHARSET: | ||
| 5023 | charset_type = Qw32_charset_default; | ||
| 5024 | break; | ||
| 5025 | case SYMBOL_CHARSET: | ||
| 5026 | charset_type = Qw32_charset_symbol; | ||
| 5027 | break; | ||
| 5028 | case SHIFTJIS_CHARSET: | ||
| 5029 | charset_type = Qw32_charset_shiftjis; | ||
| 5030 | break; | ||
| 5031 | case HANGEUL_CHARSET: | ||
| 5032 | charset_type = Qw32_charset_hangeul; | ||
| 5033 | break; | ||
| 5034 | case GB2312_CHARSET: | ||
| 5035 | charset_type = Qw32_charset_gb2312; | ||
| 5036 | break; | ||
| 5037 | case CHINESEBIG5_CHARSET: | ||
| 5038 | charset_type = Qw32_charset_chinesebig5; | ||
| 5039 | break; | ||
| 5040 | case OEM_CHARSET: | ||
| 5041 | charset_type = Qw32_charset_oem; | ||
| 5042 | break; | ||
| 5043 | |||
| 5044 | /* More recent versions of Windows (95 and NT4.0) define more | ||
| 5045 | character sets. */ | ||
| 5046 | #ifdef EASTEUROPE_CHARSET | ||
| 5047 | case EASTEUROPE_CHARSET: | ||
| 5048 | charset_type = Qw32_charset_easteurope; | ||
| 5049 | break; | ||
| 5050 | case TURKISH_CHARSET: | ||
| 5051 | charset_type = Qw32_charset_turkish; | ||
| 5052 | break; | ||
| 5053 | case BALTIC_CHARSET: | ||
| 5054 | charset_type = Qw32_charset_baltic; | ||
| 5055 | break; | ||
| 5056 | case RUSSIAN_CHARSET: | ||
| 5057 | charset_type = Qw32_charset_russian; | ||
| 5058 | break; | ||
| 5059 | case ARABIC_CHARSET: | ||
| 5060 | charset_type = Qw32_charset_arabic; | ||
| 5061 | break; | ||
| 5062 | case GREEK_CHARSET: | ||
| 5063 | charset_type = Qw32_charset_greek; | ||
| 5064 | break; | ||
| 5065 | case HEBREW_CHARSET: | ||
| 5066 | charset_type = Qw32_charset_hebrew; | ||
| 5067 | break; | ||
| 5068 | case VIETNAMESE_CHARSET: | ||
| 5069 | charset_type = Qw32_charset_vietnamese; | ||
| 5070 | break; | ||
| 5071 | case THAI_CHARSET: | ||
| 5072 | charset_type = Qw32_charset_thai; | ||
| 5073 | break; | ||
| 5074 | case MAC_CHARSET: | ||
| 5075 | charset_type = Qw32_charset_mac; | ||
| 5076 | break; | ||
| 5077 | case JOHAB_CHARSET: | ||
| 5078 | charset_type = Qw32_charset_johab; | ||
| 5079 | break; | ||
| 5080 | #endif | ||
| 5081 | |||
| 5082 | #ifdef UNICODE_CHARSET | ||
| 5083 | case UNICODE_CHARSET: | ||
| 5084 | charset_type = Qw32_charset_unicode; | ||
| 5085 | break; | ||
| 5086 | #endif | ||
| 5087 | default: | ||
| 5088 | /* Encode numerical value of unknown charset. */ | ||
| 5089 | sprintf (buf, "*-#%u", fncharset); | ||
| 5090 | return Fcons (build_string (buf), Qnil); | ||
| 5091 | } | ||
| 5092 | |||
| 5093 | { | ||
| 5094 | Lisp_Object rest; | ||
| 5095 | /* Look through w32-charset-info-alist for the character set. | ||
| 5096 | Only return fully specified charsets for codepages which are | ||
| 5097 | installed. | ||
| 5098 | |||
| 5099 | Format of each entry in Vw32_charset_info_alist is | ||
| 5100 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). | ||
| 5101 | */ | ||
| 5102 | for (rest = Vw32_charset_info_alist; CONSP (rest); rest = XCDR (rest)) | ||
| 5103 | { | ||
| 5104 | Lisp_Object x_charset; | ||
| 5105 | Lisp_Object w32_charset; | ||
| 5106 | Lisp_Object codepage; | ||
| 5107 | |||
| 5108 | Lisp_Object this_entry = XCAR (rest); | ||
| 5109 | |||
| 5110 | /* Skip invalid entries in alist. */ | ||
| 5111 | if (!CONSP (this_entry) || !STRINGP (XCAR (this_entry)) | ||
| 5112 | || !CONSP (XCDR (this_entry)) | ||
| 5113 | || !SYMBOLP (XCAR (XCDR (this_entry)))) | ||
| 5114 | continue; | ||
| 5115 | |||
| 5116 | x_charset = XCAR (this_entry); | ||
| 5117 | w32_charset = XCAR (XCDR (this_entry)); | ||
| 5118 | codepage = XCDR (XCDR (this_entry)); | ||
| 5119 | |||
| 5120 | if (!strchr (SDATA (x_charset), '-')) | ||
| 5121 | continue; | ||
| 5122 | |||
| 5123 | /* Look for Same charset and a valid codepage (or non-int | ||
| 5124 | which means ignore). */ | ||
| 5125 | if (EQ (w32_charset, charset_type) | ||
| 5126 | && (!INTEGERP (codepage) || XINT (codepage) == CP_DEFAULT | ||
| 5127 | || IsValidCodePage (XINT (codepage)))) | ||
| 5128 | { | ||
| 5129 | retval = Fcons (x_charset, retval); | ||
| 5130 | } | ||
| 5131 | } | ||
| 5132 | |||
| 5133 | /* If no match, encode the numeric value. */ | ||
| 5134 | if (NILP (retval)) | ||
| 5135 | { | ||
| 5136 | sprintf (buf, "*-#%u", fncharset); | ||
| 5137 | return Fcons (build_string (buf), Qnil); | ||
| 5138 | } | ||
| 5139 | |||
| 5140 | return retval; | ||
| 5141 | } | ||
| 5142 | } | ||
| 5143 | |||
| 5144 | static BOOL | ||
| 5145 | w32_to_x_font (lplogfont, lpxstr, len, specific_charset) | ||
| 5146 | LOGFONT * lplogfont; | ||
| 5147 | char * lpxstr; | ||
| 5148 | int len; | ||
| 5149 | char * specific_charset; | ||
| 5150 | { | ||
| 5151 | char* fonttype; | ||
| 5152 | char *fontname; | ||
| 5153 | char height_pixels[8]; | ||
| 5154 | char height_dpi[8]; | ||
| 5155 | char width_pixels[8]; | ||
| 5156 | char *fontname_dash; | ||
| 5157 | int display_resy = (int) one_w32_display_info.resy; | ||
| 5158 | int display_resx = (int) one_w32_display_info.resx; | ||
| 5159 | struct coding_system coding; | ||
| 5160 | |||
| 5161 | if (!lpxstr) abort (); | ||
| 5162 | |||
| 5163 | if (!lplogfont) | ||
| 5164 | return FALSE; | ||
| 5165 | |||
| 5166 | if (lplogfont->lfOutPrecision == OUT_STRING_PRECIS) | ||
| 5167 | fonttype = "raster"; | ||
| 5168 | else if (lplogfont->lfOutPrecision == OUT_STROKE_PRECIS) | ||
| 5169 | fonttype = "outline"; | ||
| 5170 | else | ||
| 5171 | fonttype = "unknown"; | ||
| 5172 | |||
| 5173 | setup_coding_system (Fcheck_coding_system (Vlocale_coding_system), | ||
| 5174 | &coding); | ||
| 5175 | coding.src_multibyte = 0; | ||
| 5176 | coding.dst_multibyte = 1; | ||
| 5177 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 5178 | /* We explicitely disable composition handling because selection | ||
| 5179 | data should not contain any composition sequence. */ | ||
| 5180 | coding.common_flags &= ~CODING_ANNOTATION_MASK; | ||
| 5181 | |||
| 5182 | coding.dst_bytes = LF_FACESIZE * 2; | ||
| 5183 | coding.destination = (unsigned char *) xmalloc (coding.dst_bytes + 1); | ||
| 5184 | decode_coding_c_string (&coding, lplogfont->lfFaceName, | ||
| 5185 | strlen(lplogfont->lfFaceName), Qnil); | ||
| 5186 | fontname = coding.destination; | ||
| 5187 | |||
| 5188 | *(fontname + coding.produced) = '\0'; | ||
| 5189 | |||
| 5190 | /* Replace dashes with underscores so the dashes are not | ||
| 5191 | misinterpreted. */ | ||
| 5192 | fontname_dash = fontname; | ||
| 5193 | while (fontname_dash = strchr (fontname_dash, '-')) | ||
| 5194 | *fontname_dash = '_'; | ||
| 5195 | |||
| 5196 | if (lplogfont->lfHeight) | ||
| 5197 | { | ||
| 5198 | sprintf (height_pixels, "%u", eabs (lplogfont->lfHeight)); | ||
| 5199 | sprintf (height_dpi, "%u", | ||
| 5200 | eabs (lplogfont->lfHeight) * 720 / display_resy); | ||
| 5201 | } | ||
| 5202 | else | ||
| 5203 | { | ||
| 5204 | strcpy (height_pixels, "*"); | ||
| 5205 | strcpy (height_dpi, "*"); | ||
| 5206 | } | ||
| 5207 | |||
| 5208 | #if 0 /* Never put the width in the xlfd. It fails on fonts with | ||
| 5209 | double-width characters. */ | ||
| 5210 | if (lplogfont->lfWidth) | ||
| 5211 | sprintf (width_pixels, "%u", lplogfont->lfWidth * 10); | ||
| 5212 | else | ||
| 5213 | #endif | ||
| 5214 | strcpy (width_pixels, "*"); | ||
| 5215 | |||
| 5216 | _snprintf (lpxstr, len - 1, | ||
| 5217 | "-%s-%s-%s-%c-normal-normal-%s-%s-%d-%d-%c-%s-%s", | ||
| 5218 | fonttype, /* foundry */ | ||
| 5219 | fontname, /* family */ | ||
| 5220 | w32_to_x_weight (lplogfont->lfWeight), /* weight */ | ||
| 5221 | lplogfont->lfItalic?'i':'r', /* slant */ | ||
| 5222 | /* setwidth name */ | ||
| 5223 | /* add style name */ | ||
| 5224 | height_pixels, /* pixel size */ | ||
| 5225 | height_dpi, /* point size */ | ||
| 5226 | display_resx, /* resx */ | ||
| 5227 | display_resy, /* resy */ | ||
| 5228 | ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) | ||
| 5229 | ? 'p' : 'c', /* spacing */ | ||
| 5230 | width_pixels, /* avg width */ | ||
| 5231 | w32_to_x_charset (lplogfont->lfCharSet, specific_charset) | ||
| 5232 | /* charset registry and encoding */ | ||
| 5233 | ); | ||
| 5234 | |||
| 5235 | lpxstr[len - 1] = 0; /* just to be sure */ | ||
| 5236 | return (TRUE); | ||
| 5237 | } | ||
| 5238 | |||
| 5239 | static BOOL | ||
| 5240 | x_to_w32_font (lpxstr, lplogfont) | ||
| 5241 | char * lpxstr; | ||
| 5242 | LOGFONT * lplogfont; | ||
| 5243 | { | ||
| 5244 | struct coding_system coding; | ||
| 5245 | |||
| 5246 | if (!lplogfont) return (FALSE); | ||
| 5247 | |||
| 5248 | memset (lplogfont, 0, sizeof (*lplogfont)); | ||
| 5249 | |||
| 5250 | /* Set default value for each field. */ | ||
| 5251 | #if 1 | ||
| 5252 | lplogfont->lfOutPrecision = OUT_DEFAULT_PRECIS; | ||
| 5253 | lplogfont->lfClipPrecision = CLIP_DEFAULT_PRECIS; | ||
| 5254 | lplogfont->lfQuality = DEFAULT_QUALITY; | ||
| 5255 | #else | ||
| 5256 | /* go for maximum quality */ | ||
| 5257 | lplogfont->lfOutPrecision = OUT_STROKE_PRECIS; | ||
| 5258 | lplogfont->lfClipPrecision = CLIP_STROKE_PRECIS; | ||
| 5259 | lplogfont->lfQuality = PROOF_QUALITY; | ||
| 5260 | #endif | ||
| 5261 | |||
| 5262 | lplogfont->lfCharSet = DEFAULT_CHARSET; | ||
| 5263 | lplogfont->lfWeight = FW_DONTCARE; | ||
| 5264 | lplogfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; | ||
| 5265 | |||
| 5266 | if (!lpxstr) | ||
| 5267 | return FALSE; | ||
| 5268 | |||
| 5269 | /* Provide a simple escape mechanism for specifying Windows font names | ||
| 5270 | * directly -- if font spec does not beginning with '-', assume this | ||
| 5271 | * format: | ||
| 5272 | * "<font name>[:height in pixels[:width in pixels[:weight]]]" | ||
| 5273 | */ | ||
| 5274 | |||
| 5275 | if (*lpxstr == '-') | ||
| 5276 | { | ||
| 5277 | int fields, tem; | ||
| 5278 | char name[50], weight[20], slant, pitch, pixels[10], height[10], | ||
| 5279 | width[10], resy[10], remainder[50]; | ||
| 5280 | char * encoding; | ||
| 5281 | int dpi = (int) one_w32_display_info.resy; | ||
| 5282 | |||
| 5283 | fields = sscanf (lpxstr, | ||
| 5284 | "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%49s", | ||
| 5285 | name, weight, &slant, pixels, height, resy, &pitch, width, remainder); | ||
| 5286 | if (fields == EOF) | ||
| 5287 | return (FALSE); | ||
| 5288 | |||
| 5289 | /* In the general case when wildcards cover more than one field, | ||
| 5290 | we don't know which field is which, so don't fill any in. | ||
| 5291 | However, we need to cope with this particular form, which is | ||
| 5292 | generated by font_list_1 (invoked by try_font_list): | ||
| 5293 | "-raster-6x10-*-gb2312*-*" | ||
| 5294 | and make sure to correctly parse the charset field. */ | ||
| 5295 | if (fields == 3) | ||
| 5296 | { | ||
| 5297 | fields = sscanf (lpxstr, | ||
| 5298 | "-%*[^-]-%49[^-]-*-%49s", | ||
| 5299 | name, remainder); | ||
| 5300 | } | ||
| 5301 | else if (fields < 9) | ||
| 5302 | { | ||
| 5303 | fields = 0; | ||
| 5304 | remainder[0] = 0; | ||
| 5305 | } | ||
| 5306 | |||
| 5307 | if (fields > 0 && name[0] != '*') | ||
| 5308 | { | ||
| 5309 | Lisp_Object string = build_string (name); | ||
| 5310 | setup_coding_system | ||
| 5311 | (Fcheck_coding_system (Vlocale_coding_system), &coding); | ||
| 5312 | coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK); | ||
| 5313 | /* Disable composition/charset annotation. */ | ||
| 5314 | coding.common_flags &= ~CODING_ANNOTATION_MASK; | ||
| 5315 | coding.dst_bytes = SCHARS (string) * 2; | ||
| 5316 | |||
| 5317 | coding.destination = (unsigned char *) xmalloc (coding.dst_bytes); | ||
| 5318 | encode_coding_object (&coding, string, 0, 0, | ||
| 5319 | SCHARS (string), SBYTES (string), Qnil); | ||
| 5320 | if (coding.produced >= LF_FACESIZE) | ||
| 5321 | coding.produced = LF_FACESIZE - 1; | ||
| 5322 | |||
| 5323 | coding.destination[coding.produced] = '\0'; | ||
| 5324 | |||
| 5325 | strcpy (lplogfont->lfFaceName, coding.destination); | ||
| 5326 | xfree (coding.destination); | ||
| 5327 | } | ||
| 5328 | else | ||
| 5329 | { | ||
| 5330 | lplogfont->lfFaceName[0] = '\0'; | ||
| 5331 | } | ||
| 5332 | |||
| 5333 | fields--; | ||
| 5334 | |||
| 5335 | lplogfont->lfWeight = x_to_w32_weight ((fields > 0 ? weight : "")); | ||
| 5336 | |||
| 5337 | fields--; | ||
| 5338 | |||
| 5339 | lplogfont->lfItalic = (fields > 0 && slant == 'i'); | ||
| 5340 | |||
| 5341 | fields--; | ||
| 5342 | |||
| 5343 | if (fields > 0 && pixels[0] != '*') | ||
| 5344 | lplogfont->lfHeight = atoi (pixels); | ||
| 5345 | |||
| 5346 | fields--; | ||
| 5347 | fields--; | ||
| 5348 | if (fields > 0 && resy[0] != '*') | ||
| 5349 | { | ||
| 5350 | tem = atoi (resy); | ||
| 5351 | if (tem > 0) dpi = tem; | ||
| 5352 | } | ||
| 5353 | |||
| 5354 | if (fields > -1 && lplogfont->lfHeight == 0 && height[0] != '*') | ||
| 5355 | lplogfont->lfHeight = atoi (height) * dpi / 720; | ||
| 5356 | |||
| 5357 | if (fields > 0) | ||
| 5358 | { | ||
| 5359 | if (pitch == 'p') | ||
| 5360 | lplogfont->lfPitchAndFamily = VARIABLE_PITCH | FF_DONTCARE; | ||
| 5361 | else if (pitch == 'c') | ||
| 5362 | lplogfont->lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE; | ||
| 5363 | } | ||
| 5364 | |||
| 5365 | fields--; | ||
| 5366 | |||
| 5367 | if (fields > 0 && width[0] != '*') | ||
| 5368 | lplogfont->lfWidth = atoi (width) / 10; | ||
| 5369 | |||
| 5370 | fields--; | ||
| 5371 | |||
| 5372 | /* Strip the trailing '-' if present. (it shouldn't be, as it | ||
| 5373 | fails the test against xlfd-tight-regexp in fontset.el). */ | ||
| 5374 | { | ||
| 5375 | int len = strlen (remainder); | ||
| 5376 | if (len > 0 && remainder[len-1] == '-') | ||
| 5377 | remainder[len-1] = 0; | ||
| 5378 | } | ||
| 5379 | encoding = remainder; | ||
| 5380 | #if 0 | ||
| 5381 | if (strncmp (encoding, "*-", 2) == 0) | ||
| 5382 | encoding += 2; | ||
| 5383 | #endif | ||
| 5384 | lplogfont->lfCharSet = x_to_w32_charset (encoding); | ||
| 5385 | } | ||
| 5386 | else | ||
| 5387 | { | ||
| 5388 | int fields; | ||
| 5389 | char name[100], height[10], width[10], weight[20]; | ||
| 5390 | |||
| 5391 | fields = sscanf (lpxstr, | ||
| 5392 | "%99[^:]:%9[^:]:%9[^:]:%19s", | ||
| 5393 | name, height, width, weight); | ||
| 5394 | |||
| 5395 | if (fields == EOF) return (FALSE); | ||
| 5396 | |||
| 5397 | if (fields > 0) | ||
| 5398 | { | ||
| 5399 | strncpy (lplogfont->lfFaceName, name, LF_FACESIZE); | ||
| 5400 | lplogfont->lfFaceName[LF_FACESIZE-1] = 0; | ||
| 5401 | } | ||
| 5402 | else | ||
| 5403 | { | ||
| 5404 | lplogfont->lfFaceName[0] = 0; | ||
| 5405 | } | ||
| 5406 | |||
| 5407 | fields--; | ||
| 5408 | |||
| 5409 | if (fields > 0) | ||
| 5410 | lplogfont->lfHeight = atoi (height); | ||
| 5411 | |||
| 5412 | fields--; | ||
| 5413 | |||
| 5414 | if (fields > 0) | ||
| 5415 | lplogfont->lfWidth = atoi (width); | ||
| 5416 | |||
| 5417 | fields--; | ||
| 5418 | |||
| 5419 | lplogfont->lfWeight = x_to_w32_weight ((fields > 0 ? weight : "")); | ||
| 5420 | } | ||
| 5421 | |||
| 5422 | /* This makes TrueType fonts work better. */ | ||
| 5423 | lplogfont->lfHeight = - eabs (lplogfont->lfHeight); | ||
| 5424 | |||
| 5425 | return (TRUE); | ||
| 5426 | } | ||
| 5427 | |||
| 5428 | |||
| 5429 | |||
| 5430 | DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, | 4610 | DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, |
| 5431 | doc: /* Internal function called by `color-defined-p', which see. */) | 4611 | doc: /* Internal function called by `color-defined-p', which see. */) |
| 5432 | (color, frame) | 4612 | (color, frame) |
| @@ -7995,69 +7175,6 @@ Set this to nil to get the old behavior for repainting; this should | |||
| 7995 | only be necessary if the default setting causes problems. */); | 7175 | only be necessary if the default setting causes problems. */); |
| 7996 | w32_strict_painting = 1; | 7176 | w32_strict_painting = 1; |
| 7997 | 7177 | ||
| 7998 | DEFVAR_LISP ("w32-charset-info-alist", | ||
| 7999 | &Vw32_charset_info_alist, | ||
| 8000 | doc: /* Alist linking Emacs character sets to Windows fonts and codepages. | ||
| 8001 | Each entry should be of the form: | ||
| 8002 | |||
| 8003 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)) | ||
| 8004 | |||
| 8005 | where CHARSET_NAME is a string used in font names to identify the charset, | ||
| 8006 | WINDOWS_CHARSET is a symbol that can be one of: | ||
| 8007 | w32-charset-ansi, w32-charset-default, w32-charset-symbol, | ||
| 8008 | w32-charset-shiftjis, w32-charset-hangeul, w32-charset-gb2312, | ||
| 8009 | w32-charset-chinesebig5, | ||
| 8010 | w32-charset-johab, w32-charset-hebrew, | ||
| 8011 | w32-charset-arabic, w32-charset-greek, w32-charset-turkish, | ||
| 8012 | w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope, | ||
| 8013 | w32-charset-russian, w32-charset-mac, w32-charset-baltic, | ||
| 8014 | w32-charset-unicode, | ||
| 8015 | or w32-charset-oem. | ||
| 8016 | CODEPAGE should be an integer specifying the codepage that should be used | ||
| 8017 | to display the character set, t to do no translation and output as Unicode, | ||
| 8018 | or nil to do no translation and output as 8 bit (or multibyte on far-east | ||
| 8019 | versions of Windows) characters. */); | ||
| 8020 | Vw32_charset_info_alist = Qnil; | ||
| 8021 | |||
| 8022 | DEFSYM (Qw32_charset_ansi, "w32-charset-ansi"); | ||
| 8023 | DEFSYM (Qw32_charset_symbol, "w32-charset-symbol"); | ||
| 8024 | DEFSYM (Qw32_charset_default, "w32-charset-default"); | ||
| 8025 | DEFSYM (Qw32_charset_shiftjis, "w32-charset-shiftjis"); | ||
| 8026 | DEFSYM (Qw32_charset_hangeul, "w32-charset-hangeul"); | ||
| 8027 | DEFSYM (Qw32_charset_chinesebig5, "w32-charset-chinesebig5"); | ||
| 8028 | DEFSYM (Qw32_charset_gb2312, "w32-charset-gb2312"); | ||
| 8029 | DEFSYM (Qw32_charset_oem, "w32-charset-oem"); | ||
| 8030 | |||
| 8031 | #ifdef JOHAB_CHARSET | ||
| 8032 | { | ||
| 8033 | static int w32_extra_charsets_defined = 1; | ||
| 8034 | DEFVAR_BOOL ("w32-extra-charsets-defined", &w32_extra_charsets_defined, | ||
| 8035 | doc: /* Internal variable. */); | ||
| 8036 | |||
| 8037 | DEFSYM (Qw32_charset_johab, "w32-charset-johab"); | ||
| 8038 | DEFSYM (Qw32_charset_easteurope, "w32-charset-easteurope"); | ||
| 8039 | DEFSYM (Qw32_charset_turkish, "w32-charset-turkish"); | ||
| 8040 | DEFSYM (Qw32_charset_baltic, "w32-charset-baltic"); | ||
| 8041 | DEFSYM (Qw32_charset_russian, "w32-charset-russian"); | ||
| 8042 | DEFSYM (Qw32_charset_arabic, "w32-charset-arabic"); | ||
| 8043 | DEFSYM (Qw32_charset_greek, "w32-charset-greek"); | ||
| 8044 | DEFSYM (Qw32_charset_hebrew, "w32-charset-hebrew"); | ||
| 8045 | DEFSYM (Qw32_charset_vietnamese, "w32-charset-vietnamese"); | ||
| 8046 | DEFSYM (Qw32_charset_thai, "w32-charset-thai"); | ||
| 8047 | DEFSYM (Qw32_charset_mac, "w32-charset-mac"); | ||
| 8048 | } | ||
| 8049 | #endif | ||
| 8050 | |||
| 8051 | #ifdef UNICODE_CHARSET | ||
| 8052 | { | ||
| 8053 | static int w32_unicode_charset_defined = 1; | ||
| 8054 | DEFVAR_BOOL ("w32-unicode-charset-defined", | ||
| 8055 | &w32_unicode_charset_defined, | ||
| 8056 | doc: /* Internal variable. */); | ||
| 8057 | DEFSYM (Qw32_charset_unicode, "w32-charset-unicode"); | ||
| 8058 | } | ||
| 8059 | #endif | ||
| 8060 | |||
| 8061 | #if 0 /* TODO: Port to W32 */ | 7178 | #if 0 /* TODO: Port to W32 */ |
| 8062 | defsubr (&Sx_change_window_property); | 7179 | defsubr (&Sx_change_window_property); |
| 8063 | defsubr (&Sx_delete_window_property); | 7180 | defsubr (&Sx_delete_window_property); |
diff --git a/src/w32font.c b/src/w32font.c index bc3340c191f..e97d1c2c278 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -43,6 +43,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 43 | #define CLEARTYPE_NATURAL_QUALITY 6 | 43 | #define CLEARTYPE_NATURAL_QUALITY 6 |
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| 46 | /* VIETNAMESE_CHARSET and JOHAB_CHARSET are not defined in some versions | ||
| 47 | of MSVC headers. */ | ||
| 48 | #ifndef VIETNAMESE_CHARSET | ||
| 49 | #define VIETNAMESE_CHARSET 163 | ||
| 50 | #endif | ||
| 51 | #ifndef JOHAB_CHARSET | ||
| 52 | #define JOHAB_CHARSET 130 | ||
| 53 | #endif | ||
| 54 | |||
| 46 | extern struct font_driver w32font_driver; | 55 | extern struct font_driver w32font_driver; |
| 47 | 56 | ||
| 48 | Lisp_Object Qgdi; | 57 | Lisp_Object Qgdi; |
| @@ -80,6 +89,20 @@ static Lisp_Object Qtagalog, Qtagbanwa, Qtai_le, Qtifinagh, Qugaritic; | |||
| 80 | /* Only defined here, but useful for distinguishing IPA capable fonts. */ | 89 | /* Only defined here, but useful for distinguishing IPA capable fonts. */ |
| 81 | static Lisp_Object Qphonetic; | 90 | static Lisp_Object Qphonetic; |
| 82 | 91 | ||
| 92 | /* W32 charsets: for use in Vw32_charset_info_alist. */ | ||
| 93 | static Lisp_Object Qw32_charset_ansi, Qw32_charset_default; | ||
| 94 | static Lisp_Object Qw32_charset_symbol, Qw32_charset_shiftjis; | ||
| 95 | static Lisp_Object Qw32_charset_hangeul, Qw32_charset_gb2312; | ||
| 96 | static Lisp_Object Qw32_charset_chinesebig5, Qw32_charset_oem; | ||
| 97 | static Lisp_Object Qw32_charset_easteurope, Qw32_charset_turkish; | ||
| 98 | static Lisp_Object Qw32_charset_baltic, Qw32_charset_russian; | ||
| 99 | static Lisp_Object Qw32_charset_arabic, Qw32_charset_greek; | ||
| 100 | static Lisp_Object Qw32_charset_hebrew, Qw32_charset_vietnamese; | ||
| 101 | static Lisp_Object Qw32_charset_thai, Qw32_charset_johab, Qw32_charset_mac; | ||
| 102 | |||
| 103 | /* Associative list linking character set strings to Windows codepages. */ | ||
| 104 | static Lisp_Object Vw32_charset_info_alist; | ||
| 105 | |||
| 83 | /* Font spacing symbols - defined in font.c. */ | 106 | /* Font spacing symbols - defined in font.c. */ |
| 84 | extern Lisp_Object Qc, Qp, Qm; | 107 | extern Lisp_Object Qc, Qp, Qm; |
| 85 | 108 | ||
| @@ -129,9 +152,6 @@ struct font_callback_data | |||
| 129 | style variations if the font name is not specified. */ | 152 | style variations if the font name is not specified. */ |
| 130 | static void list_all_matching_fonts P_ ((struct font_callback_data *)); | 153 | static void list_all_matching_fonts P_ ((struct font_callback_data *)); |
| 131 | 154 | ||
| 132 | /* From old font code in w32fns.c */ | ||
| 133 | char * w32_to_x_charset P_ ((int, char *)); | ||
| 134 | |||
| 135 | 155 | ||
| 136 | static int | 156 | static int |
| 137 | memq_no_quit (elt, list) | 157 | memq_no_quit (elt, list) |
| @@ -1425,6 +1445,89 @@ add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam) | |||
| 1425 | return !NILP (match_data->list); | 1445 | return !NILP (match_data->list); |
| 1426 | } | 1446 | } |
| 1427 | 1447 | ||
| 1448 | /* Old function to convert from x to w32 charset, from w32fns.c. */ | ||
| 1449 | static LONG | ||
| 1450 | x_to_w32_charset (lpcs) | ||
| 1451 | char * lpcs; | ||
| 1452 | { | ||
| 1453 | Lisp_Object this_entry, w32_charset; | ||
| 1454 | char *charset; | ||
| 1455 | int len = strlen (lpcs); | ||
| 1456 | |||
| 1457 | /* Support "*-#nnn" format for unknown charsets. */ | ||
| 1458 | if (strncmp (lpcs, "*-#", 3) == 0) | ||
| 1459 | return atoi (lpcs + 3); | ||
| 1460 | |||
| 1461 | /* All Windows fonts qualify as unicode. */ | ||
| 1462 | if (!strncmp (lpcs, "iso10646", 8)) | ||
| 1463 | return DEFAULT_CHARSET; | ||
| 1464 | |||
| 1465 | /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */ | ||
| 1466 | charset = alloca (len + 1); | ||
| 1467 | strcpy (charset, lpcs); | ||
| 1468 | lpcs = strchr (charset, '*'); | ||
| 1469 | if (lpcs) | ||
| 1470 | *lpcs = '\0'; | ||
| 1471 | |||
| 1472 | /* Look through w32-charset-info-alist for the character set. | ||
| 1473 | Format of each entry is | ||
| 1474 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). | ||
| 1475 | */ | ||
| 1476 | this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist); | ||
| 1477 | |||
| 1478 | if (NILP (this_entry)) | ||
| 1479 | { | ||
| 1480 | /* At startup, we want iso8859-1 fonts to come up properly. */ | ||
| 1481 | if (xstrcasecmp (charset, "iso8859-1") == 0) | ||
| 1482 | return ANSI_CHARSET; | ||
| 1483 | else | ||
| 1484 | return DEFAULT_CHARSET; | ||
| 1485 | } | ||
| 1486 | |||
| 1487 | w32_charset = Fcar (Fcdr (this_entry)); | ||
| 1488 | |||
| 1489 | /* Translate Lisp symbol to number. */ | ||
| 1490 | if (EQ (w32_charset, Qw32_charset_ansi)) | ||
| 1491 | return ANSI_CHARSET; | ||
| 1492 | if (EQ (w32_charset, Qw32_charset_symbol)) | ||
| 1493 | return SYMBOL_CHARSET; | ||
| 1494 | if (EQ (w32_charset, Qw32_charset_shiftjis)) | ||
| 1495 | return SHIFTJIS_CHARSET; | ||
| 1496 | if (EQ (w32_charset, Qw32_charset_hangeul)) | ||
| 1497 | return HANGEUL_CHARSET; | ||
| 1498 | if (EQ (w32_charset, Qw32_charset_chinesebig5)) | ||
| 1499 | return CHINESEBIG5_CHARSET; | ||
| 1500 | if (EQ (w32_charset, Qw32_charset_gb2312)) | ||
| 1501 | return GB2312_CHARSET; | ||
| 1502 | if (EQ (w32_charset, Qw32_charset_oem)) | ||
| 1503 | return OEM_CHARSET; | ||
| 1504 | if (EQ (w32_charset, Qw32_charset_johab)) | ||
| 1505 | return JOHAB_CHARSET; | ||
| 1506 | if (EQ (w32_charset, Qw32_charset_easteurope)) | ||
| 1507 | return EASTEUROPE_CHARSET; | ||
| 1508 | if (EQ (w32_charset, Qw32_charset_turkish)) | ||
| 1509 | return TURKISH_CHARSET; | ||
| 1510 | if (EQ (w32_charset, Qw32_charset_baltic)) | ||
| 1511 | return BALTIC_CHARSET; | ||
| 1512 | if (EQ (w32_charset, Qw32_charset_russian)) | ||
| 1513 | return RUSSIAN_CHARSET; | ||
| 1514 | if (EQ (w32_charset, Qw32_charset_arabic)) | ||
| 1515 | return ARABIC_CHARSET; | ||
| 1516 | if (EQ (w32_charset, Qw32_charset_greek)) | ||
| 1517 | return GREEK_CHARSET; | ||
| 1518 | if (EQ (w32_charset, Qw32_charset_hebrew)) | ||
| 1519 | return HEBREW_CHARSET; | ||
| 1520 | if (EQ (w32_charset, Qw32_charset_vietnamese)) | ||
| 1521 | return VIETNAMESE_CHARSET; | ||
| 1522 | if (EQ (w32_charset, Qw32_charset_thai)) | ||
| 1523 | return THAI_CHARSET; | ||
| 1524 | if (EQ (w32_charset, Qw32_charset_mac)) | ||
| 1525 | return MAC_CHARSET; | ||
| 1526 | |||
| 1527 | return DEFAULT_CHARSET; | ||
| 1528 | } | ||
| 1529 | |||
| 1530 | |||
| 1428 | /* Convert a Lisp font registry (symbol) to a windows charset. */ | 1531 | /* Convert a Lisp font registry (symbol) to a windows charset. */ |
| 1429 | static LONG | 1532 | static LONG |
| 1430 | registry_to_w32_charset (charset) | 1533 | registry_to_w32_charset (charset) |
| @@ -1441,6 +1544,203 @@ registry_to_w32_charset (charset) | |||
| 1441 | return DEFAULT_CHARSET; | 1544 | return DEFAULT_CHARSET; |
| 1442 | } | 1545 | } |
| 1443 | 1546 | ||
| 1547 | /* Old function to convert from w32 to x charset, from w32fns.c. */ | ||
| 1548 | static char * | ||
| 1549 | w32_to_x_charset (fncharset, matching) | ||
| 1550 | int fncharset; | ||
| 1551 | char *matching; | ||
| 1552 | { | ||
| 1553 | static char buf[32]; | ||
| 1554 | Lisp_Object charset_type; | ||
| 1555 | int match_len = 0; | ||
| 1556 | |||
| 1557 | if (matching) | ||
| 1558 | { | ||
| 1559 | /* If fully specified, accept it as it is. Otherwise use a | ||
| 1560 | substring match. */ | ||
| 1561 | char *wildcard = strchr (matching, '*'); | ||
| 1562 | if (wildcard) | ||
| 1563 | *wildcard = '\0'; | ||
| 1564 | else if (strchr (matching, '-')) | ||
| 1565 | return matching; | ||
| 1566 | |||
| 1567 | match_len = strlen (matching); | ||
| 1568 | } | ||
| 1569 | |||
| 1570 | switch (fncharset) | ||
| 1571 | { | ||
| 1572 | case ANSI_CHARSET: | ||
| 1573 | /* Handle startup case of w32-charset-info-alist not | ||
| 1574 | being set up yet. */ | ||
| 1575 | if (NILP (Vw32_charset_info_alist)) | ||
| 1576 | return "iso8859-1"; | ||
| 1577 | charset_type = Qw32_charset_ansi; | ||
| 1578 | break; | ||
| 1579 | case DEFAULT_CHARSET: | ||
| 1580 | charset_type = Qw32_charset_default; | ||
| 1581 | break; | ||
| 1582 | case SYMBOL_CHARSET: | ||
| 1583 | charset_type = Qw32_charset_symbol; | ||
| 1584 | break; | ||
| 1585 | case SHIFTJIS_CHARSET: | ||
| 1586 | charset_type = Qw32_charset_shiftjis; | ||
| 1587 | break; | ||
| 1588 | case HANGEUL_CHARSET: | ||
| 1589 | charset_type = Qw32_charset_hangeul; | ||
| 1590 | break; | ||
| 1591 | case GB2312_CHARSET: | ||
| 1592 | charset_type = Qw32_charset_gb2312; | ||
| 1593 | break; | ||
| 1594 | case CHINESEBIG5_CHARSET: | ||
| 1595 | charset_type = Qw32_charset_chinesebig5; | ||
| 1596 | break; | ||
| 1597 | case OEM_CHARSET: | ||
| 1598 | charset_type = Qw32_charset_oem; | ||
| 1599 | break; | ||
| 1600 | case EASTEUROPE_CHARSET: | ||
| 1601 | charset_type = Qw32_charset_easteurope; | ||
| 1602 | break; | ||
| 1603 | case TURKISH_CHARSET: | ||
| 1604 | charset_type = Qw32_charset_turkish; | ||
| 1605 | break; | ||
| 1606 | case BALTIC_CHARSET: | ||
| 1607 | charset_type = Qw32_charset_baltic; | ||
| 1608 | break; | ||
| 1609 | case RUSSIAN_CHARSET: | ||
| 1610 | charset_type = Qw32_charset_russian; | ||
| 1611 | break; | ||
| 1612 | case ARABIC_CHARSET: | ||
| 1613 | charset_type = Qw32_charset_arabic; | ||
| 1614 | break; | ||
| 1615 | case GREEK_CHARSET: | ||
| 1616 | charset_type = Qw32_charset_greek; | ||
| 1617 | break; | ||
| 1618 | case HEBREW_CHARSET: | ||
| 1619 | charset_type = Qw32_charset_hebrew; | ||
| 1620 | break; | ||
| 1621 | case VIETNAMESE_CHARSET: | ||
| 1622 | charset_type = Qw32_charset_vietnamese; | ||
| 1623 | break; | ||
| 1624 | case THAI_CHARSET: | ||
| 1625 | charset_type = Qw32_charset_thai; | ||
| 1626 | break; | ||
| 1627 | case MAC_CHARSET: | ||
| 1628 | charset_type = Qw32_charset_mac; | ||
| 1629 | break; | ||
| 1630 | case JOHAB_CHARSET: | ||
| 1631 | charset_type = Qw32_charset_johab; | ||
| 1632 | break; | ||
| 1633 | |||
| 1634 | default: | ||
| 1635 | /* Encode numerical value of unknown charset. */ | ||
| 1636 | sprintf (buf, "*-#%u", fncharset); | ||
| 1637 | return buf; | ||
| 1638 | } | ||
| 1639 | |||
| 1640 | { | ||
| 1641 | Lisp_Object rest; | ||
| 1642 | char * best_match = NULL; | ||
| 1643 | int matching_found = 0; | ||
| 1644 | |||
| 1645 | /* Look through w32-charset-info-alist for the character set. | ||
| 1646 | Prefer ISO codepages, and prefer lower numbers in the ISO | ||
| 1647 | range. Only return charsets for codepages which are installed. | ||
| 1648 | |||
| 1649 | Format of each entry is | ||
| 1650 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). | ||
| 1651 | */ | ||
| 1652 | for (rest = Vw32_charset_info_alist; CONSP (rest); rest = XCDR (rest)) | ||
| 1653 | { | ||
| 1654 | char * x_charset; | ||
| 1655 | Lisp_Object w32_charset; | ||
| 1656 | Lisp_Object codepage; | ||
| 1657 | |||
| 1658 | Lisp_Object this_entry = XCAR (rest); | ||
| 1659 | |||
| 1660 | /* Skip invalid entries in alist. */ | ||
| 1661 | if (!CONSP (this_entry) || !STRINGP (XCAR (this_entry)) | ||
| 1662 | || !CONSP (XCDR (this_entry)) | ||
| 1663 | || !SYMBOLP (XCAR (XCDR (this_entry)))) | ||
| 1664 | continue; | ||
| 1665 | |||
| 1666 | x_charset = SDATA (XCAR (this_entry)); | ||
| 1667 | w32_charset = XCAR (XCDR (this_entry)); | ||
| 1668 | codepage = XCDR (XCDR (this_entry)); | ||
| 1669 | |||
| 1670 | /* Look for Same charset and a valid codepage (or non-int | ||
| 1671 | which means ignore). */ | ||
| 1672 | if (EQ (w32_charset, charset_type) | ||
| 1673 | && (!INTEGERP (codepage) || XINT (codepage) == CP_DEFAULT | ||
| 1674 | || IsValidCodePage (XINT (codepage)))) | ||
| 1675 | { | ||
| 1676 | /* If we don't have a match already, then this is the | ||
| 1677 | best. */ | ||
| 1678 | if (!best_match) | ||
| 1679 | { | ||
| 1680 | best_match = x_charset; | ||
| 1681 | if (matching && !strnicmp (x_charset, matching, match_len)) | ||
| 1682 | matching_found = 1; | ||
| 1683 | } | ||
| 1684 | /* If we already found a match for MATCHING, then | ||
| 1685 | only consider other matches. */ | ||
| 1686 | else if (matching_found | ||
| 1687 | && strnicmp (x_charset, matching, match_len)) | ||
| 1688 | continue; | ||
| 1689 | /* If this matches what we want, and the best so far doesn't, | ||
| 1690 | then this is better. */ | ||
| 1691 | else if (!matching_found && matching | ||
| 1692 | && !strnicmp (x_charset, matching, match_len)) | ||
| 1693 | { | ||
| 1694 | best_match = x_charset; | ||
| 1695 | matching_found = 1; | ||
| 1696 | } | ||
| 1697 | /* If this is fully specified, and the best so far isn't, | ||
| 1698 | then this is better. */ | ||
| 1699 | else if ((!strchr (best_match, '-') && strchr (x_charset, '-')) | ||
| 1700 | /* If this is an ISO codepage, and the best so far isn't, | ||
| 1701 | then this is better, but only if it fully specifies the | ||
| 1702 | encoding. */ | ||
| 1703 | || (strnicmp (best_match, "iso", 3) != 0 | ||
| 1704 | && strnicmp (x_charset, "iso", 3) == 0 | ||
| 1705 | && strchr (x_charset, '-'))) | ||
| 1706 | best_match = x_charset; | ||
| 1707 | /* If both are ISO8859 codepages, choose the one with the | ||
| 1708 | lowest number in the encoding field. */ | ||
| 1709 | else if (strnicmp (best_match, "iso8859-", 8) == 0 | ||
| 1710 | && strnicmp (x_charset, "iso8859-", 8) == 0) | ||
| 1711 | { | ||
| 1712 | int best_enc = atoi (best_match + 8); | ||
| 1713 | int this_enc = atoi (x_charset + 8); | ||
| 1714 | if (this_enc > 0 && this_enc < best_enc) | ||
| 1715 | best_match = x_charset; | ||
| 1716 | } | ||
| 1717 | } | ||
| 1718 | } | ||
| 1719 | |||
| 1720 | /* If no match, encode the numeric value. */ | ||
| 1721 | if (!best_match) | ||
| 1722 | { | ||
| 1723 | sprintf (buf, "*-#%u", fncharset); | ||
| 1724 | return buf; | ||
| 1725 | } | ||
| 1726 | |||
| 1727 | strncpy (buf, best_match, 31); | ||
| 1728 | /* If the charset is not fully specified, put -0 on the end. */ | ||
| 1729 | if (!strchr (best_match, '-')) | ||
| 1730 | { | ||
| 1731 | int pos = strlen (best_match); | ||
| 1732 | /* Charset specifiers shouldn't be very long. If it is a made | ||
| 1733 | up one, truncating it should not do any harm since it isn't | ||
| 1734 | recognized anyway. */ | ||
| 1735 | if (pos > 29) | ||
| 1736 | pos = 29; | ||
| 1737 | strcpy (buf + pos, "-0"); | ||
| 1738 | } | ||
| 1739 | buf[31] = '\0'; | ||
| 1740 | return buf; | ||
| 1741 | } | ||
| 1742 | } | ||
| 1743 | |||
| 1444 | static Lisp_Object | 1744 | static Lisp_Object |
| 1445 | w32_registry (w32_charset, font_type) | 1745 | w32_registry (w32_charset, font_type) |
| 1446 | LONG w32_charset; | 1746 | LONG w32_charset; |
| @@ -2218,6 +2518,51 @@ syms_of_w32font () | |||
| 2218 | DEFSYM (Qtifinagh, "tifinagh"); | 2518 | DEFSYM (Qtifinagh, "tifinagh"); |
| 2219 | DEFSYM (Qugaritic, "ugaritic"); | 2519 | DEFSYM (Qugaritic, "ugaritic"); |
| 2220 | 2520 | ||
| 2521 | /* W32 font encodings. */ | ||
| 2522 | DEFVAR_LISP ("w32-charset-info-alist", | ||
| 2523 | &Vw32_charset_info_alist, | ||
| 2524 | doc: /* Alist linking Emacs character sets to Windows fonts and codepages. | ||
| 2525 | Each entry should be of the form: | ||
| 2526 | |||
| 2527 | (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)) | ||
| 2528 | |||
| 2529 | where CHARSET_NAME is a string used in font names to identify the charset, | ||
| 2530 | WINDOWS_CHARSET is a symbol that can be one of: | ||
| 2531 | |||
| 2532 | w32-charset-ansi, w32-charset-default, w32-charset-symbol, | ||
| 2533 | w32-charset-shiftjis, w32-charset-hangeul, w32-charset-gb2312, | ||
| 2534 | w32-charset-chinesebig5, w32-charset-johab, w32-charset-hebrew, | ||
| 2535 | w32-charset-arabic, w32-charset-greek, w32-charset-turkish, | ||
| 2536 | w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope, | ||
| 2537 | w32-charset-russian, w32-charset-mac, w32-charset-baltic, | ||
| 2538 | or w32-charset-oem. | ||
| 2539 | |||
| 2540 | CODEPAGE should be an integer specifying the codepage that should be used | ||
| 2541 | to display the character set, t to do no translation and output as Unicode, | ||
| 2542 | or nil to do no translation and output as 8 bit (or multibyte on far-east | ||
| 2543 | versions of Windows) characters. */); | ||
| 2544 | Vw32_charset_info_alist = Qnil; | ||
| 2545 | |||
| 2546 | DEFSYM (Qw32_charset_ansi, "w32-charset-ansi"); | ||
| 2547 | DEFSYM (Qw32_charset_symbol, "w32-charset-symbol"); | ||
| 2548 | DEFSYM (Qw32_charset_default, "w32-charset-default"); | ||
| 2549 | DEFSYM (Qw32_charset_shiftjis, "w32-charset-shiftjis"); | ||
| 2550 | DEFSYM (Qw32_charset_hangeul, "w32-charset-hangeul"); | ||
| 2551 | DEFSYM (Qw32_charset_chinesebig5, "w32-charset-chinesebig5"); | ||
| 2552 | DEFSYM (Qw32_charset_gb2312, "w32-charset-gb2312"); | ||
| 2553 | DEFSYM (Qw32_charset_oem, "w32-charset-oem"); | ||
| 2554 | DEFSYM (Qw32_charset_johab, "w32-charset-johab"); | ||
| 2555 | DEFSYM (Qw32_charset_easteurope, "w32-charset-easteurope"); | ||
| 2556 | DEFSYM (Qw32_charset_turkish, "w32-charset-turkish"); | ||
| 2557 | DEFSYM (Qw32_charset_baltic, "w32-charset-baltic"); | ||
| 2558 | DEFSYM (Qw32_charset_russian, "w32-charset-russian"); | ||
| 2559 | DEFSYM (Qw32_charset_arabic, "w32-charset-arabic"); | ||
| 2560 | DEFSYM (Qw32_charset_greek, "w32-charset-greek"); | ||
| 2561 | DEFSYM (Qw32_charset_hebrew, "w32-charset-hebrew"); | ||
| 2562 | DEFSYM (Qw32_charset_vietnamese, "w32-charset-vietnamese"); | ||
| 2563 | DEFSYM (Qw32_charset_thai, "w32-charset-thai"); | ||
| 2564 | DEFSYM (Qw32_charset_mac, "w32-charset-mac"); | ||
| 2565 | |||
| 2221 | defsubr (&Sx_select_font); | 2566 | defsubr (&Sx_select_font); |
| 2222 | 2567 | ||
| 2223 | w32font_driver.type = Qgdi; | 2568 | w32font_driver.type = Qgdi; |