diff options
| author | Jan Djärv | 2003-02-18 21:30:08 +0000 |
|---|---|---|
| committer | Jan Djärv | 2003-02-18 21:30:08 +0000 |
| commit | ee5be7c3c93602b4c5d6b7181544141e9484c003 (patch) | |
| tree | 2af097d75433c7fad75056c2ad65e8b5d0aa31c1 /src | |
| parent | ad837d13dba87187687c4b36789a770e5e78339d (diff) | |
| download | emacs-ee5be7c3c93602b4c5d6b7181544141e9484c003.tar.gz emacs-ee5be7c3c93602b4c5d6b7181544141e9484c003.zip | |
* xterm.c (x_list_fonts): If maxnames is less than 0, get all font
names.
* xfaces.c (x_face_list_fonts): Allocate struct font_name here.
(sorted_font_list): Moved allocation of struct font_name to
x_face_list_fonts.
(Fx_font_family_list): Set font-list-limit to -1 to get all font names.
(Fx_list_fonts): Set maxnames to -1 to get all font names.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/xfaces.c | 55 | ||||
| -rw-r--r-- | src/xterm.c | 24 |
3 files changed, 61 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8359b581a9b..5bef6ada00f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2003-02-18 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xterm.c (x_list_fonts): If maxnames is less than 0, get all font | ||
| 4 | names. | ||
| 5 | |||
| 6 | * xfaces.c (x_face_list_fonts): Allocate struct font_name here. | ||
| 7 | (sorted_font_list): Moved allocation of struct font_name to | ||
| 8 | x_face_list_fonts. | ||
| 9 | (Fx_font_family_list): Set font-list-limit to -1 to get all font names. | ||
| 10 | (Fx_list_fonts): Set maxnames to -1 to get all font names. | ||
| 11 | |||
| 1 | 2003-02-18 Kim F. Storm <storm@cua.dk> | 12 | 2003-02-18 Kim F. Storm <storm@cua.dk> |
| 2 | 13 | ||
| 3 | * lread.c (read1): Fix last change; "`" is not always special. | 14 | * lread.c (read1): Fix last change; "`" is not always special. |
diff --git a/src/xfaces.c b/src/xfaces.c index bf942be245f..0e6fa8daf34 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -474,7 +474,7 @@ static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); | |||
| 474 | static int better_font_p P_ ((int *, struct font_name *, struct font_name *, | 474 | static int better_font_p P_ ((int *, struct font_name *, struct font_name *, |
| 475 | int, int)); | 475 | int, int)); |
| 476 | static int x_face_list_fonts P_ ((struct frame *, char *, | 476 | static int x_face_list_fonts P_ ((struct frame *, char *, |
| 477 | struct font_name *, int, int)); | 477 | struct font_name **, int, int)); |
| 478 | static int font_scalable_p P_ ((struct font_name *)); | 478 | static int font_scalable_p P_ ((struct font_name *)); |
| 479 | static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); | 479 | static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); |
| 480 | static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); | 480 | static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); |
| @@ -2435,10 +2435,10 @@ sort_fonts (f, fonts, nfonts, cmpfn) | |||
| 2435 | fonts that we can't parse. Value is the number of fonts found. */ | 2435 | fonts that we can't parse. Value is the number of fonts found. */ |
| 2436 | 2436 | ||
| 2437 | static int | 2437 | static int |
| 2438 | x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p) | 2438 | x_face_list_fonts (f, pattern, pfonts, nfonts, try_alternatives_p) |
| 2439 | struct frame *f; | 2439 | struct frame *f; |
| 2440 | char *pattern; | 2440 | char *pattern; |
| 2441 | struct font_name *fonts; | 2441 | struct font_name **pfonts; |
| 2442 | int nfonts, try_alternatives_p; | 2442 | int nfonts, try_alternatives_p; |
| 2443 | { | 2443 | { |
| 2444 | int n, nignored; | 2444 | int n, nignored; |
| @@ -2447,7 +2447,10 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p) | |||
| 2447 | better to do it the other way around. */ | 2447 | better to do it the other way around. */ |
| 2448 | Lisp_Object lfonts; | 2448 | Lisp_Object lfonts; |
| 2449 | Lisp_Object lpattern, tem; | 2449 | Lisp_Object lpattern, tem; |
| 2450 | struct font_name *fonts = 0; | ||
| 2451 | int num_fonts = nfonts; | ||
| 2450 | 2452 | ||
| 2453 | *pfonts = 0; | ||
| 2451 | lpattern = build_string (pattern); | 2454 | lpattern = build_string (pattern); |
| 2452 | 2455 | ||
| 2453 | /* Get the list of fonts matching PATTERN. */ | 2456 | /* Get the list of fonts matching PATTERN. */ |
| @@ -2459,10 +2462,13 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p) | |||
| 2459 | lfonts = x_list_fonts (f, lpattern, -1, nfonts); | 2462 | lfonts = x_list_fonts (f, lpattern, -1, nfonts); |
| 2460 | #endif | 2463 | #endif |
| 2461 | 2464 | ||
| 2465 | if (nfonts < 0 && CONSP (lfonts)) | ||
| 2466 | num_fonts = Flength (lfonts); | ||
| 2467 | |||
| 2462 | /* Make a copy of the font names we got from X, and | 2468 | /* Make a copy of the font names we got from X, and |
| 2463 | split them into fields. */ | 2469 | split them into fields. */ |
| 2464 | n = nignored = 0; | 2470 | n = nignored = 0; |
| 2465 | for (tem = lfonts; CONSP (tem) && n < nfonts; tem = XCDR (tem)) | 2471 | for (tem = lfonts; CONSP (tem) && n < num_fonts; tem = XCDR (tem)) |
| 2466 | { | 2472 | { |
| 2467 | Lisp_Object elt, tail; | 2473 | Lisp_Object elt, tail; |
| 2468 | const char *name = SDATA (XCAR (tem)); | 2474 | const char *name = SDATA (XCAR (tem)); |
| @@ -2481,6 +2487,12 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p) | |||
| 2481 | continue; | 2487 | continue; |
| 2482 | } | 2488 | } |
| 2483 | 2489 | ||
| 2490 | if (! fonts) | ||
| 2491 | { | ||
| 2492 | *pfonts = (struct font_name *) xmalloc (num_fonts * sizeof **pfonts); | ||
| 2493 | fonts = *pfonts; | ||
| 2494 | } | ||
| 2495 | |||
| 2484 | /* Make a copy of the font name. */ | 2496 | /* Make a copy of the font name. */ |
| 2485 | fonts[n].name = xstrdup (name); | 2497 | fonts[n].name = xstrdup (name); |
| 2486 | 2498 | ||
| @@ -2504,6 +2516,8 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p) | |||
| 2504 | { | 2516 | { |
| 2505 | Lisp_Object list = Valternate_fontname_alist; | 2517 | Lisp_Object list = Valternate_fontname_alist; |
| 2506 | 2518 | ||
| 2519 | if (fonts) xfree (fonts); | ||
| 2520 | |||
| 2507 | while (CONSP (list)) | 2521 | while (CONSP (list)) |
| 2508 | { | 2522 | { |
| 2509 | Lisp_Object entry = XCAR (list); | 2523 | Lisp_Object entry = XCAR (list); |
| @@ -2527,7 +2541,7 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p) | |||
| 2527 | already with no success. */ | 2541 | already with no success. */ |
| 2528 | && (strcmp (SDATA (name), pattern) == 0 | 2542 | && (strcmp (SDATA (name), pattern) == 0 |
| 2529 | || (n = x_face_list_fonts (f, SDATA (name), | 2543 | || (n = x_face_list_fonts (f, SDATA (name), |
| 2530 | fonts, nfonts, 0), | 2544 | pfonts, nfonts, 0), |
| 2531 | n == 0))) | 2545 | n == 0))) |
| 2532 | patterns = XCDR (patterns); | 2546 | patterns = XCDR (patterns); |
| 2533 | } | 2547 | } |
| @@ -2556,17 +2570,17 @@ sorted_font_list (f, pattern, cmpfn, fonts) | |||
| 2556 | 2570 | ||
| 2557 | /* Get the list of fonts matching pattern. 100 should suffice. */ | 2571 | /* Get the list of fonts matching pattern. 100 should suffice. */ |
| 2558 | nfonts = DEFAULT_FONT_LIST_LIMIT; | 2572 | nfonts = DEFAULT_FONT_LIST_LIMIT; |
| 2559 | if (INTEGERP (Vfont_list_limit) && XINT (Vfont_list_limit) > 0) | 2573 | if (INTEGERP (Vfont_list_limit)) |
| 2560 | nfonts = XFASTINT (Vfont_list_limit); | 2574 | nfonts = XINT (Vfont_list_limit); |
| 2561 | 2575 | ||
| 2562 | *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts); | 2576 | *fonts = NULL; |
| 2563 | nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1); | 2577 | nfonts = x_face_list_fonts (f, pattern, fonts, nfonts, 1); |
| 2564 | 2578 | ||
| 2565 | /* Sort the resulting array and return it in *FONTS. If no | 2579 | /* Sort the resulting array and return it in *FONTS. If no |
| 2566 | fonts were found, make sure to set *FONTS to null. */ | 2580 | fonts were found, make sure to set *FONTS to null. */ |
| 2567 | if (nfonts) | 2581 | if (nfonts) |
| 2568 | sort_fonts (f, *fonts, nfonts, cmpfn); | 2582 | sort_fonts (f, *fonts, nfonts, cmpfn); |
| 2569 | else | 2583 | else if (*fonts) |
| 2570 | { | 2584 | { |
| 2571 | xfree (*fonts); | 2585 | xfree (*fonts); |
| 2572 | *fonts = NULL; | 2586 | *fonts = NULL; |
| @@ -2834,23 +2848,10 @@ are fixed-pitch. */) | |||
| 2834 | Lisp_Object result; | 2848 | Lisp_Object result; |
| 2835 | struct gcpro gcpro1; | 2849 | struct gcpro gcpro1; |
| 2836 | int count = SPECPDL_INDEX (); | 2850 | int count = SPECPDL_INDEX (); |
| 2837 | int limit; | ||
| 2838 | |||
| 2839 | /* Let's consider all fonts. Increase the limit for matching | ||
| 2840 | fonts until we have them all. */ | ||
| 2841 | for (limit = 500;;) | ||
| 2842 | { | ||
| 2843 | specbind (intern ("font-list-limit"), make_number (limit)); | ||
| 2844 | nfonts = font_list (f, Qnil, Qnil, Qnil, &fonts); | ||
| 2845 | 2851 | ||
| 2846 | if (nfonts == limit) | 2852 | /* Let's consider all fonts. */ |
| 2847 | { | 2853 | specbind (intern ("font-list-limit"), make_number (-1)); |
| 2848 | free_font_names (fonts, nfonts); | 2854 | nfonts = font_list (f, Qnil, Qnil, Qnil, &fonts); |
| 2849 | limit *= 2; | ||
| 2850 | } | ||
| 2851 | else | ||
| 2852 | break; | ||
| 2853 | } | ||
| 2854 | 2855 | ||
| 2855 | result = Qnil; | 2856 | result = Qnil; |
| 2856 | GCPRO1 (result); | 2857 | GCPRO1 (result); |
| @@ -2897,7 +2898,7 @@ the WIDTH times as wide as FACE on FRAME. */) | |||
| 2897 | CHECK_STRING (pattern); | 2898 | CHECK_STRING (pattern); |
| 2898 | 2899 | ||
| 2899 | if (NILP (maximum)) | 2900 | if (NILP (maximum)) |
| 2900 | maxnames = 2000; | 2901 | maxnames = -1; |
| 2901 | else | 2902 | else |
| 2902 | { | 2903 | { |
| 2903 | CHECK_NATNUM (maximum); | 2904 | CHECK_NATNUM (maximum); |
diff --git a/src/xterm.c b/src/xterm.c index a27ddb22612..ebc0366e36b 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -14536,8 +14536,28 @@ x_list_fonts (f, pattern, size, maxnames) | |||
| 14536 | { | 14536 | { |
| 14537 | /* We try at least 10 fonts because XListFonts will return | 14537 | /* We try at least 10 fonts because XListFonts will return |
| 14538 | auto-scaled fonts at the head. */ | 14538 | auto-scaled fonts at the head. */ |
| 14539 | names = XListFonts (dpy, SDATA (pattern), max (maxnames, 10), | 14539 | if (maxnames < 0) |
| 14540 | &num_fonts); | 14540 | { |
| 14541 | int limit; | ||
| 14542 | |||
| 14543 | for (limit = 500;;) | ||
| 14544 | { | ||
| 14545 | names = XListFonts (dpy, SDATA (pattern), limit, &num_fonts); | ||
| 14546 | if (num_fonts == limit) | ||
| 14547 | { | ||
| 14548 | BLOCK_INPUT; | ||
| 14549 | XFreeFontNames (names); | ||
| 14550 | UNBLOCK_INPUT; | ||
| 14551 | limit *= 2; | ||
| 14552 | } | ||
| 14553 | else | ||
| 14554 | break; | ||
| 14555 | } | ||
| 14556 | } | ||
| 14557 | else | ||
| 14558 | names = XListFonts (dpy, SDATA (pattern), max (maxnames, 10), | ||
| 14559 | &num_fonts); | ||
| 14560 | |||
| 14541 | if (x_had_errors_p (dpy)) | 14561 | if (x_had_errors_p (dpy)) |
| 14542 | { | 14562 | { |
| 14543 | /* This error is perhaps due to insufficient memory on X | 14563 | /* This error is perhaps due to insufficient memory on X |