Mercurial > emacs
changeset 35369:aca9ba55cfcc
(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.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 17 Jan 2001 15:50:29 +0000 |
parents | 1e3b82738a26 |
children | bbca4b18a59c |
files | src/xfaces.c |
diffstat | 1 files changed, 37 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xfaces.c Wed Jan 17 15:46:49 2001 +0000 +++ b/src/xfaces.c Wed Jan 17 15:50:29 2001 +0000 @@ -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,99 +2297,59 @@ 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; - - /* 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) + int n; + /* 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) */ - - 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) + { + Lisp_Object elt, tail; + char *name = XSTRING (XCAR (tem))->data; + + 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; - - /* Make a copy of the font name. */ - fonts[j].name = xstrdup (names[i]); - - /* 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; - } + 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[n].name = xstrdup (name); + + /* 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)