aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2006-04-21 07:57:17 +0000
committerYAMAMOTO Mitsuharu2006-04-21 07:57:17 +0000
commita0c62ca2998a7daca34aac44186903959088f538 (patch)
tree637473beadbbd9829151e153ee861c633f000516 /src
parentf1d7196a178d12d29238dee6d272fb85ff191a32 (diff)
downloademacs-a0c62ca2998a7daca34aac44186903959088f538.tar.gz
emacs-a0c62ca2998a7daca34aac44186903959088f538.zip
(x_per_char_metric): Return NULL if glyph width is 0.
(add_mac_font_name): New function. (init_font_name_table): Use it. Adopt the first found font from those having the same family name.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog19
-rw-r--r--src/macterm.c122
2 files changed, 75 insertions, 66 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 392d0c97ab9..36aba44b8db 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
12006-04-21 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * image.c [MAC_OS] (xpm_load_image): Fill in background field
4 while we have ximg handy.
5
6 * macmenu.c (restore_menu_items, save_menu_items): New functions
7 from xmenu.c.
8 (set_frame_menubar, digest_single_submenu): Apply 2006-04-18
9 changes for xmenu.c.
10
11 * macterm.c (x_per_char_metric): Return NULL if glyph width is 0.
12 (add_mac_font_name): New function.
13 (init_font_name_table): Use it. Adopt the first found font from
14 those having the same family name.
15
12006-04-21 Nick Roberts <nickrob@snap.net.nz> 162006-04-21 Nick Roberts <nickrob@snap.net.nz>
2 17
3 * xdisp.c (note_mouse_highlight): Use build_string. 18 * xdisp.c (note_mouse_highlight): Use build_string.
@@ -51,8 +66,8 @@
51 66
52 * macterm.c (XCreateGC, x_per_char_metric, xlfdpat_create) 67 * macterm.c (XCreateGC, x_per_char_metric, xlfdpat_create)
53 (init_font_name_table, init_font_name_table, mac_do_list_fonts) 68 (init_font_name_table, init_font_name_table, mac_do_list_fonts)
54 (XLoadQueryFont, mac_store_apple_event): Don't check 69 (XLoadQueryFont, mac_store_apple_event): Don't check return value
55 return value of xmalloc. 70 of xmalloc.
56 71
572006-04-17 Kim F. Storm <storm@cua.dk> 722006-04-17 Kim F. Storm <storm@cua.dk>
58 73
diff --git a/src/macterm.c b/src/macterm.c
index 7313cf1b3ee..cbef67c3bee 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -2230,7 +2230,11 @@ x_per_char_metric (font, char2b)
2230#endif 2230#endif
2231 2231
2232 return ((pcm == NULL 2232 return ((pcm == NULL
2233 || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0)) 2233 || (pcm->width == 0
2234#if 0 /* Show hollow boxes for zero-width glyphs such as combining diacritics. */
2235 && (pcm->rbearing - pcm->lbearing) == 0
2236#endif
2237 ))
2234 ? NULL : pcm); 2238 ? NULL : pcm);
2235} 2239}
2236 2240
@@ -7042,6 +7046,25 @@ add_font_name_table_entry (char *font_name)
7042 font_name_table[font_name_count++] = font_name; 7046 font_name_table[font_name_count++] = font_name;
7043} 7047}
7044 7048
7049static void
7050add_mac_font_name (name, size, style, charset)
7051 char *name;
7052 int size;
7053 Style style;
7054 char *charset;
7055{
7056 if (size > 0)
7057 add_font_name_table_entry (mac_to_x_fontname (name, size, style, charset));
7058 else
7059 {
7060 add_font_name_table_entry (mac_to_x_fontname (name, 0, style, charset));
7061 add_font_name_table_entry (mac_to_x_fontname (name, 0, italic, charset));
7062 add_font_name_table_entry (mac_to_x_fontname (name, 0, bold, charset));
7063 add_font_name_table_entry (mac_to_x_fontname (name, 0, italic | bold,
7064 charset));
7065 }
7066}
7067
7045/* Sets up the table font_name_table to contain the list of all fonts 7068/* Sets up the table font_name_table to contain the list of all fonts
7046 in the system the first time the table is used so that the Resource 7069 in the system the first time the table is used so that the Resource
7047 Manager need not be accessed every time this information is 7070 Manager need not be accessed every time this information is
@@ -7067,16 +7090,21 @@ init_font_name_table ()
7067 text_encoding_info_alist))) 7090 text_encoding_info_alist)))
7068 { 7091 {
7069 OSErr err; 7092 OSErr err;
7093 struct Lisp_Hash_Table *h;
7094 unsigned hash_code;
7070 ItemCount nfonts, i; 7095 ItemCount nfonts, i;
7071 ATSUFontID *font_ids = NULL; 7096 ATSUFontID *font_ids = NULL;
7072 Ptr name, prev_name = NULL; 7097 Ptr name;
7073 ByteCount name_len; 7098 ByteCount name_len;
7099 Lisp_Object family;
7074 7100
7075 atsu_font_id_hash = 7101 atsu_font_id_hash =
7076 make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), 7102 make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
7077 make_float (DEFAULT_REHASH_SIZE), 7103 make_float (DEFAULT_REHASH_SIZE),
7078 make_float (DEFAULT_REHASH_THRESHOLD), 7104 make_float (DEFAULT_REHASH_THRESHOLD),
7079 Qnil, Qnil, Qnil);; 7105 Qnil, Qnil, Qnil);;
7106 h = XHASH_TABLE (atsu_font_id_hash);
7107
7080 err = ATSUFontCount (&nfonts); 7108 err = ATSUFontCount (&nfonts);
7081 if (err == noErr) 7109 if (err == noErr)
7082 { 7110 {
@@ -7098,32 +7126,19 @@ init_font_name_table ()
7098 kFontNoLanguage, name_len, name, 7126 kFontNoLanguage, name_len, name,
7099 NULL, NULL); 7127 NULL, NULL);
7100 if (err == noErr) 7128 if (err == noErr)
7101 decode_mac_font_name (name, name_len + 1, Qnil);
7102 if (err == noErr
7103 && *name != '.'
7104 && (prev_name == NULL
7105 || strcmp (name, prev_name) != 0))
7106 { 7129 {
7107 static char *cs = "iso10646-1"; 7130 decode_mac_font_name (name, name_len + 1, Qnil);
7108 7131 family = make_unibyte_string (name, name_len);
7109 add_font_name_table_entry (mac_to_x_fontname (name, 0, 7132 if (*name != '.'
7110 normal, cs)); 7133 && hash_lookup (h, family, &hash_code) < 0)
7111 add_font_name_table_entry (mac_to_x_fontname (name, 0, 7134 {
7112 italic, cs)); 7135 add_mac_font_name (name, 0, normal, "iso10646-1");
7113 add_font_name_table_entry (mac_to_x_fontname (name, 0, 7136 hash_put (h, family, long_to_cons (font_ids[i]),
7114 bold, cs)); 7137 hash_code);
7115 add_font_name_table_entry (mac_to_x_fontname (name, 0, 7138 }
7116 italic | bold, cs));
7117 Fputhash (make_unibyte_string (name, name_len),
7118 long_to_cons (font_ids[i]), atsu_font_id_hash);
7119 xfree (prev_name);
7120 prev_name = name;
7121 } 7139 }
7122 else 7140 xfree (name);
7123 xfree (name);
7124 } 7141 }
7125 if (prev_name)
7126 xfree (prev_name);
7127 if (font_ids) 7142 if (font_ids)
7128 xfree (font_ids); 7143 xfree (font_ids);
7129 } 7144 }
@@ -7151,16 +7166,16 @@ init_font_name_table ()
7151 FMFontSize size; 7166 FMFontSize size;
7152 TextEncoding encoding; 7167 TextEncoding encoding;
7153 TextEncodingBase sc; 7168 TextEncodingBase sc;
7154 Lisp_Object text_encoding_info; 7169 Lisp_Object text_encoding_info, family;
7155 7170
7156 if (FMGetFontFamilyName (ff, name) != noErr) 7171 if (FMGetFontFamilyName (ff, name) != noErr)
7157 break; 7172 continue;
7158 p2cstr (name); 7173 p2cstr (name);
7159 if (*name == '.') 7174 if (*name == '.')
7160 continue; 7175 continue;
7161 7176
7162 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr) 7177 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
7163 break; 7178 continue;
7164 sc = GetTextEncodingBase (encoding); 7179 sc = GetTextEncodingBase (encoding);
7165 text_encoding_info = assq_no_quit (make_number (sc), 7180 text_encoding_info = assq_no_quit (make_number (sc),
7166 text_encoding_info_alist); 7181 text_encoding_info_alist);
@@ -7169,13 +7184,15 @@ init_font_name_table ()
7169 text_encoding_info_alist); 7184 text_encoding_info_alist);
7170 decode_mac_font_name (name, sizeof (name), 7185 decode_mac_font_name (name, sizeof (name),
7171 XCAR (XCDR (text_encoding_info))); 7186 XCAR (XCDR (text_encoding_info)));
7172 fm_font_family_alist = Fcons (Fcons (build_string (name), 7187 family = build_string (name);
7173 make_number (ff)), 7188 if (!NILP (Fassoc (family, fm_font_family_alist)))
7189 continue;
7190 fm_font_family_alist = Fcons (Fcons (family, make_number (ff)),
7174 fm_font_family_alist); 7191 fm_font_family_alist);
7175 7192
7176 /* Point the instance iterator at the current font family. */ 7193 /* Point the instance iterator at the current font family. */
7177 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) 7194 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
7178 break; 7195 continue;
7179 7196
7180 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size) 7197 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
7181 == noErr) 7198 == noErr)
@@ -7184,27 +7201,7 @@ init_font_name_table ()
7184 7201
7185 if (size > 0 || style == normal) 7202 if (size > 0 || style == normal)
7186 for (; !NILP (rest); rest = XCDR (rest)) 7203 for (; !NILP (rest); rest = XCDR (rest))
7187 { 7204 add_mac_font_name (name, size, style, SDATA (XCAR (rest)));
7188 char *cs = SDATA (XCAR (rest));
7189
7190 if (size == 0)
7191 {
7192 add_font_name_table_entry (mac_to_x_fontname (name, size,
7193 style, cs));
7194 add_font_name_table_entry (mac_to_x_fontname (name, size,
7195 italic, cs));
7196 add_font_name_table_entry (mac_to_x_fontname (name, size,
7197 bold, cs));
7198 add_font_name_table_entry (mac_to_x_fontname (name, size,
7199 italic | bold,
7200 cs));
7201 }
7202 else
7203 {
7204 add_font_name_table_entry (mac_to_x_fontname (name, size,
7205 style, cs));
7206 }
7207 }
7208 } 7205 }
7209 } 7206 }
7210 7207
@@ -7224,7 +7221,7 @@ init_font_name_table ()
7224 Str255 name; 7221 Str255 name;
7225 struct FontAssoc *fat; 7222 struct FontAssoc *fat;
7226 struct AsscEntry *assc_entry; 7223 struct AsscEntry *assc_entry;
7227 Lisp_Object text_encoding_info_alist, text_encoding_info; 7224 Lisp_Object text_encoding_info_alist, text_encoding_info, family;
7228 struct gcpro gcpro1; 7225 struct gcpro gcpro1;
7229 7226
7230 GetPort (&port); /* save the current font number used */ 7227 GetPort (&port); /* save the current font number used */
@@ -7243,7 +7240,7 @@ init_font_name_table ()
7243 GetResInfo (font_handle, &id, &type, name); 7240 GetResInfo (font_handle, &id, &type, name);
7244 GetFNum (name, &fontnum); 7241 GetFNum (name, &fontnum);
7245 p2cstr (name); 7242 p2cstr (name);
7246 if (fontnum == 0) 7243 if (fontnum == 0 || *name == '.')
7247 continue; 7244 continue;
7248 7245
7249 TextFont (fontnum); 7246 TextFont (fontnum);
@@ -7255,8 +7252,10 @@ init_font_name_table ()
7255 text_encoding_info_alist); 7252 text_encoding_info_alist);
7256 decode_mac_font_name (name, sizeof (name), 7253 decode_mac_font_name (name, sizeof (name),
7257 XCAR (XCDR (text_encoding_info))); 7254 XCAR (XCDR (text_encoding_info)));
7258 fm_font_family_alist = Fcons (Fcons (build_string (name), 7255 family = build_string (name);
7259 make_number (fontnum)), 7256 if (!NILP (Fassoc (family, fm_font_family_alist)))
7257 continue;
7258 fm_font_family_alist = Fcons (Fcons (family, make_number (fontnum)),
7260 fm_font_family_alist); 7259 fm_font_family_alist);
7261 do 7260 do
7262 { 7261 {
@@ -7277,14 +7276,9 @@ init_font_name_table ()
7277 Lisp_Object rest = XCDR (XCDR (text_encoding_info)); 7276 Lisp_Object rest = XCDR (XCDR (text_encoding_info));
7278 7277
7279 for (; !NILP (rest); rest = XCDR (rest)) 7278 for (; !NILP (rest); rest = XCDR (rest))
7280 { 7279 add_mac_font_name (name, assc_entry->fontSize,
7281 char *cs = SDATA (XCAR (rest)); 7280 assc_entry->fontStyle,
7282 7281 SDATA (XCAR (rest)));
7283 add_font_name_table_entry (mac_to_x_fontname (name,
7284 assc_entry->fontSize,
7285 assc_entry->fontStyle,
7286 cs));
7287 }
7288 } 7282 }
7289 } 7283 }
7290 7284