emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is a default font?


From: martin rudalics
Subject: Re: What is a default font?
Date: Fri, 6 Dec 2019 09:35:46 +0100

I intend to rewrite 'window-default-font-height' as

(defun window-default-font-height (&optional window buffer)
  "Return height in pixels of BUFFER's default face font in WINDOW.
WINDOW must be a valid window and defaults to the selected one.
If BUFFER is a live buffer, it stands for itself.  Any other
value means to use WINDOW's buffer.  If neither WINDOW nor BUFFER
are live, signal an error.

The return value accounts for any remapping of the default face
font (see `face-remapping-alist') in BUFFER.  If no such
remapping has been specified for BUFFER, return the height of the
default face font for WINDOW's frame.

Note that if WINDOW specifes a live window and BUFFER specifies a
buffer different from the one currently shown in WINDOW, the
return value is calculated by pretending that BUFFER is displayed
in WINDOW."
  (let* ((window (window-normalize-window window))
         (frame (window-frame window))
         (buffer
          (cond
           ((buffer-live-p buffer) buffer)
           ((window-live-p window) (window-buffer window))
           (t (error "No live window and buffer specified"))))
         (default-font
           (if (window-live-p window)
               (with-selected-window window
                 (with-current-buffer buffer
                   (face-font 'default frame)))
             (with-selected-frame frame
               (with-current-buffer buffer
                 (face-font 'default frame))))))
    (cond
     ((not default-font)
      (frame-char-height frame))
     ((and (display-multi-font-p (frame-parameter frame 'display))
           (not (string-equal (frame-parameter frame 'font) default-font)))
      (aref (font-info default-font frame) 3))
     (t
      (frame-char-height frame)))))

If you think that my interpretation is correct, the doc-string of
'face-font' could maybe tell something similar.

And I'd still like to know what 'face-new-frame-defaults' is really
used for.

martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]