Function: font-at

font-at is a function defined in font.c.

Signature

(font-at POSITION &optional WINDOW STRING)

Documentation

Return a font-object for displaying a character at POSITION.

Optional second arg WINDOW, if non-nil, is a window displaying the current buffer. It defaults to the currently selected window. Optional third arg STRING, if non-nil, is a string containing the target character at index specified by POSITION.

View in manual

Source Code

// Defined in /usr/src/emacs/src/font.c
{
  struct window *w = decode_live_window (window);
  EMACS_INT pos;

  if (NILP (string))
    {
      if (XBUFFER (w->contents) != current_buffer)
	error ("Specified window is not displaying the current buffer");
      pos = fix_position (position);
      if (! (BEGV <= pos && pos < ZV))
	args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
    }
  else
    {
      CHECK_FIXNUM (position);
      CHECK_STRING (string);
      pos = XFIXNUM (position);
      if (! (0 <= pos && pos < SCHARS (string)))
	args_out_of_range (string, position);
    }

  return font_at (-1, pos, NULL, w, string);
}