comparison src/macterm.c @ 64102:09d72bda30b9

(mac_draw_vertical_window_border): Use foreground of VERTICAL_BORDER_FACE_ID for vertical border line. (mac_encode_char): Call check_ccl_update in advance. (mac_to_x_fontname, x_font_name_to_mac_font_name) (init_font_name_table, mac_do_list_fonts, XLoadQueryFont): Don't assume that font family length is less than 32. (x_compute_min_glyph_bounds): Make static. (x_load_font): Never set fonts_changed_p to zero.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Wed, 06 Jul 2005 08:43:10 +0000
parents a8fa7c632ee4
children 0a062d2d75f3 24c69010999c f9a65d7ebd29
comparison
equal deleted inserted replaced
64101:90caba02a18d 64102:09d72bda30b9
1332 mac_draw_vertical_window_border (w, x, y0, y1) 1332 mac_draw_vertical_window_border (w, x, y0, y1)
1333 struct window *w; 1333 struct window *w;
1334 int x, y0, y1; 1334 int x, y0, y1;
1335 { 1335 {
1336 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1336 struct frame *f = XFRAME (WINDOW_FRAME (w));
1337 struct face *face;
1338
1339 face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
1340 if (face)
1341 XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
1342 face->foreground);
1337 1343
1338 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1344 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1339 f->output_data.mac->normal_gc, x, y0, x, y1); 1345 f->output_data.mac->normal_gc, x, y0, x, y1);
1340 } 1346 }
1341 1347
1719 if (font_info->font_encoder) 1725 if (font_info->font_encoder)
1720 { 1726 {
1721 /* It's a program. */ 1727 /* It's a program. */
1722 struct ccl_program *ccl = font_info->font_encoder; 1728 struct ccl_program *ccl = font_info->font_encoder;
1723 1729
1730 check_ccl_update (ccl);
1724 if (CHARSET_DIMENSION (charset) == 1) 1731 if (CHARSET_DIMENSION (charset) == 1)
1725 { 1732 {
1726 ccl->reg[0] = charset; 1733 ccl->reg[0] = charset;
1727 ccl->reg[1] = char2b->byte2; 1734 ccl->reg[1] = char2b->byte2;
1735 ccl->reg[2] = -1;
1728 } 1736 }
1729 else 1737 else
1730 { 1738 {
1731 ccl->reg[0] = charset; 1739 ccl->reg[0] = charset;
1732 ccl->reg[1] = char2b->byte1; 1740 ccl->reg[1] = char2b->byte1;
6247 char *name; 6255 char *name;
6248 int size; 6256 int size;
6249 Style style; 6257 Style style;
6250 char *charset; 6258 char *charset;
6251 { 6259 {
6252 char foundry[32], family[32], cs[32]; 6260 Str31 foundry, cs;
6261 Str255 family;
6253 char xf[256], *result, *p; 6262 char xf[256], *result, *p;
6254 6263
6255 if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) == 3) 6264 if (sscanf (name, "%31[^-]-%255[^-]-%31s", foundry, family, cs) == 3)
6256 charset = cs; 6265 charset = cs;
6257 else 6266 else
6258 { 6267 {
6259 strcpy(foundry, "Apple"); 6268 strcpy(foundry, "Apple");
6260 strcpy(family, name); 6269 strcpy(family, name);
6261 } 6270 }
6262 6271
6263 sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-%d-%d-m-%d-%s", 6272 sprintf (xf, "%s-%c-normal--%d-%d-%d-%d-m-%d-%s",
6264 foundry, family, style & bold ? "bold" : "medium", 6273 style & bold ? "bold" : "medium", style & italic ? 'i' : 'r',
6265 style & italic ? 'i' : 'r', size, size * 10, 6274 size, size * 10, size ? 75 : 0, size ? 75 : 0, size * 10, charset);
6266 size ? 75 : 0, size ? 75 : 0, size * 10, charset); 6275
6267 6276 result = xmalloc (strlen (foundry) + strlen (family) + strlen (xf) + 3 + 1);
6268 result = (char *) xmalloc (strlen (xf) + 1); 6277 sprintf (result, "-%s-%s-%s", foundry, family, xf);
6269 strcpy (result, xf);
6270 for (p = result; *p; p++) 6278 for (p = result; *p; p++)
6271 *p = tolower(*p); 6279 *p = tolower(*p);
6272 return result; 6280 return result;
6273 } 6281 }
6274 6282
6284 x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs) 6292 x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs)
6285 char *xf, *mf, *mf_decoded; 6293 char *xf, *mf, *mf_decoded;
6286 Style *style; 6294 Style *style;
6287 char *cs; 6295 char *cs;
6288 { 6296 {
6289 char foundry[32], family[32], weight[20], slant[2], *p; 6297 Str31 foundry;
6298 Str255 family;
6299 char weight[20], slant[2], *p;
6290 Lisp_Object charset_info, coding_system = Qnil; 6300 Lisp_Object charset_info, coding_system = Qnil;
6291 struct coding_system coding; 6301 struct coding_system coding;
6292 6302
6293 strcpy (mf, ""); 6303 strcpy (mf, "");
6294 6304
6295 if (sscanf (xf, "-%31[^-]-%31[^-]-%19[^-]-%1[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s", 6305 if (sscanf (xf, "-%31[^-]-%255[^-]-%19[^-]-%1[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
6296 foundry, family, weight, slant, cs) != 5 && 6306 foundry, family, weight, slant, cs) != 5 &&
6297 sscanf (xf, "-%31[^-]-%31[^-]-%19[^-]-%1[^-]-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s", 6307 sscanf (xf, "-%31[^-]-%255[^-]-%19[^-]-%1[^-]-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
6298 foundry, family, weight, slant, cs) != 5) 6308 foundry, family, weight, slant, cs) != 5)
6299 return; 6309 return;
6300 6310
6301 *style = normal; 6311 *style = normal;
6302 if (strcmp (weight, "bold") == 0) 6312 if (strcmp (weight, "bold") == 0)
6325 setup_coding_system (coding_system, &coding); 6335 setup_coding_system (coding_system, &coding);
6326 coding.src_multibyte = 1; 6336 coding.src_multibyte = 1;
6327 coding.dst_multibyte = 1; 6337 coding.dst_multibyte = 1;
6328 coding.mode |= CODING_MODE_LAST_BLOCK; 6338 coding.mode |= CODING_MODE_LAST_BLOCK;
6329 encode_coding (&coding, mf_decoded, mf, 6339 encode_coding (&coding, mf_decoded, mf,
6330 strlen (mf_decoded), sizeof (Str32) - 1); 6340 strlen (mf_decoded), sizeof (Str255) - 1);
6331 mf[coding.produced] = '\0'; 6341 mf[coding.produced] = '\0';
6332 } 6342 }
6333 } 6343 }
6334 6344
6335 6345
6457 int num_mac_fonts = CountResources('FOND'); 6467 int num_mac_fonts = CountResources('FOND');
6458 int i, j; 6468 int i, j;
6459 Handle font_handle, font_handle_2; 6469 Handle font_handle, font_handle_2;
6460 short id, scriptcode; 6470 short id, scriptcode;
6461 ResType type; 6471 ResType type;
6462 Str32 name; 6472 Str255 name;
6463 struct FontAssoc *fat; 6473 struct FontAssoc *fat;
6464 struct AsscEntry *assc_entry; 6474 struct AsscEntry *assc_entry;
6465 Lisp_Object text_encoding_info_alist, text_encoding_info; 6475 Lisp_Object text_encoding_info_alist, text_encoding_info;
6466 struct gcpro gcpro1; 6476 struct gcpro gcpro1;
6467 6477
6596 int maxnames; 6606 int maxnames;
6597 { 6607 {
6598 int i, n_fonts = 0; 6608 int i, n_fonts = 0;
6599 Lisp_Object font_list = Qnil, pattern_regex, fontname; 6609 Lisp_Object font_list = Qnil, pattern_regex, fontname;
6600 char *regex = (char *) alloca (strlen (pattern) * 2 + 3); 6610 char *regex = (char *) alloca (strlen (pattern) * 2 + 3);
6601 char scaled[256]; 6611 char *scaled, *ptr;
6602 char *ptr;
6603 int scl_val[XLFD_SCL_LAST], *field, *val; 6612 int scl_val[XLFD_SCL_LAST], *field, *val;
6604 char *longest_start, *cur_start, *nonspecial; 6613 char *longest_start, *cur_start, *nonspecial;
6605 int longest_len, exact; 6614 int longest_len, exact;
6606 6615
6607 if (font_name_table == NULL) /* Initialize when first used. */ 6616 if (font_name_table == NULL) /* Initialize when first used. */
6721 else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 6730 else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0
6722 && (ptr = strstr (font_name_table[i], "-0-0-0-0-m-0-"))) 6731 && (ptr = strstr (font_name_table[i], "-0-0-0-0-m-0-")))
6723 { 6732 {
6724 int former_len = ptr - font_name_table[i]; 6733 int former_len = ptr - font_name_table[i];
6725 6734
6735 scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1);
6726 memcpy (scaled, font_name_table[i], former_len); 6736 memcpy (scaled, font_name_table[i], former_len);
6727 sprintf (scaled + former_len, 6737 sprintf (scaled + former_len,
6728 "-%d-%d-75-75-m-%d-%s", 6738 "-%d-%d-75-75-m-%d-%s",
6729 scl_val[XLFD_SCL_PIXEL_SIZE], 6739 scl_val[XLFD_SCL_PIXEL_SIZE],
6730 scl_val[XLFD_SCL_POINT_SIZE], 6740 scl_val[XLFD_SCL_POINT_SIZE],
6731 scl_val[XLFD_SCL_AVGWIDTH], 6741 scl_val[XLFD_SCL_AVGWIDTH],
6732 ptr + sizeof ("-0-0-0-0-m-0-") - 1); 6742 ptr + sizeof ("-0-0-0-0-m-0-") - 1);
6733 fontname = mac_c_string_match (pattern_regex, scaled, 6743 fontname = mac_c_string_match (pattern_regex, scaled,
6734 nonspecial, exact); 6744 nonspecial, exact);
6745 xfree (scaled);
6735 if (!NILP (fontname)) 6746 if (!NILP (fontname))
6736 { 6747 {
6737 font_list = Fcons (fontname, font_list); 6748 font_list = Fcons (fontname, font_list);
6738 if (exact || maxnames > 0 && ++n_fonts >= maxnames) 6749 if (exact || maxnames > 0 && ++n_fonts >= maxnames)
6739 break; 6750 break;
6850 all fonts available on frame F. Set the members smallest_char_width 6861 all fonts available on frame F. Set the members smallest_char_width
6851 and smallest_font_height in F's x_display_info structure to 6862 and smallest_font_height in F's x_display_info structure to
6852 the values computed. Value is non-zero if smallest_font_height or 6863 the values computed. Value is non-zero if smallest_font_height or
6853 smallest_char_width become smaller than they were before. */ 6864 smallest_char_width become smaller than they were before. */
6854 6865
6855 int 6866 static int
6856 x_compute_min_glyph_bounds (f) 6867 x_compute_min_glyph_bounds (f)
6857 struct frame *f; 6868 struct frame *f;
6858 { 6869 {
6859 int i; 6870 int i;
6860 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); 6871 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
6935 int i, size, point_size, avgwidth, is_two_byte_font, char_width; 6946 int i, size, point_size, avgwidth, is_two_byte_font, char_width;
6936 char *name; 6947 char *name;
6937 GrafPtr port; 6948 GrafPtr port;
6938 SInt16 old_fontnum, old_fontsize; 6949 SInt16 old_fontnum, old_fontsize;
6939 Style old_fontface; 6950 Style old_fontface;
6940 Str32 mfontname, mfontname_decoded, charset; 6951 Str255 mfontname, mfontname_decoded;
6952 Str31 charset;
6941 SInt16 fontnum; 6953 SInt16 fontnum;
6942 Style fontface; 6954 Style fontface;
6943 #if TARGET_API_MAC_CARBON 6955 #if TARGET_API_MAC_CARBON
6944 TextEncoding encoding; 6956 TextEncoding encoding;
6945 int scriptcode; 6957 int scriptcode;
7327 /* Set global flag fonts_changed_p to non-zero if the font loaded 7339 /* Set global flag fonts_changed_p to non-zero if the font loaded
7328 has a character with a smaller width than any other character 7340 has a character with a smaller width than any other character
7329 before, or if the font loaded has a smalle>r height than any 7341 before, or if the font loaded has a smalle>r height than any
7330 other font loaded before. If this happens, it will make a 7342 other font loaded before. If this happens, it will make a
7331 glyph matrix reallocation necessary. */ 7343 glyph matrix reallocation necessary. */
7332 fonts_changed_p = x_compute_min_glyph_bounds (f); 7344 fonts_changed_p |= x_compute_min_glyph_bounds (f);
7333 UNBLOCK_INPUT; 7345 UNBLOCK_INPUT;
7334 return fontp; 7346 return fontp;
7335 } 7347 }
7336 } 7348 }
7337 7349