aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann <[email protected]>2001-01-17 15:51:32 +0000
committerGerd Moellmann <[email protected]>2001-01-17 15:51:32 +0000
commitd26d6fd91601e02e2fe38d371933a22b041c8cf8 (patch)
treea02d99e3ade037255fb781541f00c42cb6b25406
parent9c11f79e2d17431a6dcb3f5b406e4bc91577ca06 (diff)
(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/ChangeLog6
-rw-r--r--src/xfaces.c101
2 files changed, 37 insertions, 70 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ef20fc4426..01f3772db3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,8 @@
2001-01-17 Gerd Moellmann <[email protected]>
+ * 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 <[email protected]>
+ * 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 e890dc790f..2275a928ec 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)
{