aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann1999-08-15 22:29:45 +0000
committerGerd Moellmann1999-08-15 22:29:45 +0000
commit057df17c4bc0be2a3b2749b437eed10b000bdfea (patch)
tree130bba0f1007f401a88042a35e7a3ec42c10b071
parentfe6f39d99bb4b8cb1784fb4775be4adc551cc6ea (diff)
downloademacs-057df17c4bc0be2a3b2749b437eed10b000bdfea.tar.gz
emacs-057df17c4bc0be2a3b2749b437eed10b000bdfea.zip
(Vfont_list_limit): New.
(syms_of_xfaces): Make it a user-variable. (DEFAULT_FONT_LIST_LIMIT): New. (sorted_font_list): If Vfont_list_limit is an integer > 0, list maximally that number of fonts, otherwise use DEFAULT_FONT_LIST_LIMIT. (Fx_font_family_list): Bind `font-list-limit' to higher values until we have all fonts. (Fxfont_list): Additionally return the full names of fonts and their registry and encoding.
-rw-r--r--src/xfaces.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index aa74650aa1d..2bd29a00ff4 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -311,6 +311,12 @@ Lisp_Object Vface_alternative_font_family_alist;
311Lisp_Object Vscalable_fonts_allowed; 311Lisp_Object Vscalable_fonts_allowed;
312#endif 312#endif
313 313
314/* Maximum number of fonts to consider in font_list. If not an
315 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */
316
317Lisp_Object Vfont_list_limit;
318#define DEFAULT_FONT_LIST_LIMIT 100
319
314/* The symbols `foreground-color' and `background-color' which can be 320/* The symbols `foreground-color' and `background-color' which can be
315 used as part of a `face' property. This is for compatibility with 321 used as part of a `face' property. This is for compatibility with
316 Emacs 20.2. */ 322 Emacs 20.2. */
@@ -2155,7 +2161,10 @@ sorted_font_list (f, pattern, cmpfn, fonts)
2155 int nfonts; 2161 int nfonts;
2156 2162
2157 /* Get the list of fonts matching pattern. 100 should suffice. */ 2163 /* Get the list of fonts matching pattern. 100 should suffice. */
2158 nfonts = 100; 2164 nfonts = DEFAULT_FONT_LIST_LIMIT;
2165 if (INTEGERP (Vfont_list_limit) && XINT (Vfont_list_limit) > 0)
2166 nfonts = XFASTINT (Vfont_list_limit);
2167
2159 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts); 2168 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts);
2160#if SCALABLE_FONTS 2169#if SCALABLE_FONTS
2161 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 1); 2170 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 1);
@@ -2285,11 +2294,13 @@ Otherwise, FAMILY must be a string, possibly containing wildcards\n\
2285`?' and `*'.\n\ 2294`?' and `*'.\n\
2286If FRAME is omitted or nil, use the selected frame.\n\ 2295If FRAME is omitted or nil, use the selected frame.\n\
2287Each element of the result is a vector [FAMILY WIDTH POINT-SIZE WEIGHT\n\ 2296Each element of the result is a vector [FAMILY WIDTH POINT-SIZE WEIGHT\n\
2288SLANT FIXED-P].\n\ 2297SLANT FIXED-P FULL REGISTRY-AND-ENCODING].\n\
2289FAMILY is the font family name. POINT-SIZE is the size of the\n\ 2298FAMILY is the font family name. POINT-SIZE is the size of the\n\
2290font in 1/10 pt. WIDTH, WEIGHT, and SLANT are symbols describing the\n\ 2299font in 1/10 pt. WIDTH, WEIGHT, and SLANT are symbols describing the\n\
2291width, weight and slant of the font. These symbols are the same as for\n\ 2300width, weight and slant of the font. These symbols are the same as for\n\
2292face attributes. FIXED-P is non-nil if the font is fixed-pitch.\n\ 2301face attributes. FIXED-P is non-nil if the font is fixed-pitch.\n\
2302FULL is the full name of the font, and REGISTRY-AND-ENCODING is a string\n\
2303giving the registry and encoding of the font.\n\
2293The result list is sorted according to the current setting of\n\ 2304The result list is sorted according to the current setting of\n\
2294the face font sort order.") 2305the face font sort order.")
2295 (family, frame) 2306 (family, frame)
@@ -2315,7 +2326,8 @@ the face font sort order.")
2315 nfonts = font_list (f, NULL, family_pattern, NULL, &fonts); 2326 nfonts = font_list (f, NULL, family_pattern, NULL, &fonts);
2316 for (i = nfonts - 1; i >= 0; --i) 2327 for (i = nfonts - 1; i >= 0; --i)
2317 { 2328 {
2318 Lisp_Object v = Fmake_vector (make_number (6), Qnil); 2329 Lisp_Object v = Fmake_vector (make_number (8), Qnil);
2330 char *tem;
2319 2331
2320#define ASET(VECTOR, IDX, VAL) (XVECTOR (VECTOR)->contents[IDX] = (VAL)) 2332#define ASET(VECTOR, IDX, VAL) (XVECTOR (VECTOR)->contents[IDX] = (VAL))
2321 2333
@@ -2325,6 +2337,13 @@ the face font sort order.")
2325 ASET (v, 3, xlfd_symbolic_weight (fonts + i)); 2337 ASET (v, 3, xlfd_symbolic_weight (fonts + i));
2326 ASET (v, 4, xlfd_symbolic_slant (fonts + i)); 2338 ASET (v, 4, xlfd_symbolic_slant (fonts + i));
2327 ASET (v, 5, xlfd_fixed_p (fonts + i) ? Qt : Qnil); 2339 ASET (v, 5, xlfd_fixed_p (fonts + i) ? Qt : Qnil);
2340 tem = build_font_name (fonts + i);
2341 ASET (v, 6, build_string (tem));
2342 sprintf (tem, "%s-%s", fonts[i].fields[XLFD_REGISTRY],
2343 fonts[i].fields[XLFD_ENCODING]);
2344 ASET (v, 7, build_string (tem));
2345 xfree (tem);
2346
2328 result = Fcons (v, result); 2347 result = Fcons (v, result);
2329 2348
2330#undef ASET 2349#undef ASET
@@ -2352,8 +2371,25 @@ are fixed-pitch.")
2352 struct font_name *fonts; 2371 struct font_name *fonts;
2353 Lisp_Object result; 2372 Lisp_Object result;
2354 struct gcpro gcpro1; 2373 struct gcpro gcpro1;
2374 int count = specpdl_ptr - specpdl;
2375 int limit;
2376
2377 /* Let's consider all fonts. Increase the limit for matching
2378 fonts until we have them all. */
2379 for (limit = 500;;)
2380 {
2381 specbind (intern ("font-list-limit"), make_number (limit));
2382 nfonts = font_list (f, NULL, "*", NULL, &fonts);
2383
2384 if (nfonts == limit)
2385 {
2386 free_font_names (fonts, nfonts);
2387 limit *= 2;
2388 }
2389 else
2390 break;
2391 }
2355 2392
2356 nfonts = font_list (f, NULL, "*", NULL, &fonts);
2357 result = Qnil; 2393 result = Qnil;
2358 GCPRO1 (result); 2394 GCPRO1 (result);
2359 for (i = nfonts - 1; i >= 0; --i) 2395 for (i = nfonts - 1; i >= 0; --i)
@@ -2364,7 +2400,7 @@ are fixed-pitch.")
2364 remove_duplicates (result); 2400 remove_duplicates (result);
2365 free_font_names (fonts, nfonts); 2401 free_font_names (fonts, nfonts);
2366 UNGCPRO; 2402 UNGCPRO;
2367 return result; 2403 return unbind_to (count, result);
2368} 2404}
2369 2405
2370 2406
@@ -6247,6 +6283,12 @@ syms_of_xfaces ()
6247#endif /* GLYPH_DEBUG */ 6283#endif /* GLYPH_DEBUG */
6248 defsubr (&Sclear_face_cache); 6284 defsubr (&Sclear_face_cache);
6249 6285
6286 DEFVAR_LISP ("font-list-limit", &Vfont_list_limit,
6287 "*Limit for font matching.\n\
6288If an integer > 0, font matching functions won't load more than\n\
6289that number of fonts when searching for a matching font.");
6290 Vfont_list_limit = make_number (DEFAULT_FONT_LIST_LIMIT);
6291
6250 DEFVAR_LISP ("face-new-frame-defaults", &Vface_new_frame_defaults, 6292 DEFVAR_LISP ("face-new-frame-defaults", &Vface_new_frame_defaults,
6251 "List of global face definitions (for internal use only.)"); 6293 "List of global face definitions (for internal use only.)");
6252 Vface_new_frame_defaults = Qnil; 6294 Vface_new_frame_defaults = Qnil;