aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2005-04-25 11:47:55 +0000
committerKaroly Lorentey2005-04-25 11:47:55 +0000
commit5ad1bc4dead80db3e81a6855714bc0b5817f5fc0 (patch)
treed9a6baba163ca50b60f19b3f63adeb29dac2071b /src
parent8d6f9bce72ee94ed6c297b79a181eac3f5beca74 (diff)
parent37c5c4a7273ea3e538d3aab8862645b9096af738 (diff)
downloademacs-5ad1bc4dead80db3e81a6855714bc0b5817f5fc0.tar.gz
emacs-5ad1bc4dead80db3e81a6855714bc0b5817f5fc0.zip
Merged from miles@gnu.org--gnu-2005 (patch 269)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-269 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-331
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog55
-rw-r--r--src/fns.c13
-rw-r--r--src/lisp.h1
-rw-r--r--src/macgui.h6
-rw-r--r--src/macterm.c724
-rw-r--r--src/xdisp.c13
-rw-r--r--src/xfaces.c18
7 files changed, 418 insertions, 412 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ac7d5fb07f3..e2a5fa1fd9c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,58 @@
12005-04-19 Kim F. Storm <storm@cua.dk>
2
3 * xdisp.c (setup_for_ellipsis): Reset saved_face_id to use default
4 face unless last visible char and first invisible char have the
5 same face. Also use default face if saved_face_id is undefined.
6
72005-04-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
8
9 * macgui.h (MacFontStruct): Remove member `fontname'. Add member
10 `full_name'.
11 [TARGET_API_MAC_CARBON] (MacFontStruct): Use type int for
12 mac_scriptcode member.
13
14 * macterm.c (Qbig5, Qcn_gb, Qsjis, Qeuc_kr): Remove variables.
15 (syms_of_mac): Don't initialize them.
16 (Vmac_charset_info_alist): New variable.
17 (syms_of_mac): Defvar it.
18 (create_text_encoding_info_alist): New function.
19 (decode_mac_font_name, mac_to_x_fontname)
20 (x_font_name_to_mac_font_name, init_font_name_table): Don't hard
21 code the correspondence among XLFD charsets, Mac script codes, and
22 Emacs coding systems. Use Vmac_charset_info_alist and result of
23 create_text_encoding_info_alist instead.
24 (init_font_name_table) [TARGET_API_MAC_CARBON]: Use Font Manager
25 routines also on Mac OS Classic.
26 (init_font_name_table) [!TARGET_API_MAC_CARBON]: Use
27 add_font_name_table_entry.
28 (mac_do_list_fonts): Regard 0 in XLFD scaleble fields as
29 specified. Derive unspecified scalable fields from specified one.
30 (x_list_fonts): Consider Valternate_fontname_alist.
31 (kDefaultFontSize): Change value from 9 to 12.
32 (XLoadQueryFont): Get decoded font family, font face, and charset
33 from x_font_name_to_mac_font_name. Set full name of loaded font.
34 (mac_unload_font): Free `full_name' member.
35 (x_load_font): Don't try XLoadQueryFont if x_list_fonts returns
36 NULL. Copy full_name member of struct MacFontStruct to that of
37 struct font_info.
38
392005-04-19 Kim F. Storm <storm@cua.dk>
40
41 * xdisp.c (handle_stop): Set saved_face_id to current face if
42 selective_display_ellipsis_p so ellipsis will be shown in same
43 face as preceding text.
44 (setup_for_ellipsis): Don't set saved_face_id here.
45 (next_element_from_display_vector): Default to saved_face_id.
46
47 * fns.c (Fsafe_get): New function.
48 (syms_of_fns): Defsubr it.
49
50 * lisp.h (Fsafe_get): EXFUN it.
51
52 * xfaces.c (resolve_face_name): Use Fsafe_get to avoid redisplay
53 loops in case of bad face property lists. Limit number of face
54 alias lookups to 10 (in case of face alias loops).
55
12005-04-18 Kim F. Storm <storm@cua.dk> 562005-04-18 Kim F. Storm <storm@cua.dk>
2 57
3 * dispextern.h (struct glyph_row): New member overlay_arrow_bitmap. 58 * dispextern.h (struct glyph_row): New member overlay_arrow_bitmap.
diff --git a/src/fns.c b/src/fns.c
index daa9e10c465..088b6ca500d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2051,6 +2051,18 @@ This is the last value stored with `(put SYMBOL PROPNAME VALUE)'. */)
2051 return Fplist_get (XSYMBOL (symbol)->plist, propname); 2051 return Fplist_get (XSYMBOL (symbol)->plist, propname);
2052} 2052}
2053 2053
2054DEFUN ("safe-get", Fsafe_get, Ssafe_get, 2, 2, 0,
2055 doc: /* Return the value of SYMBOL's PROPNAME property.
2056This is the last value stored with `(put SYMBOL PROPNAME VALUE)'.
2057This function never signals an error. */)
2058 (symbol, propname)
2059 Lisp_Object symbol, propname;
2060{
2061 if (!SYMBOLP (symbol))
2062 return Qnil;
2063 return Fsafe_plist_get (XSYMBOL (symbol)->plist, propname);
2064}
2065
2054DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0, 2066DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0,
2055 doc: /* Change value in PLIST of PROP to VAL. 2067 doc: /* Change value in PLIST of PROP to VAL.
2056PLIST is a property list, which is a list of the form 2068PLIST is a property list, which is a list of the form
@@ -5792,6 +5804,7 @@ used if both `use-dialog-box' and this variable are non-nil. */);
5792 defsubr (&Splist_get); 5804 defsubr (&Splist_get);
5793 defsubr (&Ssafe_plist_get); 5805 defsubr (&Ssafe_plist_get);
5794 defsubr (&Sget); 5806 defsubr (&Sget);
5807 defsubr (&Ssafe_get);
5795 defsubr (&Splist_put); 5808 defsubr (&Splist_put);
5796 defsubr (&Sput); 5809 defsubr (&Sput);
5797 defsubr (&Slax_plist_get); 5810 defsubr (&Slax_plist_get);
diff --git a/src/lisp.h b/src/lisp.h
index e1727697802..c3ae08b8d76 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2322,6 +2322,7 @@ EXFUN (Fsort, 2);
2322EXFUN (Freverse, 1); 2322EXFUN (Freverse, 1);
2323EXFUN (Fnreverse, 1); 2323EXFUN (Fnreverse, 1);
2324EXFUN (Fget, 2); 2324EXFUN (Fget, 2);
2325EXFUN (Fsafe_get, 2);
2325EXFUN (Fput, 3); 2326EXFUN (Fput, 3);
2326EXFUN (Fequal, 2); 2327EXFUN (Fequal, 2);
2327EXFUN (Ffillarray, 2); 2328EXFUN (Ffillarray, 2);
diff --git a/src/macgui.h b/src/macgui.h
index 96fd54a603b..5d4f1894e2e 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -101,12 +101,16 @@ typedef struct _XCharStruct
101 (xcs).descent = (bds).bottom) 101 (xcs).descent = (bds).bottom)
102 102
103struct MacFontStruct { 103struct MacFontStruct {
104 char *fontname; 104 char *full_name;
105 105
106 short mac_fontnum; /* font number of font used in this window */ 106 short mac_fontnum; /* font number of font used in this window */
107 int mac_fontsize; /* size of font */ 107 int mac_fontsize; /* size of font */
108 short mac_fontface; /* plain, bold, italics, etc. */ 108 short mac_fontface; /* plain, bold, italics, etc. */
109#if TARGET_API_MAC_CARBON
110 int mac_scriptcode; /* Mac OS script code for font used */
111#else
109 short mac_scriptcode; /* Mac OS script code for font used */ 112 short mac_scriptcode; /* Mac OS script code for font used */
113#endif
110 114
111#if 0 115#if 0
112 SInt16 mFontNum; /* font number of font used in this window */ 116 SInt16 mFontNum; /* font number of font used in this window */
diff --git a/src/macterm.c b/src/macterm.c
index 7bef378b590..1c7893e8d03 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -5841,121 +5841,59 @@ char **font_name_table = NULL;
5841int font_name_table_size = 0; 5841int font_name_table_size = 0;
5842int font_name_count = 0; 5842int font_name_count = 0;
5843 5843
5844#if 0 5844/* Alist linking character set strings to Mac text encoding and Emacs
5845/* compare two strings ignoring case */ 5845 coding system. */
5846static int 5846static Lisp_Object Vmac_charset_info_alist;
5847stricmp (const char *s, const char *t)
5848{
5849 for ( ; tolower (*s) == tolower (*t); s++, t++)
5850 if (*s == '\0')
5851 return 0;
5852 return tolower (*s) - tolower (*t);
5853}
5854 5847
5855/* compare two strings ignoring case and handling wildcard */ 5848static Lisp_Object
5856static int 5849create_text_encoding_info_alist ()
5857wildstrieq (char *s1, char *s2)
5858{
5859 if (strcmp (s1, "*") == 0 || strcmp (s2, "*") == 0)
5860 return true;
5861
5862 return stricmp (s1, s2) == 0;
5863}
5864
5865/* Assume parameter 1 is fully qualified, no wildcards. */
5866static int
5867mac_font_pattern_match (fontname, pattern)
5868 char * fontname;
5869 char * pattern;
5870{ 5850{
5871 char *regex = (char *) alloca (strlen (pattern) * 2 + 3); 5851 Lisp_Object result = Qnil, rest;
5872 char *font_name_copy = (char *) alloca (strlen (fontname) + 1);
5873 char *ptr;
5874 5852
5875 /* Copy fontname so we can modify it during comparison. */ 5853 for (rest = Vmac_charset_info_alist; CONSP (rest); rest = XCDR (rest))
5876 strcpy (font_name_copy, fontname); 5854 {
5855 Lisp_Object charset_info = XCAR (rest);
5856 Lisp_Object charset, coding_system, text_encoding;
5857 Lisp_Object existing_info;
5877 5858
5878 ptr = regex; 5859 if (!(CONSP (charset_info)
5879 *ptr++ = '^'; 5860 && STRINGP (charset = XCAR (charset_info))
5861 && CONSP (XCDR (charset_info))
5862 && INTEGERP (text_encoding = XCAR (XCDR (charset_info)))
5863 && CONSP (XCDR (XCDR (charset_info)))
5864 && SYMBOLP (coding_system = XCAR (XCDR (XCDR (charset_info))))))
5865 continue;
5880 5866
5881 /* Turn pattern into a regexp and do a regexp match. */ 5867 existing_info = assq_no_quit (text_encoding, result);
5882 for (; *pattern; pattern++) 5868 if (NILP (existing_info))
5883 { 5869 result = Fcons (list3 (text_encoding, coding_system, charset),
5884 if (*pattern == '?') 5870 result);
5885 *ptr++ = '.';
5886 else if (*pattern == '*')
5887 {
5888 *ptr++ = '.';
5889 *ptr++ = '*';
5890 }
5891 else 5871 else
5892 *ptr++ = *pattern; 5872 if (NILP (Fmember (charset, XCDR (XCDR (existing_info)))))
5873 XSETCDR (XCDR (existing_info),
5874 Fcons (charset, XCDR (XCDR (existing_info))));
5893 } 5875 }
5894 *ptr = '$';
5895 *(ptr + 1) = '\0';
5896
5897 return (fast_c_string_match_ignore_case (build_string (regex),
5898 font_name_copy) >= 0);
5899}
5900
5901/* Two font specs are considered to match if their foundry, family,
5902 weight, slant, and charset match. */
5903static int
5904mac_font_match (char *mf, char *xf)
5905{
5906 char m_foundry[50], m_family[50], m_weight[20], m_slant[2], m_charset[20];
5907 char x_foundry[50], x_family[50], x_weight[20], x_slant[2], x_charset[20];
5908
5909 if (sscanf (mf, "-%49[^-]-%49[^-]-%19[^-]-%1[^-]-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%19s",
5910 m_foundry, m_family, m_weight, m_slant, m_charset) != 5)
5911 return mac_font_pattern_match (mf, xf);
5912 5876
5913 if (sscanf (xf, "-%49[^-]-%49[^-]-%19[^-]-%1[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%19s", 5877 return result;
5914 x_foundry, x_family, x_weight, x_slant, x_charset) != 5)
5915 return mac_font_pattern_match (mf, xf);
5916
5917 return (wildstrieq (m_foundry, x_foundry)
5918 && wildstrieq (m_family, x_family)
5919 && wildstrieq (m_weight, x_weight)
5920 && wildstrieq (m_slant, x_slant)
5921 && wildstrieq (m_charset, x_charset))
5922 || mac_font_pattern_match (mf, xf);
5923} 5878}
5924#endif
5925 5879
5926static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr;
5927 5880
5928static void 5881static void
5929decode_mac_font_name (name, size, scriptcode) 5882decode_mac_font_name (name, size, coding_system)
5930 char *name; 5883 char *name;
5931 int size; 5884 int size;
5932#if TARGET_API_MAC_CARBON 5885 Lisp_Object coding_system;
5933 int scriptcode;
5934#else
5935 short scriptcode;
5936#endif
5937{ 5886{
5938 Lisp_Object coding_system;
5939 struct coding_system coding; 5887 struct coding_system coding;
5940 char *buf; 5888 char *buf, *p;
5941 5889
5942 switch (scriptcode) 5890 for (p = name; *p; p++)
5943 { 5891 if (!isascii (*p) || iscntrl (*p))
5944 case smTradChinese:
5945 coding_system = Qbig5;
5946 break; 5892 break;
5947 case smSimpChinese: 5893
5948 coding_system = Qcn_gb; 5894 if (*p == '\0'
5949 break; 5895 || NILP (coding_system) || NILP (Fcoding_system_p (coding_system)))
5950 case smJapanese: 5896 return;
5951 coding_system = Qsjis;
5952 break;
5953 case smKorean:
5954 coding_system = Qeuc_kr;
5955 break;
5956 default:
5957 return;
5958 }
5959 5897
5960 setup_coding_system (coding_system, &coding); 5898 setup_coding_system (coding_system, &coding);
5961 coding.src_multibyte = 0; 5899 coding.src_multibyte = 0;
@@ -5971,68 +5909,26 @@ decode_mac_font_name (name, size, scriptcode)
5971 5909
5972 5910
5973static char * 5911static char *
5974mac_to_x_fontname (name, size, style, scriptcode) 5912mac_to_x_fontname (name, size, style, charset)
5975 char *name; 5913 char *name;
5976 int size; 5914 int size;
5977 Style style; 5915 Style style;
5978#if TARGET_API_MAC_CARBON 5916 char *charset;
5979 int scriptcode;
5980#else
5981 short scriptcode;
5982#endif
5983{ 5917{
5984 char foundry[32], family[32], cs[32]; 5918 char foundry[32], family[32], cs[32];
5985 char xf[256], *result, *p; 5919 char xf[256], *result, *p;
5986 5920
5987 if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) != 3) 5921 if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) == 3)
5922 charset = cs;
5923 else
5988 { 5924 {
5989 strcpy(foundry, "Apple"); 5925 strcpy(foundry, "Apple");
5990 strcpy(family, name); 5926 strcpy(family, name);
5991
5992 switch (scriptcode)
5993 {
5994 case smTradChinese: /* == kTextEncodingMacChineseTrad */
5995 strcpy(cs, "big5-0");
5996 break;
5997 case smSimpChinese: /* == kTextEncodingMacChineseSimp */
5998 strcpy(cs, "gb2312.1980-0");
5999 break;
6000 case smJapanese: /* == kTextEncodingMacJapanese */
6001 strcpy(cs, "jisx0208.1983-sjis");
6002 break;
6003 case -smJapanese:
6004 /* Each Apple Japanese font is entered into the font table
6005 twice: once as a jisx0208.1983-sjis font and once as a
6006 jisx0201.1976-0 font. The latter can be used to display
6007 the ascii charset and katakana-jisx0201 charset. A
6008 negative script code signals that the name of this latter
6009 font is being built. */
6010 strcpy(cs, "jisx0201.1976-0");
6011 break;
6012 case smKorean: /* == kTextEncodingMacKorean */
6013 strcpy(cs, "ksc5601.1989-0");
6014 break;
6015#if TARGET_API_MAC_CARBON
6016 case kTextEncodingMacCyrillic:
6017 strcpy(cs, "mac-cyrillic");
6018 break;
6019 case kTextEncodingMacCentralEurRoman:
6020 strcpy(cs, "mac-centraleurroman");
6021 break;
6022 case kTextEncodingMacSymbol:
6023 case kTextEncodingMacDingbats:
6024 strcpy(cs, "adobe-fontspecific");
6025 break;
6026#endif
6027 default:
6028 strcpy(cs, "mac-roman");
6029 break;
6030 }
6031 } 5927 }
6032 5928
6033 sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s", 5929 sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s",
6034 foundry, family, style & bold ? "bold" : "medium", 5930 foundry, family, style & bold ? "bold" : "medium",
6035 style & italic ? 'i' : 'r', size, size * 10, size * 10, cs); 5931 style & italic ? 'i' : 'r', size, size * 10, size * 10, charset);
6036 5932
6037 result = (char *) xmalloc (strlen (xf) + 1); 5933 result = (char *) xmalloc (strlen (xf) + 1);
6038 strcpy (result, xf); 5934 strcpy (result, xf);
@@ -6050,10 +5946,13 @@ mac_to_x_fontname (name, size, style, scriptcode)
6050 "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both types of font 5946 "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both types of font
6051 names are handled accordingly. */ 5947 names are handled accordingly. */
6052static void 5948static void
6053x_font_name_to_mac_font_name (char *xf, char *mf) 5949x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs)
5950 char *xf, *mf, *mf_decoded;
5951 Style *style;
5952 char *cs;
6054{ 5953{
6055 char foundry[32], family[32], weight[20], slant[2], cs[32]; 5954 char foundry[32], family[32], weight[20], slant[2], *p;
6056 Lisp_Object coding_system = Qnil; 5955 Lisp_Object charset_info, coding_system = Qnil;
6057 struct coding_system coding; 5956 struct coding_system coding;
6058 5957
6059 strcpy (mf, ""); 5958 strcpy (mf, "");
@@ -6064,30 +5963,36 @@ x_font_name_to_mac_font_name (char *xf, char *mf)
6064 foundry, family, weight, slant, cs) != 5) 5963 foundry, family, weight, slant, cs) != 5)
6065 return; 5964 return;
6066 5965
6067 if (strcmp (cs, "big5-0") == 0) 5966 *style = normal;
6068 coding_system = Qbig5; 5967 if (strcmp (weight, "bold") == 0)
6069 else if (strcmp (cs, "gb2312.1980-0") == 0) 5968 *style |= bold;
6070 coding_system = Qcn_gb; 5969 if (*slant == 'i')
6071 else if (strcmp (cs, "jisx0208.1983-sjis") == 0 5970 *style |= italic;
6072 || strcmp (cs, "jisx0201.1976-0") == 0) 5971
6073 coding_system = Qsjis; 5972 charset_info = Fassoc (build_string (cs), Vmac_charset_info_alist);
6074 else if (strcmp (cs, "ksc5601.1989-0") == 0) 5973 if (!NILP (charset_info))
6075 coding_system = Qeuc_kr; 5974 {
6076 else if (strcmp (cs, "mac-roman") == 0 5975 strcpy (mf_decoded, family);
6077 || strcmp (cs, "mac-cyrillic") == 0 5976 coding_system = Fcar (Fcdr (Fcdr (charset_info)));
6078 || strcmp (cs, "mac-centraleurroman") == 0 5977 }
6079 || strcmp (cs, "adobe-fontspecific") == 0)
6080 strcpy (mf, family);
6081 else 5978 else
6082 sprintf (mf, "%s-%s-%s", foundry, family, cs); 5979 sprintf (mf_decoded, "%s-%s-%s", foundry, family, cs);
6083 5980
6084 if (!NILP (coding_system)) 5981 for (p = mf_decoded; *p; p++)
5982 if (!isascii (*p) || iscntrl (*p))
5983 break;
5984
5985 if (*p == '\0'
5986 || NILP (coding_system) || NILP (Fcoding_system_p (coding_system)))
5987 strcpy (mf, mf_decoded);
5988 else
6085 { 5989 {
6086 setup_coding_system (coding_system, &coding); 5990 setup_coding_system (coding_system, &coding);
6087 coding.src_multibyte = 1; 5991 coding.src_multibyte = 1;
6088 coding.dst_multibyte = 1; 5992 coding.dst_multibyte = 1;
6089 coding.mode |= CODING_MODE_LAST_BLOCK; 5993 coding.mode |= CODING_MODE_LAST_BLOCK;
6090 encode_coding (&coding, family, mf, strlen (family), sizeof (Str32) - 1); 5994 encode_coding (&coding, mf_decoded, mf,
5995 strlen (mf_decoded), sizeof (Str32) - 1);
6091 mf[coding.produced] = '\0'; 5996 mf[coding.produced] = '\0';
6092 } 5997 }
6093} 5998}
@@ -6122,181 +6027,180 @@ static void
6122init_font_name_table () 6027init_font_name_table ()
6123{ 6028{
6124#if TARGET_API_MAC_CARBON 6029#if TARGET_API_MAC_CARBON
6125 SInt32 sv; 6030 FMFontFamilyIterator ffi;
6031 FMFontFamilyInstanceIterator ffii;
6032 FMFontFamily ff;
6033 Lisp_Object text_encoding_info_alist;
6034 struct gcpro gcpro1;
6035
6036 /* Create a dummy instance iterator here to avoid creating and
6037 destroying it in the loop. */
6038 if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr)
6039 return;
6040 /* Create an iterator to enumerate the font families. */
6041 if (FMCreateFontFamilyIterator (NULL, NULL, kFMDefaultOptions, &ffi)
6042 != noErr)
6043 {
6044 FMDisposeFontFamilyInstanceIterator (&ffii);
6045 return;
6046 }
6047
6048 text_encoding_info_alist = create_text_encoding_info_alist ();
6126 6049
6127 if (Gestalt (gestaltSystemVersion, &sv) == noErr && sv >= 0x1000) 6050 GCPRO1 (text_encoding_info_alist);
6051
6052 while (FMGetNextFontFamily (&ffi, &ff) == noErr)
6128 { 6053 {
6129 FMFontFamilyIterator ffi; 6054 Str255 name;
6130 FMFontFamilyInstanceIterator ffii; 6055 FMFont font;
6131 FMFontFamily ff; 6056 FMFontStyle style;
6057 FMFontSize size;
6058 TextEncoding encoding;
6059 TextEncodingBase sc;
6060 Lisp_Object text_encoding_info;
6132 6061
6133 /* Create a dummy instance iterator here to avoid creating and 6062 if (FMGetFontFamilyName (ff, name) != noErr)
6134 destroying it in the loop. */ 6063 break;
6135 if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr) 6064 p2cstr (name);
6136 return; 6065 if (*name == '.')
6137 /* Create an iterator to enumerate the font families. */ 6066 continue;
6138 if (FMCreateFontFamilyIterator (NULL, NULL, kFMDefaultOptions, &ffi)
6139 != noErr)
6140 {
6141 FMDisposeFontFamilyInstanceIterator (&ffii);
6142 return;
6143 }
6144 6067
6145 while (FMGetNextFontFamily (&ffi, &ff) == noErr) 6068 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
6146 { 6069 break;
6147 Str255 name; 6070 sc = GetTextEncodingBase (encoding);
6148 FMFont font; 6071 text_encoding_info = assq_no_quit (make_number (sc),
6149 FMFontStyle style; 6072 text_encoding_info_alist);
6150 FMFontSize size; 6073 if (!NILP (text_encoding_info))
6151 TextEncoding encoding; 6074 decode_mac_font_name (name, sizeof (name),
6152 TextEncodingBase sc; 6075 XCAR (XCDR (text_encoding_info)));
6153 6076 else
6154 if (FMGetFontFamilyName (ff, name) != noErr) 6077 text_encoding_info = assq_no_quit (make_number (kTextEncodingMacRoman),
6155 break; 6078 text_encoding_info_alist);
6156 p2cstr (name);
6157 if (*name == '.')
6158 continue;
6159 6079
6160 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr) 6080 /* Point the instance iterator at the current font family. */
6161 break; 6081 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
6162 sc = GetTextEncodingBase (encoding); 6082 break;
6163 decode_mac_font_name (name, sizeof (name), sc);
6164 6083
6165 /* Point the instance iterator at the current font family. */ 6084 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
6166 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) 6085 == noErr)
6167 break; 6086 {
6087 Lisp_Object rest = XCDR (XCDR (text_encoding_info));
6168 6088
6169 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size) 6089 for (; !NILP (rest); rest = XCDR (rest))
6170 == noErr)
6171 { 6090 {
6172 /* Both jisx0208.1983-sjis and jisx0201.1976-0 parts are 6091 char *cs = SDATA (XCAR (rest));
6173 contained in Apple Japanese (SJIS) font. */ 6092
6174 again:
6175 if (size == 0) 6093 if (size == 0)
6176 { 6094 {
6177 add_font_name_table_entry (mac_to_x_fontname (name, size, 6095 add_font_name_table_entry (mac_to_x_fontname (name, size,
6178 style, sc)); 6096 style, cs));
6179 add_font_name_table_entry (mac_to_x_fontname (name, size, 6097 add_font_name_table_entry (mac_to_x_fontname (name, size,
6180 italic, sc)); 6098 italic, cs));
6181 add_font_name_table_entry (mac_to_x_fontname (name, size, 6099 add_font_name_table_entry (mac_to_x_fontname (name, size,
6182 bold, sc)); 6100 bold, cs));
6183 add_font_name_table_entry (mac_to_x_fontname (name, size, 6101 add_font_name_table_entry (mac_to_x_fontname (name, size,
6184 italic | bold, 6102 italic | bold,
6185 sc)); 6103 cs));
6186 } 6104 }
6187 else 6105 else
6188 add_font_name_table_entry (mac_to_x_fontname (name, size,
6189 style, sc));
6190 if (sc == smJapanese)
6191 { 6106 {
6192 sc = -smJapanese; 6107 add_font_name_table_entry (mac_to_x_fontname (name, size,
6193 goto again; 6108 style, cs));
6194 } 6109 }
6195 else if (sc == -smJapanese)
6196 sc = smJapanese;
6197 } 6110 }
6198 } 6111 }
6199
6200 /* Dispose of the iterators. */
6201 FMDisposeFontFamilyIterator (&ffi);
6202 FMDisposeFontFamilyInstanceIterator (&ffii);
6203 } 6112 }
6204 else 6113
6114 UNGCPRO;
6115
6116 /* Dispose of the iterators. */
6117 FMDisposeFontFamilyIterator (&ffi);
6118 FMDisposeFontFamilyInstanceIterator (&ffii);
6119#else /* !TARGET_API_MAC_CARBON */
6120 GrafPtr port;
6121 SInt16 fontnum, old_fontnum;
6122 int num_mac_fonts = CountResources('FOND');
6123 int i, j;
6124 Handle font_handle, font_handle_2;
6125 short id, scriptcode;
6126 ResType type;
6127 Str32 name;
6128 struct FontAssoc *fat;
6129 struct AsscEntry *assc_entry;
6130 Lisp_Object text_encoding_info_alist, text_encoding_info;
6131 struct gcpro gcpro1;
6132
6133 GetPort (&port); /* save the current font number used */
6134 old_fontnum = port->txFont;
6135
6136 text_encoding_info_alist = create_text_encoding_info_alist ();
6137
6138 GCPRO1 (text_encoding_info_alist);
6139
6140 for (i = 1; i <= num_mac_fonts; i++) /* get all available fonts */
6205 { 6141 {
6206#endif /* TARGET_API_MAC_CARBON */ 6142 font_handle = GetIndResource ('FOND', i);
6207 GrafPtr port; 6143 if (!font_handle)
6208 SInt16 fontnum, old_fontnum; 6144 continue;
6209 int num_mac_fonts = CountResources('FOND');
6210 int i, j;
6211 Handle font_handle, font_handle_2;
6212 short id, scriptcode;
6213 ResType type;
6214 Str32 name;
6215 struct FontAssoc *fat;
6216 struct AsscEntry *assc_entry;
6217
6218 GetPort (&port); /* save the current font number used */
6219#if TARGET_API_MAC_CARBON
6220 old_fontnum = GetPortTextFont (port);
6221#else
6222 old_fontnum = port->txFont;
6223#endif
6224 6145
6225 for (i = 1; i <= num_mac_fonts; i++) /* get all available fonts */ 6146 GetResInfo (font_handle, &id, &type, name);
6226 { 6147 GetFNum (name, &fontnum);
6227 font_handle = GetIndResource ('FOND', i); 6148 p2cstr (name);
6228 if (!font_handle) 6149 if (fontnum == 0)
6229 continue; 6150 continue;
6230 6151
6231 GetResInfo (font_handle, &id, &type, name); 6152 TextFont (fontnum);
6232 GetFNum (name, &fontnum); 6153 scriptcode = FontToScript (fontnum);
6233 p2cstr (name); 6154 text_encoding_info = assq_no_quit (make_number (scriptcode),
6234 if (fontnum == 0) 6155 text_encoding_info_alist);
6235 continue; 6156 if (!NILP (text_encoding_info))
6157 decode_mac_font_name (name, sizeof (name),
6158 XCAR (XCDR (text_encoding_info)));
6159 else
6160 text_encoding_info = assq_no_quit (make_number (smRoman),
6161 text_encoding_info_alist);
6162 do
6163 {
6164 HLock (font_handle);
6236 6165
6237 TextFont (fontnum); 6166 if (GetResourceSizeOnDisk (font_handle)
6238 scriptcode = FontToScript (fontnum); 6167 >= sizeof (struct FamRec))
6239 decode_mac_font_name (name, sizeof (name), scriptcode);
6240 do
6241 { 6168 {
6242 HLock (font_handle); 6169 fat = (struct FontAssoc *) (*font_handle
6243 6170 + sizeof (struct FamRec));
6244 if (GetResourceSizeOnDisk (font_handle) 6171 assc_entry
6245 >= sizeof (struct FamRec)) 6172 = (struct AsscEntry *) (*font_handle
6173 + sizeof (struct FamRec)
6174 + sizeof (struct FontAssoc));
6175
6176 for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
6246 { 6177 {
6247 fat = (struct FontAssoc *) (*font_handle 6178 Lisp_Object rest = XCDR (XCDR (text_encoding_info));
6248 + sizeof (struct FamRec)); 6179
6249 assc_entry 6180 for (; !NILP (rest); rest = XCDR (rest))
6250 = (struct AsscEntry *) (*font_handle
6251 + sizeof (struct FamRec)
6252 + sizeof (struct FontAssoc));
6253
6254 for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
6255 { 6181 {
6256 if (font_name_table_size == 0) 6182 char *cs = SDATA (XCAR (rest));
6257 { 6183
6258 font_name_table_size = 16; 6184 add_font_name_table_entry (mac_to_x_fontname (name,
6259 font_name_table = (char **) 6185 assc_entry->fontSize,
6260 xmalloc (font_name_table_size * sizeof (char *)); 6186 assc_entry->fontStyle,
6261 } 6187 cs));
6262 else if (font_name_count >= font_name_table_size)
6263 {
6264 font_name_table_size += 16;
6265 font_name_table = (char **)
6266 xrealloc (font_name_table,
6267 font_name_table_size * sizeof (char *));
6268 }
6269 font_name_table[font_name_count++]
6270 = mac_to_x_fontname (name,
6271 assc_entry->fontSize,
6272 assc_entry->fontStyle,
6273 scriptcode);
6274 /* Both jisx0208.1983-sjis and jisx0201.1976-0
6275 parts are contained in Apple Japanese (SJIS)
6276 font. */
6277 if (smJapanese == scriptcode)
6278 {
6279 font_name_table[font_name_count++]
6280 = mac_to_x_fontname (name,
6281 assc_entry->fontSize,
6282 assc_entry->fontStyle,
6283 -smJapanese);
6284 }
6285 } 6188 }
6286 } 6189 }
6287
6288 HUnlock (font_handle);
6289 font_handle_2 = GetNextFOND (font_handle);
6290 ReleaseResource (font_handle);
6291 font_handle = font_handle_2;
6292 } 6190 }
6293 while (ResError () == noErr && font_handle);
6294 }
6295 6191
6296 TextFont (old_fontnum); 6192 HUnlock (font_handle);
6297#if TARGET_API_MAC_CARBON 6193 font_handle_2 = GetNextFOND (font_handle);
6194 ReleaseResource (font_handle);
6195 font_handle = font_handle_2;
6196 }
6197 while (ResError () == noErr && font_handle);
6298 } 6198 }
6299#endif /* TARGET_API_MAC_CARBON */ 6199
6200 UNGCPRO;
6201
6202 TextFont (old_fontnum);
6203#endif /* !TARGET_API_MAC_CARBON */
6300} 6204}
6301 6205
6302 6206
@@ -6384,7 +6288,7 @@ mac_do_list_fonts (pattern, maxnames)
6384 ptr++; 6288 ptr++;
6385 if (i == *field) 6289 if (i == *field)
6386 { 6290 {
6387 if ('1' <= *ptr && *ptr <= '9') 6291 if ('0' <= *ptr && *ptr <= '9')
6388 { 6292 {
6389 *val = *ptr++ - '0'; 6293 *val = *ptr++ - '0';
6390 while ('0' <= *ptr && *ptr <= '9' && *val < 10000) 6294 while ('0' <= *ptr && *ptr <= '9' && *val < 10000)
@@ -6402,21 +6306,21 @@ mac_do_list_fonts (pattern, maxnames)
6402 6306
6403 if (i == 14 && ptr == NULL) 6307 if (i == 14 && ptr == NULL)
6404 { 6308 {
6405 if (scl_val[XLFD_SCL_POINT_SIZE] > 0) 6309 if (scl_val[XLFD_SCL_PIXEL_SIZE] < 0)
6406 { 6310 scl_val[XLFD_SCL_PIXEL_SIZE] =
6407 scl_val[XLFD_SCL_PIXEL_SIZE] = scl_val[XLFD_SCL_POINT_SIZE] / 10; 6311 (scl_val[XLFD_SCL_POINT_SIZE] > 0 ? scl_val[XLFD_SCL_POINT_SIZE] / 10
6408 scl_val[XLFD_SCL_AVGWIDTH] = scl_val[XLFD_SCL_POINT_SIZE]; 6312 : (scl_val[XLFD_SCL_AVGWIDTH] > 0 ? scl_val[XLFD_SCL_AVGWIDTH] / 10
6409 } 6313 : -1));
6410 else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0) 6314 if (scl_val[XLFD_SCL_POINT_SIZE] < 0)
6411 { 6315 scl_val[XLFD_SCL_POINT_SIZE] =
6412 scl_val[XLFD_SCL_POINT_SIZE] = 6316 (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 ? scl_val[XLFD_SCL_PIXEL_SIZE] * 10
6413 scl_val[XLFD_SCL_AVGWIDTH] = scl_val[XLFD_SCL_PIXEL_SIZE] * 10; 6317 : (scl_val[XLFD_SCL_AVGWIDTH] > 0 ? scl_val[XLFD_SCL_AVGWIDTH]
6414 } 6318 : -1));
6415 else if (scl_val[XLFD_SCL_AVGWIDTH] > 0) 6319 if (scl_val[XLFD_SCL_AVGWIDTH] < 0)
6416 { 6320 scl_val[XLFD_SCL_AVGWIDTH] =
6417 scl_val[XLFD_SCL_PIXEL_SIZE] = scl_val[XLFD_SCL_AVGWIDTH] / 10; 6321 (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 ? scl_val[XLFD_SCL_PIXEL_SIZE] * 10
6418 scl_val[XLFD_SCL_POINT_SIZE] = scl_val[XLFD_SCL_AVGWIDTH]; 6322 : (scl_val[XLFD_SCL_POINT_SIZE] > 0 ? scl_val[XLFD_SCL_POINT_SIZE]
6419 } 6323 : -1));
6420 } 6324 }
6421 else 6325 else
6422 scl_val[XLFD_SCL_PIXEL_SIZE] = -1; 6326 scl_val[XLFD_SCL_PIXEL_SIZE] = -1;
@@ -6507,49 +6411,62 @@ mac_do_list_fonts (pattern, maxnames)
6507 return font_list; 6411 return font_list;
6508} 6412}
6509 6413
6510/* Return a list of at most MAXNAMES font specs matching the one in 6414/* Return a list of names of available fonts matching PATTERN on frame F.
6511 PATTERN. Cache matching fonts for patterns in 6415
6512 dpyinfo->name_list_element to avoid looking them up again by 6416 Frame F null means we have not yet created any frame on Mac, and
6513 calling mac_font_pattern_match (slow). Return as many matching 6417 consult the first display in x_display_list. MAXNAMES sets a limit
6514 fonts as possible if MAXNAMES = -1. */ 6418 on how many fonts to match. */
6515 6419
6516Lisp_Object 6420Lisp_Object
6517x_list_fonts (struct frame *f, 6421x_list_fonts (f, pattern, size, maxnames)
6518 Lisp_Object pattern, 6422 struct frame *f;
6519 int size, 6423 Lisp_Object pattern;
6520 int maxnames) 6424 int size, maxnames;
6521{ 6425{
6522 Lisp_Object newlist = Qnil, tem, key; 6426 Lisp_Object list = Qnil, patterns, tem, key;
6523 struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL; 6427 struct mac_display_info *dpyinfo
6428 = f ? FRAME_MAC_DISPLAY_INFO (f) : x_display_list;
6524 6429
6525 if (dpyinfo) 6430 xassert (size <= 0);
6431
6432 patterns = Fassoc (pattern, Valternate_fontname_alist);
6433 if (NILP (patterns))
6434 patterns = Fcons (pattern, Qnil);
6435
6436 for (; CONSP (patterns); patterns = XCDR (patterns))
6526 { 6437 {
6438 pattern = XCAR (patterns);
6439
6440 if (!STRINGP (pattern))
6441 continue;
6442
6527 tem = XCAR (XCDR (dpyinfo->name_list_element)); 6443 tem = XCAR (XCDR (dpyinfo->name_list_element));
6528 key = Fcons (pattern, make_number (maxnames)); 6444 key = Fcons (pattern, make_number (maxnames));
6529 6445
6530 newlist = Fassoc (key, tem); 6446 list = Fassoc (key, tem);
6531 if (!NILP (newlist)) 6447 if (!NILP (list))
6532 { 6448 {
6533 newlist = Fcdr_safe (newlist); 6449 list = Fcdr_safe (list);
6450 /* We have a cashed list. Don't have to get the list again. */
6534 goto label_cached; 6451 goto label_cached;
6535 } 6452 }
6536 }
6537 6453
6538 BLOCK_INPUT; 6454 BLOCK_INPUT;
6539 newlist = mac_do_list_fonts (SDATA (pattern), maxnames); 6455 list = mac_do_list_fonts (SDATA (pattern), maxnames);
6540 UNBLOCK_INPUT; 6456 UNBLOCK_INPUT;
6541 6457
6542 /* MAC_TODO: add code for matching outline fonts here */ 6458 /* MAC_TODO: add code for matching outline fonts here */
6543 6459
6544 if (dpyinfo) 6460 /* Now store the result in the cache. */
6545 {
6546 XSETCAR (XCDR (dpyinfo->name_list_element), 6461 XSETCAR (XCDR (dpyinfo->name_list_element),
6547 Fcons (Fcons (key, newlist), 6462 Fcons (Fcons (key, list),
6548 XCAR (XCDR (dpyinfo->name_list_element)))); 6463 XCAR (XCDR (dpyinfo->name_list_element))));
6464
6465 label_cached:
6466 if (NILP (list)) continue; /* Try the remaining alternatives. */
6549 } 6467 }
6550 label_cached:
6551 6468
6552 return newlist; 6469 return list;
6553} 6470}
6554 6471
6555 6472
@@ -6668,7 +6585,7 @@ is_fully_specified_xlfd (char *p)
6668} 6585}
6669 6586
6670 6587
6671const int kDefaultFontSize = 9; 6588const int kDefaultFontSize = 12;
6672 6589
6673 6590
6674/* XLoadQueryFont creates and returns an internal representation for a 6591/* XLoadQueryFont creates and returns an internal representation for a
@@ -6680,17 +6597,25 @@ const int kDefaultFontSize = 9;
6680static MacFontStruct * 6597static MacFontStruct *
6681XLoadQueryFont (Display *dpy, char *fontname) 6598XLoadQueryFont (Display *dpy, char *fontname)
6682{ 6599{
6683 int i, size, is_two_byte_font, char_width; 6600 int i, size, point_size, avgwidth, is_two_byte_font, char_width;
6684 char *name; 6601 char *name;
6685 GrafPtr port; 6602 GrafPtr port;
6686 SInt16 old_fontnum, old_fontsize; 6603 SInt16 old_fontnum, old_fontsize;
6687 Style old_fontface; 6604 Style old_fontface;
6688 Str32 mfontname; 6605 Str32 mfontname, mfontname_decoded, charset;
6689 SInt16 fontnum; 6606 SInt16 fontnum;
6690 Style fontface = normal; 6607 Style fontface;
6608#if TARGET_API_MAC_CARBON
6609 TextEncoding encoding;
6610 int scriptcode;
6611#else
6612 short scriptcode;
6613#endif
6691 MacFontStruct *font; 6614 MacFontStruct *font;
6692 FontInfo the_fontinfo; 6615 FontInfo the_fontinfo;
6693 char s_weight[7], c_slant; 6616#ifdef MAC_OSX
6617 UInt32 old_flags, new_flags;
6618#endif
6694 6619
6695 if (is_fully_specified_xlfd (fontname)) 6620 if (is_fully_specified_xlfd (fontname))
6696 name = fontname; 6621 name = fontname;
@@ -6715,46 +6640,50 @@ XLoadQueryFont (Display *dpy, char *fontname)
6715 old_fontface = port->txFace; 6640 old_fontface = port->txFace;
6716#endif 6641#endif
6717 6642
6718 if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", &size) != 1) 6643 if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%d-%*[^-]-%*[^-]-%*c-%d-%*s", &size, &point_size, &avgwidth) != 3)
6644 size = 0;
6645 else
6646 {
6647 if (size == 0)
6648 if (point_size > 0)
6649 size = point_size / 10;
6650 else if (avgwidth > 0)
6651 size = avgwidth / 10;
6652 }
6653 if (size == 0)
6719 size = kDefaultFontSize; 6654 size = kDefaultFontSize;
6720 6655
6721 if (sscanf (name, "-%*[^-]-%*[^-]-%6[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", s_weight) == 1) 6656 x_font_name_to_mac_font_name (name, mfontname, mfontname_decoded,
6722 if (strcmp (s_weight, "bold") == 0) 6657 &fontface, charset);
6723 fontface |= bold;
6724
6725 if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", &c_slant) == 1)
6726 if (c_slant == 'i')
6727 fontface |= italic;
6728
6729 x_font_name_to_mac_font_name (name, mfontname);
6730 c2pstr (mfontname); 6658 c2pstr (mfontname);
6659#if TARGET_API_MAC_CARBON
6660 fontnum = FMGetFontFamilyFromName (mfontname);
6661 if (fontnum == kInvalidFontFamily
6662 || FMGetFontFamilyTextEncoding (fontnum, &encoding) != noErr)
6663 return NULL;
6664 scriptcode = GetTextEncodingBase (encoding);
6665#else
6731 GetFNum (mfontname, &fontnum); 6666 GetFNum (mfontname, &fontnum);
6732 if (fontnum == 0) 6667 if (fontnum == 0)
6733 return NULL; 6668 return NULL;
6669 scriptcode = FontToScript (fontnum);
6670#endif
6734 6671
6735 font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct)); 6672 font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct));
6736 6673
6737 font->fontname = (char *) xmalloc (strlen (name) + 1);
6738 bcopy (name, font->fontname, strlen (name) + 1);
6739
6740 font->mac_fontnum = fontnum; 6674 font->mac_fontnum = fontnum;
6741 font->mac_fontsize = size; 6675 font->mac_fontsize = size;
6742 font->mac_fontface = fontface; 6676 font->mac_fontface = fontface;
6743 font->mac_scriptcode = FontToScript (fontnum); 6677 font->mac_scriptcode = scriptcode;
6744 6678
6745 /* Apple Japanese (SJIS) font is listed as both 6679 /* Apple Japanese (SJIS) font is listed as both
6746 "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0" 6680 "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0"
6747 (Roman script) in init_font_name_table (). The latter should be 6681 (Roman script) in init_font_name_table (). The latter should be
6748 treated as a one-byte font. */ 6682 treated as a one-byte font. */
6749 { 6683 if (scriptcode == smJapanese && strcmp (charset, "jisx0201.1976-0") == 0)
6750 char cs[32]; 6684 font->mac_scriptcode = smRoman;
6751 6685
6752 if (sscanf (name, 6686 font->full_name = mac_to_x_fontname (mfontname_decoded, size, fontface, charset);
6753 "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
6754 cs) == 1
6755 && 0 == strcmp (cs, "jisx0201.1976-0"))
6756 font->mac_scriptcode = smRoman;
6757 }
6758 6687
6759 is_two_byte_font = font->mac_scriptcode == smJapanese || 6688 is_two_byte_font = font->mac_scriptcode == smJapanese ||
6760 font->mac_scriptcode == smTradChinese || 6689 font->mac_scriptcode == smTradChinese ||
@@ -6879,7 +6808,7 @@ mac_unload_font (dpyinfo, font)
6879 struct mac_display_info *dpyinfo; 6808 struct mac_display_info *dpyinfo;
6880 XFontStruct *font; 6809 XFontStruct *font;
6881{ 6810{
6882 xfree (font->fontname); 6811 xfree (font->full_name);
6883 if (font->per_char) 6812 if (font->per_char)
6884 xfree (font->per_char); 6813 xfree (font->per_char);
6885 xfree (font); 6814 xfree (font);
@@ -6919,6 +6848,8 @@ x_load_font (f, fontname, size)
6919 SDATA (XCAR (tail))))) 6848 SDATA (XCAR (tail)))))
6920 return (dpyinfo->font_table + i); 6849 return (dpyinfo->font_table + i);
6921 } 6850 }
6851 else
6852 return NULL;
6922 6853
6923 /* Load the font and add it to the table. */ 6854 /* Load the font and add it to the table. */
6924 { 6855 {
@@ -6928,13 +6859,7 @@ x_load_font (f, fontname, size)
6928 unsigned long value; 6859 unsigned long value;
6929 int i; 6860 int i;
6930 6861
6931 /* If we have found fonts by x_list_font, load one of them. If 6862 fontname = (char *) SDATA (XCAR (font_names));
6932 not, we still try to load a font by the name given as FONTNAME
6933 because XListFonts (called in x_list_font) of some X server has
6934 a bug of not finding a font even if the font surely exists and
6935 is loadable by XLoadQueryFont. */
6936 if (size > 0 && !NILP (font_names))
6937 fontname = (char *) SDATA (XCAR (font_names));
6938 6863
6939 BLOCK_INPUT; 6864 BLOCK_INPUT;
6940 font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname); 6865 font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname);
@@ -6967,8 +6892,8 @@ x_load_font (f, fontname, size)
6967 bzero (fontp, sizeof (*fontp)); 6892 bzero (fontp, sizeof (*fontp));
6968 fontp->font = font; 6893 fontp->font = font;
6969 fontp->font_idx = i; 6894 fontp->font_idx = i;
6970 fontp->name = (char *) xmalloc (strlen (font->fontname) + 1); 6895 fontp->name = (char *) xmalloc (strlen (fontname) + 1);
6971 bcopy (font->fontname, fontp->name, strlen (font->fontname) + 1); 6896 bcopy (fontname, fontp->name, strlen (fontname) + 1);
6972 6897
6973 if (font->min_bounds.width == font->max_bounds.width) 6898 if (font->min_bounds.width == font->max_bounds.width)
6974 { 6899 {
@@ -6999,7 +6924,8 @@ x_load_font (f, fontname, size)
6999 fontp->average_width = FONT_WIDTH (font); 6924 fontp->average_width = FONT_WIDTH (font);
7000 } 6925 }
7001 6926
7002 fontp->full_name = fontp->name; 6927 fontp->full_name = (char *) xmalloc (strlen (font->full_name) + 1);
6928 bcopy (font->full_name, fontp->full_name, strlen (font->full_name) + 1);
7003 6929
7004 fontp->size = font->max_bounds.width; 6930 fontp->size = font->max_bounds.width;
7005 fontp->height = FONT_HEIGHT (font); 6931 fontp->height = FONT_HEIGHT (font);
@@ -9811,18 +9737,6 @@ syms_of_macterm ()
9811 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); 9737 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
9812 staticpro (&Qmac_ready_for_drag_n_drop); 9738 staticpro (&Qmac_ready_for_drag_n_drop);
9813 9739
9814 Qbig5 = intern ("big5");
9815 staticpro (&Qbig5);
9816
9817 Qcn_gb = intern ("cn-gb");
9818 staticpro (&Qcn_gb);
9819
9820 Qsjis = intern ("sjis");
9821 staticpro (&Qsjis);
9822
9823 Qeuc_kr = intern ("euc-kr");
9824 staticpro (&Qeuc_kr);
9825
9826 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 9740 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
9827 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 9741 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
9828 Vx_toolkit_scroll_bars = Qt; 9742 Vx_toolkit_scroll_bars = Qt;
@@ -9889,6 +9803,22 @@ Toolbox for processing before Emacs sees it. */);
9889The text will be rendered using Core Graphics text rendering which 9803The text will be rendered using Core Graphics text rendering which
9890may anti-alias the text. */); 9804may anti-alias the text. */);
9891 Vmac_use_core_graphics = Qnil; 9805 Vmac_use_core_graphics = Qnil;
9806
9807 /* Register an entry for `mac-roman' so that it can be used when
9808 creating the terminal frame on Mac OS 9 before loading
9809 term/mac-win.elc. */
9810 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist,
9811 doc: /* Alist linking Emacs character sets to Mac text encoding and Emacs coding system.
9812Each entry should be of the form:
9813
9814 (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM)
9815
9816where CHARSET-NAME is a string used in font names to identify the
9817charset, TEXT-ENCODING is a TextEncodingBase value, and CODING_SYSTEM
9818is a coding system corresponding to TEXT-ENCODING. */);
9819 Vmac_charset_info_alist =
9820 Fcons (list3 (build_string ("mac-roman"),
9821 make_number (smRoman), Qnil), Qnil);
9892} 9822}
9893 9823
9894/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b 9824/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
diff --git a/src/xdisp.c b/src/xdisp.c
index 12ee4fef7d3..736b60f9a95 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2702,6 +2702,10 @@ handle_stop (it)
2702 it->dpvec = NULL; 2702 it->dpvec = NULL;
2703 it->current.dpvec_index = -1; 2703 it->current.dpvec_index = -1;
2704 2704
2705 /* Use face of preceding text for ellipsis (if invisible) */
2706 if (it->selective_display_ellipsis_p)
2707 it->saved_face_id = it->face_id;
2708
2705 do 2709 do
2706 { 2710 {
2707 handled = HANDLED_NORMALLY; 2711 handled = HANDLED_NORMALLY;
@@ -3379,8 +3383,11 @@ setup_for_ellipsis (it, len)
3379 it->dpvec_face_id = -1; 3383 it->dpvec_face_id = -1;
3380 3384
3381 /* Remember the current face id in case glyphs specify faces. 3385 /* Remember the current face id in case glyphs specify faces.
3382 IT's face is restored in set_iterator_to_next. */ 3386 IT's face is restored in set_iterator_to_next.
3383 it->saved_face_id = it->face_id; 3387 saved_face_id was set to preceding char's face in handle_stop. */
3388 if (it->saved_face_id < 0 || it->saved_face_id != it->face_id)
3389 it->saved_face_id = it->face_id = DEFAULT_FACE_ID;
3390
3384 it->method = GET_FROM_DISPLAY_VECTOR; 3391 it->method = GET_FROM_DISPLAY_VECTOR;
3385 it->ellipsis_p = 1; 3392 it->ellipsis_p = 1;
3386} 3393}
@@ -5419,6 +5426,8 @@ next_element_from_display_vector (it)
5419 /* Precondition. */ 5426 /* Precondition. */
5420 xassert (it->dpvec && it->current.dpvec_index >= 0); 5427 xassert (it->dpvec && it->current.dpvec_index >= 0);
5421 5428
5429 it->face_id = it->saved_face_id;
5430
5422 if (INTEGERP (*it->dpvec) 5431 if (INTEGERP (*it->dpvec)
5423 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec))) 5432 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec)))
5424 { 5433 {
diff --git a/src/xfaces.c b/src/xfaces.c
index 89267c8f7f6..099ad673ddd 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3228,25 +3228,19 @@ resolve_face_name (face_name)
3228 Lisp_Object face_name; 3228 Lisp_Object face_name;
3229{ 3229{
3230 Lisp_Object aliased; 3230 Lisp_Object aliased;
3231 Lisp_Object args[2]; 3231 int alias_loop_max = 10;
3232 int c = 0;
3233 3232
3234 if (STRINGP (face_name)) 3233 if (STRINGP (face_name))
3235 face_name = intern (SDATA (face_name)); 3234 face_name = intern (SDATA (face_name));
3236 3235
3237 /* Protect against loops by limiting the number of indirections. */ 3236 while (SYMBOLP (face_name))
3238 while (SYMBOLP (face_name) && c < 10)
3239 { 3237 {
3240 /* Fget can signal an error; just ignore it. */ 3238 aliased = Fsafe_get (face_name, Qface_alias);
3241 args[0] = face_name;
3242 args[1] = Qface_alias;
3243 aliased = internal_condition_case_2 (internal_resolve_face_name, 2, args, Qt,
3244 resolve_face_name_error);
3245 if (NILP (aliased)) 3239 if (NILP (aliased))
3246 break; 3240 break;
3247 else 3241 if (--alias_loop_max == 0)
3248 face_name = aliased; 3242 break;
3249 c++; 3243 face_name = aliased;
3250 } 3244 }
3251 3245
3252 return face_name; 3246 return face_name;