comparison src/xterm.c @ 53038:ea521a9007e2

(x_list_fonts): Fix excluding of auto-scaled fonts.
author Kenichi Handa <handa@m17n.org>
date Tue, 11 Nov 2003 07:47:44 +0000
parents 92d82baef50b
children 4835b200fafe
comparison
equal deleted inserted replaced
53037:9958d8677feb 53038:ea521a9007e2
9441 struct x_display_info *dpyinfo 9441 struct x_display_info *dpyinfo
9442 = f ? FRAME_X_DISPLAY_INFO (f) : x_display_list; 9442 = f ? FRAME_X_DISPLAY_INFO (f) : x_display_list;
9443 Display *dpy = dpyinfo->display; 9443 Display *dpy = dpyinfo->display;
9444 int try_XLoadQueryFont = 0; 9444 int try_XLoadQueryFont = 0;
9445 int count; 9445 int count;
9446 int allow_scalable_fonts_p = 0; 9446 int allow_auto_scaled_font = 0;
9447 9447
9448 if (size < 0) 9448 if (size < 0)
9449 { 9449 {
9450 allow_scalable_fonts_p = 1; 9450 allow_auto_scaled_font = 1;
9451 size = 0; 9451 size = 0;
9452 } 9452 }
9453 9453
9454 patterns = Fassoc (pattern, Valternate_fontname_alist); 9454 patterns = Fassoc (pattern, Valternate_fontname_alist);
9455 if (NILP (patterns)) 9455 if (NILP (patterns))
9468 /* See if we cached the result for this particular query. 9468 /* See if we cached the result for this particular query.
9469 The cache is an alist of the form: 9469 The cache is an alist of the form:
9470 ((((PATTERN . MAXNAMES) . SCALABLE) (FONTNAME . WIDTH) ...) ...) */ 9470 ((((PATTERN . MAXNAMES) . SCALABLE) (FONTNAME . WIDTH) ...) ...) */
9471 tem = XCDR (dpyinfo->name_list_element); 9471 tem = XCDR (dpyinfo->name_list_element);
9472 key = Fcons (Fcons (pattern, make_number (maxnames)), 9472 key = Fcons (Fcons (pattern, make_number (maxnames)),
9473 allow_scalable_fonts_p ? Qt : Qnil); 9473 allow_auto_scaled_font ? Qt : Qnil);
9474 list = Fassoc (key, tem); 9474 list = Fassoc (key, tem);
9475 if (!NILP (list)) 9475 if (!NILP (list))
9476 { 9476 {
9477 list = Fcdr_safe (list); 9477 list = Fcdr_safe (list);
9478 /* We have a cashed list. Don't have to get the list again. */ 9478 /* We have a cashed list. Don't have to get the list again. */
9574 Store that in the font cache for the display. */ 9574 Store that in the font cache for the display. */
9575 for (i = 0; i < num_fonts; i++) 9575 for (i = 0; i < num_fonts; i++)
9576 { 9576 {
9577 int width = 0; 9577 int width = 0;
9578 char *p = names[i]; 9578 char *p = names[i];
9579 int average_width = -1, dashes = 0; 9579 int average_width = -1, resx = 0, dashes = 0;
9580 9580
9581 /* Count the number of dashes in NAMES[I]. If there are 9581 /* Count the number of dashes in NAMES[I]. If there are
9582 14 dashes, and the field value following 12th dash 9582 14 dashes, the field value following 9th dash
9583 (AVERAGE_WIDTH) is 0, this is a auto-scaled font which 9583 (RESOLUTION_X) is nonzero, and the field value
9584 is usually too ugly to be used for editing. Let's 9584 following 12th dash (AVERAGE_WIDTH) is 0, this is a
9585 ignore it. */ 9585 auto-scaled font which is usually too ugly to be used
9586 for editing. Let's ignore it. */
9586 while (*p) 9587 while (*p)
9587 if (*p++ == '-') 9588 if (*p++ == '-')
9588 { 9589 {
9589 dashes++; 9590 dashes++;
9590 if (dashes == 7) /* PIXEL_SIZE field */ 9591 if (dashes == 7) /* PIXEL_SIZE field */
9591 width = atoi (p); 9592 width = atoi (p);
9593 else if (dashes == 9)
9594 resx = atoi (p);
9592 else if (dashes == 12) /* AVERAGE_WIDTH field */ 9595 else if (dashes == 12) /* AVERAGE_WIDTH field */
9593 average_width = atoi (p); 9596 average_width = atoi (p);
9594 } 9597 }
9595 9598
9596 if (allow_scalable_fonts_p 9599 if (allow_auto_scaled_font
9597 || dashes < 14 || average_width != 0) 9600 || dashes < 14 || average_width != 0 || resx == 0)
9598 { 9601 {
9599 tem = build_string (names[i]); 9602 tem = build_string (names[i]);
9600 if (NILP (Fassoc (tem, list))) 9603 if (NILP (Fassoc (tem, list)))
9601 { 9604 {
9602 if (STRINGP (Vx_pixel_size_width_font_regexp) 9605 if (STRINGP (Vx_pixel_size_width_font_regexp)