aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 83076db0b2e..3cd23598763 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3325,7 +3325,7 @@ DEFUN ("unfocus-frame", Funfocus_frame, Sunfocus_frame, 0, 0, 0,
3325 return Qnil; 3325 return Qnil;
3326} 3326}
3327 3327
3328DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 3, 0, 3328DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 4, 0,
3329 "Return a list of the names of available fonts matching PATTERN.\n\ 3329 "Return a list of the names of available fonts matching PATTERN.\n\
3330If optional arguments FACE and FRAME are specified, return only fonts\n\ 3330If optional arguments FACE and FRAME are specified, return only fonts\n\
3331the same size as FACE on FRAME.\n\ 3331the same size as FACE on FRAME.\n\
@@ -3340,9 +3340,12 @@ The return value is a list of strings, suitable as arguments to\n\
3340set-face-font.\n\ 3340set-face-font.\n\
3341\n\ 3341\n\
3342Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\ 3342Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\
3343even if they match PATTERN and FACE.") 3343even if they match PATTERN and FACE.\n\
3344 (pattern, face, frame) 3344\n\
3345 Lisp_Object pattern, face, frame; 3345The optional fourth argument MAXIMUM sets a limit on how many\n\
3346fonts to match. The first MAXIMUM fonts are reported.")
3347 (pattern, face, frame, maximum)
3348 Lisp_Object pattern, face, frame, maximum;
3346{ 3349{
3347 int num_fonts; 3350 int num_fonts;
3348 char **names; 3351 char **names;
@@ -3352,12 +3355,22 @@ even if they match PATTERN and FACE.")
3352 XFontStruct *size_ref; 3355 XFontStruct *size_ref;
3353 Lisp_Object list; 3356 Lisp_Object list;
3354 FRAME_PTR f; 3357 FRAME_PTR f;
3358 Lisp_Object key;
3359 int maxnames;
3355 3360
3356 check_x (); 3361 check_x ();
3357 CHECK_STRING (pattern, 0); 3362 CHECK_STRING (pattern, 0);
3358 if (!NILP (face)) 3363 if (!NILP (face))
3359 CHECK_SYMBOL (face, 1); 3364 CHECK_SYMBOL (face, 1);
3360 3365
3366 if (NILP (maximum))
3367 maxnames = 2000;
3368 else
3369 {
3370 CHECK_NATNUM (maximum, 0);
3371 maxnames = XINT (maximum);
3372 }
3373
3361 f = check_x_frame (frame); 3374 f = check_x_frame (frame);
3362 3375
3363 /* Determine the width standard for comparison with the fonts we find. */ 3376 /* Determine the width standard for comparison with the fonts we find. */
@@ -3386,7 +3399,8 @@ even if they match PATTERN and FACE.")
3386 } 3399 }
3387 3400
3388 /* See if we cached the result for this particular query. */ 3401 /* See if we cached the result for this particular query. */
3389 list = Fassoc (pattern, 3402 key = Fcons (pattern, maximum);
3403 list = Fassoc (key,
3390 XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr); 3404 XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr);
3391 3405
3392 /* We have info in the cache for this PATTERN. */ 3406 /* We have info in the cache for this PATTERN. */
@@ -3437,14 +3451,14 @@ even if they match PATTERN and FACE.")
3437 if (size_ref) 3451 if (size_ref)
3438 names = XListFontsWithInfo (FRAME_X_DISPLAY (f), 3452 names = XListFontsWithInfo (FRAME_X_DISPLAY (f),
3439 XSTRING (pattern)->data, 3453 XSTRING (pattern)->data,
3440 2000, /* maxnames */ 3454 maxnames,
3441 &num_fonts, /* count_return */ 3455 &num_fonts, /* count_return */
3442 &info); /* info_return */ 3456 &info); /* info_return */
3443 else 3457 else
3444#endif 3458#endif
3445 names = XListFonts (FRAME_X_DISPLAY (f), 3459 names = XListFonts (FRAME_X_DISPLAY (f),
3446 XSTRING (pattern)->data, 3460 XSTRING (pattern)->data,
3447 2000, /* maxnames */ 3461 maxnames,
3448 &num_fonts); /* count_return */ 3462 &num_fonts); /* count_return */
3449 3463
3450 x_check_errors (FRAME_X_DISPLAY (f), "XListFonts failure: %s"); 3464 x_check_errors (FRAME_X_DISPLAY (f), "XListFonts failure: %s");
@@ -3465,7 +3479,7 @@ even if they match PATTERN and FACE.")
3465 for (i = 0; i < num_fonts; i++) 3479 for (i = 0; i < num_fonts; i++)
3466 full_list = Fcons (build_string (names[i]), full_list); 3480 full_list = Fcons (build_string (names[i]), full_list);
3467 XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr 3481 XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr
3468 = Fcons (Fcons (pattern, full_list), 3482 = Fcons (Fcons (key, full_list),
3469 XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr); 3483 XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr);
3470 3484
3471 /* Make a list of the fonts that have the right width. */ 3485 /* Make a list of the fonts that have the right width. */