view src/x-list-font.c @ 20331:39baaa9c5980

Some comment and doc fixes. (ps-print-version): New version number (3.05.2) and doc fix. (ps-print, ps-header-lines, ps-show-n-of-n, ps-font-info-database) (ps-font-family, ps-font-size, ps-header-font-family) (ps-header-font-size, ps-header-title-font-size, ps-bold-faces) (ps-italic-faces, ps-underlined-faces, ps-left-header, ps-right-header) (ps-font, ps-font-bold, ps-font-italic, ps-font-bold-italic) (ps-avg-char-width, ps-space-width, ps-line-height): Doc fix. (ps-error-scale-font): New fn. (ps-soft-lf, ps-hard-lf): Fn deleted. (ps-get-page-dimensions, ps-set-bg, ps-face-bold-p, ps-face-italic-p) (ps-set-color): Reindentation. (ps-output-string-prim, ps-xemacs-face-kind-p): Internal blank lines deleted. (ps-set-font): Little programming improvement. (ps-line-lengths-internal, ps-nb-pages, ps-select-font) (ps-select-header-font): Simplify some expressions. (ps-plot-region): Replace (- X 1) by (1- X). (ps-generate-header): Replace (+ X 1) by (1+ X). (ps-print-preprint, ps-plot-with-face, ps-print-ensure-fontified) (ps-kill-emacs-check): Replace (if (and A B) C) by (and A B C). (ps-init-output-queue, ps-gnus-article-prepare-hook, ps-jts-ps-setup): Replace (setq a b)(setq c d) by (setq a b c d). (ps-begin-file, ps-end-file): Replace (ps-output A)(ps-output B) by (ps-output A B). (ps-begin-page): Replace (ps-output A)(ps-output B) by (ps-output A B), replace (setq a b)(setq c d) by (setq a b c d). (ps-next-line, ps-continue-line): Replace (setq a b)(setq c d) by (setq a b c d), and incorporates ps-soft-lf and ps-hard-lf, respectively. (ps-plot): Replace (setq a b)(setq c d) by (setq a b c d), and programming improvement. (ps-generate-postscript-with-faces): Initialization fix, replace (setq a b)(setq c d) by (setq a b c d), replace (if (and A B) C) by (and A B C). (ps-generate): Doc fix, reprogramming to set the page count, replace (setq a b)(setq c d) by (setq a b c d), replace (if A nil B) by (or A B), replace (if (and A B) C) by (and A B C). (ps-info-mode-hook): Replace (list 'A 'B) by '(A B). (ps-jack-setup): Replace (list) by nil.
author Karl Heuer <kwzh@gnu.org>
date Sun, 23 Nov 1997 02:26:50 +0000
parents f21dd94faebc
children 6303fc8c3e7c
line wrap: on
line source

DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 5, 0,
  "Return a list of the names of available fonts matching PATTERN.\n\
If optional arguments FACE and FRAME are specified, return only fonts\n\
the same size as FACE on FRAME.\n\
PATTERN is a string, perhaps with wildcard characters;\n\
  the * character matches any substring, and\n\
  the ? character matches any single character.\n\
  PATTERN is case-insensitive.\n\
FACE is a face name--a symbol.\n\
\n\
The return value is a list of strings, suitable as arguments to\n\
set-face-font.\n\
\n\
Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\
even if they match PATTERN and FACE.\n\
The optional fourth argument MAXIMUM sets a limit on how many\n\
fonts to match.  The first MAXIMUM fonts are reported.\n\
The optional fifth argument WIDTH, if specified, is a number of columns\n\
occupied by a character of a font.  In that case, return only fonts\n\
the WIDTH times as wide as FACE on FRAME.")
  (pattern, face, frame, maximum, width)
    Lisp_Object pattern, face, frame, maximum, width;
{
  FRAME_PTR f;
  int size, cols;
  int maxnames;

  check_x ();
  CHECK_STRING (pattern, 0);
  if (!NILP (face))
    CHECK_SYMBOL (face, 1);

  if (NILP (maximum))
    maxnames = 2000;
  else
    {
      CHECK_NATNUM (maximum, 0);
      maxnames = XINT (maximum);
    }

  if (!NILP (width))
    CHECK_NUMBER (width, 4);

  /* We can't simply call check_x_frame because this function may be
     called before any frame is created.  */
  if (NILP (frame))
    f = selected_frame;
  else
    {
      CHECK_LIVE_FRAME (frame, 0);
      f = XFRAME (frame);
    }
  if (! FRAME_X_P (f))
    {
      /* Perhaps we have not yet created any frame.  */
      f = NULL;
      face = Qnil;
    }

  /* Determine the width standard for comparison with the fonts we find.  */

  if (NILP (face))
    size = 0;
  else
    {
      int face_id;

      face_id = face_name_id_number (f, face);

      if (face_id < 0 || face_id >= FRAME_N_PARAM_FACES (f)
	  || FRAME_PARAM_FACES (f) [face_id] == 0
	  || FRAME_PARAM_FACES (f) [face_id]->font == (XFontStruct *) (~0))
	size = f->output_data.x->font->max_bounds.width;
      else
	size = FRAME_PARAM_FACES (f) [face_id]->font->max_bounds.width;

      if (!NILP (width))
	  size *= XINT (width);
    }

  {
    Lisp_Object args[2];

    args[0] = x_list_fonts (f, pattern, size, maxnames);
    if (f == NULL)
      /* We don't have to check fontsets.  */
      return args[0];
    args[1] = list_fontsets (f, pattern, size);
    return Fnconc (2, args);
  }
}