diff options
| author | Gerd Moellmann | 2001-01-17 15:51:32 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-01-17 15:51:32 +0000 |
| commit | d26d6fd91601e02e2fe38d371933a22b041c8cf8 (patch) | |
| tree | a02d99e3ade037255fb781541f00c42cb6b25406 | |
| parent | 9c11f79e2d17431a6dcb3f5b406e4bc91577ca06 (diff) | |
| download | emacs-d26d6fd91601e02e2fe38d371933a22b041c8cf8.tar.gz emacs-d26d6fd91601e02e2fe38d371933a22b041c8cf8.zip | |
(x_face_list_fonts): Call x_list_fonts with SIZE -1,
so that scalable fonts are included.
(x_face_list_fonts): Use x_list_fonts instead of
XListFonts to take advantage of font caching.
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/xfaces.c | 101 |
2 files changed, 37 insertions, 70 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ef20fc4426f..01f3772db32 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2001-01-17 Gerd Moellmann <gerd@gnu.org> | 1 | 2001-01-17 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * xfaces.c (x_face_list_fonts): Call x_list_fonts with SIZE -1, | ||
| 4 | so that scalable fonts are included. | ||
| 5 | |||
| 3 | * xterm.c (x_list_fonts): Allow scalable fonts if SIZE is < 0, | 6 | * xterm.c (x_list_fonts): Allow scalable fonts if SIZE is < 0, |
| 4 | In the cache, use a key containing the information if scalable | 7 | In the cache, use a key containing the information if scalable |
| 5 | fonts are included. | 8 | fonts are included. |
| @@ -7,6 +10,9 @@ | |||
| 7 | 10 | ||
| 8 | 2001-01-17 Kim F. Storm <storm@filanet.dk> | 11 | 2001-01-17 Kim F. Storm <storm@filanet.dk> |
| 9 | 12 | ||
| 13 | * xfaces.c (x_face_list_fonts): Use x_list_fonts instead of | ||
| 14 | XListFonts to take advantage of font caching. | ||
| 15 | |||
| 10 | * xterm.c (x_list_fonts): Ensure caching font information when | 16 | * xterm.c (x_list_fonts): Ensure caching font information when |
| 11 | called for a null frame, which is the case frequently when Emacs | 17 | called for a null frame, which is the case frequently when Emacs |
| 12 | starts. | 18 | starts. |
diff --git a/src/xfaces.c b/src/xfaces.c index e890dc790fd..2275a928ecf 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* xfaces.c -- "Face" primitives. | 1 | /* xfaces.c -- "Face" primitives. |
| 2 | Copyright (C) 1993, 1994, 1998, 1999, 2000 Free Software Foundation. | 2 | Copyright (C) 1993, 1994, 1998, 1999, 2000, 2001 |
| 3 | Free Software Foundation. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -2296,100 +2297,60 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, | |||
| 2296 | int nfonts, try_alternatives_p; | 2297 | int nfonts, try_alternatives_p; |
| 2297 | int scalable_fonts_p; | 2298 | int scalable_fonts_p; |
| 2298 | { | 2299 | { |
| 2299 | int n, i, j; | 2300 | int n; |
| 2300 | char **names; | ||
| 2301 | #ifdef HAVE_X_WINDOWS | ||
| 2302 | Display *dpy = f ? FRAME_X_DISPLAY (f) : x_display_list->display; | ||
| 2303 | 2301 | ||
| 2304 | /* Get the list of fonts matching PATTERN from the X server. */ | ||
| 2305 | BLOCK_INPUT; | ||
| 2306 | names = XListFonts (dpy, pattern, nfonts, &n); | ||
| 2307 | UNBLOCK_INPUT; | ||
| 2308 | #endif /* HAVE_X_WINDOWS */ | ||
| 2309 | #if defined (WINDOWSNT) || defined (macintosh) | ||
| 2310 | /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be | 2302 | /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be |
| 2311 | better to do it the other way around. */ | 2303 | better to do it the other way around. */ |
| 2312 | Lisp_Object lfonts; | 2304 | Lisp_Object lfonts; |
| 2313 | Lisp_Object lpattern, tem; | 2305 | Lisp_Object lpattern, tem; |
| 2314 | 2306 | ||
| 2315 | n = 0; | ||
| 2316 | names = NULL; | ||
| 2317 | |||
| 2318 | lpattern = build_string (pattern); | 2307 | lpattern = build_string (pattern); |
| 2319 | 2308 | ||
| 2320 | /* Get the list of fonts matching PATTERN. */ | 2309 | /* Get the list of fonts matching PATTERN. */ |
| 2321 | BLOCK_INPUT; | 2310 | BLOCK_INPUT; |
| 2322 | #ifdef WINDOWSNT | 2311 | #ifdef WINDOWSNT |
| 2323 | lfonts = w32_list_fonts (f, lpattern, 0, nfonts); | 2312 | lfonts = w32_list_fonts (f, lpattern, 0, nfonts); |
| 2324 | #else /* macintosh */ | 2313 | #else |
| 2325 | lfonts = x_list_fonts (f, lpattern, 0, nfonts); | 2314 | lfonts = x_list_fonts (f, lpattern, -1, nfonts); |
| 2326 | #endif | 2315 | #endif |
| 2327 | UNBLOCK_INPUT; | 2316 | UNBLOCK_INPUT; |
| 2328 | 2317 | ||
| 2329 | /* Count fonts returned */ | 2318 | /* Make a copy of the font names we got from X, and |
| 2319 | split them into fields. */ | ||
| 2320 | n = 0; | ||
| 2330 | for (tem = lfonts; CONSP (tem); tem = XCDR (tem)) | 2321 | for (tem = lfonts; CONSP (tem); tem = XCDR (tem)) |
| 2331 | n++; | ||
| 2332 | |||
| 2333 | /* Allocate array. */ | ||
| 2334 | if (n) | ||
| 2335 | names = (char **) xmalloc (n * sizeof (char *)); | ||
| 2336 | |||
| 2337 | /* Extract font names into char * array. */ | ||
| 2338 | tem = lfonts; | ||
| 2339 | for (i = 0; i < n; i++) | ||
| 2340 | { | 2322 | { |
| 2341 | names[i] = XSTRING (XCAR (tem))->data; | 2323 | Lisp_Object elt, tail; |
| 2342 | tem = XCDR (tem); | 2324 | char *name = XSTRING (XCAR (tem))->data; |
| 2343 | } | ||
| 2344 | #endif /* defined (WINDOWSNT) || defined (macintosh) */ | ||
| 2345 | 2325 | ||
| 2346 | if (names) | 2326 | for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) |
| 2347 | { | ||
| 2348 | /* Make a copy of the font names we got from X, and | ||
| 2349 | split them into fields. */ | ||
| 2350 | for (i = j = 0; i < n; ++i) | ||
| 2351 | { | 2327 | { |
| 2352 | Lisp_Object elt, tail; | 2328 | elt = XCAR (tail); |
| 2353 | 2329 | if (STRINGP (elt) | |
| 2354 | for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) | 2330 | && fast_c_string_match_ignore_case (elt, name) >= 0) |
| 2355 | { | 2331 | break; |
| 2356 | elt = XCAR (tail); | 2332 | } |
| 2357 | if (STRINGP (elt) | 2333 | if (!NILP (tail)) |
| 2358 | && fast_c_string_match_ignore_case (elt, names[i]) >= 0) | 2334 | continue; |
| 2359 | break; | ||
| 2360 | } | ||
| 2361 | if (!NILP (tail)) | ||
| 2362 | continue; | ||
| 2363 | 2335 | ||
| 2364 | /* Make a copy of the font name. */ | 2336 | /* Make a copy of the font name. */ |
| 2365 | fonts[j].name = xstrdup (names[i]); | 2337 | fonts[n].name = xstrdup (name); |
| 2366 | 2338 | ||
| 2367 | /* Ignore fonts having a name that we can't parse. */ | 2339 | /* Ignore fonts having a name that we can't parse. */ |
| 2368 | if (!split_font_name (f, fonts + j, 1)) | 2340 | if (!split_font_name (f, fonts + n, 1)) |
| 2369 | xfree (fonts[j].name); | 2341 | xfree (fonts[n].name); |
| 2370 | else if (font_scalable_p (fonts + j)) | 2342 | else if (font_scalable_p (fonts + n)) |
| 2371 | { | 2343 | { |
| 2372 | if (!scalable_fonts_p | 2344 | if (!scalable_fonts_p |
| 2373 | || !may_use_scalable_font_p (fonts + j, names[i])) | 2345 | || !may_use_scalable_font_p (fonts + n, name)) |
| 2374 | xfree (fonts[j].name); | 2346 | xfree (fonts[n].name); |
| 2375 | else | ||
| 2376 | ++j; | ||
| 2377 | } | ||
| 2378 | else | 2347 | else |
| 2379 | ++j; | 2348 | ++n; |
| 2380 | } | 2349 | } |
| 2381 | 2350 | else | |
| 2382 | n = j; | 2351 | ++n; |
| 2383 | |||
| 2384 | #ifdef HAVE_X_WINDOWS | ||
| 2385 | /* Free font names. */ | ||
| 2386 | BLOCK_INPUT; | ||
| 2387 | XFreeFontNames (names); | ||
| 2388 | UNBLOCK_INPUT; | ||
| 2389 | #endif | ||
| 2390 | } | 2352 | } |
| 2391 | 2353 | ||
| 2392 | |||
| 2393 | /* If no fonts found, try patterns from Valternate_fontname_alist. */ | 2354 | /* If no fonts found, try patterns from Valternate_fontname_alist. */ |
| 2394 | if (n == 0 && try_alternatives_p) | 2355 | if (n == 0 && try_alternatives_p) |
| 2395 | { | 2356 | { |