Function: default-font-width

default-font-width is a byte-compiled function defined in simple.el.gz.

Signature

(default-font-width)

Documentation

Return the width in pixels of the current buffer's default face font.

If the default font is remapped (see face-remapping-alist), the function returns the width of the remapped face. This function uses the definition of the default face for the currently selected frame.

Probably introduced at or before Emacs version 25.1.

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun default-font-width ()
  "Return the width in pixels of the current buffer's default face font.

If the default font is remapped (see `face-remapping-alist'), the
function returns the width of the remapped face.
This function uses the definition of the default face for the currently
selected frame."
  (let ((default-font (face-font 'default)))
    (cond
     ((and (display-multi-font-p)
	   ;; Avoid calling font-info if the frame's default font was
	   ;; not changed since the frame was created.  That's because
	   ;; font-info is expensive for some fonts, see bug #14838.
	   (not (string= (frame-parameter nil 'font) default-font)))
      (let* ((info (font-info (face-font 'default)))
	     (width (aref info 11)))
	(if (> width 0)
	    width
	  (aref info 10))))
     (t (frame-char-width)))))