view src/x-list-font.c @ 19707:0181cc080316

Include limits.h and errno.h. Declare externs from other files. (w32_in_use): New variable. (check_w32, have_menus_p, x_set_title, w32_msg_worker, find_deferred_msg, send_deferred_msg, complete_deferred_msg, Fw32_focus_frame, W32-send-sys-command): New functions. (last_mouse_movement_time): Delete variable. (x_frame_parms): Alphabetize. Add title parm. (x_set_icon_name): Use title if set. (x_set_menu_bar_lines): Ensure client area remains the same. (x_set_name): Don't update if the name is the same. Use title for name if available. (x_icon): Initial support for creating window iconified. (x_display_info_for_name): Set w32_in_use. (Fx_open_connection): Validate Vwindow_system. Set w32_in_use. (w32_create_window): Set window size to frame dimensions. Set font width, line height, border, scrollbar indexes. Don't set X and Y units indexes. (w32_msg_pump): Renamed from windows_msg_worker. Make static. Don't post done message. No longer handle create scrollbar message. Don't abort on anomalous messages. Return when completion detected. (w32_wnd_proc): Keep track of button state. For WINDOWPOSCHANGING, force window dimensions to be multiples of character dimensions. Handle CREATESCROLLBAR. Use correct arguments for SHOWWINDOW. For SETWINDOWPOS, use WINDOWPOS structure. (my_create_window): Abort if message post fails. (Fx_create_frame): Use title instead of name. GC protect frame before make_frame_without_minibuffer. Set icon name. Use courier new as default font (has bold and italic). Set BufferPredicate and Title default parameters. (x_to_w32_weight): Support semibold weight. (x_to_w32_charset): Map # to numeric charset identifier. (w32_to_x_charset): Encode unknown charsets as a number. (enum_font_cb2): Don't restrict to ANSI and OEM charsets. (Fx_color_values): Set high and low words of color values. (syms_of_w32fns): Zero w32_in_use. defsubr new functions. (w32_wnd_proc): Pass on WM_DISPLAYCHANGE messages. (win32_wnd_proc): Capture and handle WM_MOUSEWHEEL events. Capture and handle WM_EMACS_TRACKPOPUPMENU events. Allow a dragged selection from a popup menu started up by a mouse down event. (x_to_win32_color): Support for X Windows RGB string specifications.
author Geoff Voelker <voelker@cs.washington.edu>
date Wed, 03 Sep 1997 00:47:47 +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);
  }
}