From: Gerd Moellmann Date: Wed, 17 Jan 2001 15:51:32 +0000 (+0000) Subject: (x_face_list_fonts): Call x_list_fonts with SIZE -1, X-Git-Tag: emacs-pretest-21.0.96~240 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d26d6fd91601e02e2fe38d371933a22b041c8cf8;p=emacs.git (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. --- diff --git a/src/ChangeLog b/src/ChangeLog index ef20fc4426f..01f3772db32 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2001-01-17 Gerd Moellmann + * xfaces.c (x_face_list_fonts): Call x_list_fonts with SIZE -1, + so that scalable fonts are included. + * xterm.c (x_list_fonts): Allow scalable fonts if SIZE is < 0, In the cache, use a key containing the information if scalable fonts are included. @@ -7,6 +10,9 @@ 2001-01-17 Kim F. Storm + * xfaces.c (x_face_list_fonts): Use x_list_fonts instead of + XListFonts to take advantage of font caching. + * xterm.c (x_list_fonts): Ensure caching font information when called for a null frame, which is the case frequently when Emacs 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 @@ /* xfaces.c -- "Face" primitives. - Copyright (C) 1993, 1994, 1998, 1999, 2000 Free Software Foundation. + Copyright (C) 1993, 1994, 1998, 1999, 2000, 2001 + Free Software Foundation. This file is part of GNU Emacs. @@ -2296,100 +2297,60 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, int nfonts, try_alternatives_p; int scalable_fonts_p; { - int n, i, j; - char **names; -#ifdef HAVE_X_WINDOWS - Display *dpy = f ? FRAME_X_DISPLAY (f) : x_display_list->display; + int n; - /* Get the list of fonts matching PATTERN from the X server. */ - BLOCK_INPUT; - names = XListFonts (dpy, pattern, nfonts, &n); - UNBLOCK_INPUT; -#endif /* HAVE_X_WINDOWS */ -#if defined (WINDOWSNT) || defined (macintosh) /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be better to do it the other way around. */ Lisp_Object lfonts; Lisp_Object lpattern, tem; - n = 0; - names = NULL; - lpattern = build_string (pattern); /* Get the list of fonts matching PATTERN. */ BLOCK_INPUT; #ifdef WINDOWSNT lfonts = w32_list_fonts (f, lpattern, 0, nfonts); -#else /* macintosh */ - lfonts = x_list_fonts (f, lpattern, 0, nfonts); +#else + lfonts = x_list_fonts (f, lpattern, -1, nfonts); #endif UNBLOCK_INPUT; - /* Count fonts returned */ + /* Make a copy of the font names we got from X, and + split them into fields. */ + n = 0; for (tem = lfonts; CONSP (tem); tem = XCDR (tem)) - n++; - - /* Allocate array. */ - if (n) - names = (char **) xmalloc (n * sizeof (char *)); - - /* Extract font names into char * array. */ - tem = lfonts; - for (i = 0; i < n; i++) { - names[i] = XSTRING (XCAR (tem))->data; - tem = XCDR (tem); - } -#endif /* defined (WINDOWSNT) || defined (macintosh) */ + Lisp_Object elt, tail; + char *name = XSTRING (XCAR (tem))->data; - if (names) - { - /* Make a copy of the font names we got from X, and - split them into fields. */ - for (i = j = 0; i < n; ++i) + for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) { - Lisp_Object elt, tail; - - for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) - { - elt = XCAR (tail); - if (STRINGP (elt) - && fast_c_string_match_ignore_case (elt, names[i]) >= 0) - break; - } - if (!NILP (tail)) - continue; + elt = XCAR (tail); + if (STRINGP (elt) + && fast_c_string_match_ignore_case (elt, name) >= 0) + break; + } + if (!NILP (tail)) + continue; - /* Make a copy of the font name. */ - fonts[j].name = xstrdup (names[i]); + /* Make a copy of the font name. */ + fonts[n].name = xstrdup (name); - /* Ignore fonts having a name that we can't parse. */ - if (!split_font_name (f, fonts + j, 1)) - xfree (fonts[j].name); - else if (font_scalable_p (fonts + j)) - { - if (!scalable_fonts_p - || !may_use_scalable_font_p (fonts + j, names[i])) - xfree (fonts[j].name); - else - ++j; - } + /* Ignore fonts having a name that we can't parse. */ + if (!split_font_name (f, fonts + n, 1)) + xfree (fonts[n].name); + else if (font_scalable_p (fonts + n)) + { + if (!scalable_fonts_p + || !may_use_scalable_font_p (fonts + n, name)) + xfree (fonts[n].name); else - ++j; + ++n; } - - n = j; - -#ifdef HAVE_X_WINDOWS - /* Free font names. */ - BLOCK_INPUT; - XFreeFontNames (names); - UNBLOCK_INPUT; -#endif + else + ++n; } - /* If no fonts found, try patterns from Valternate_fontname_alist. */ if (n == 0 && try_alternatives_p) {