Function: doom-modeline--font-height

doom-modeline--font-height is a natively compiled function defined in doom-modeline-core.el.

Signature

(doom-modeline--font-height)

Documentation

Calculate the actual char height of the mode-line for the current frame.

The result is cached per-frame to avoid expensive calculations during redisplay.

Source Code

;; Defined in /nix/store/1lcicrdd2r4b8rkc91nnn74ymk1jl6yd-emacs-packages-deps/share/emacs/site-lisp/elpa/doom-modeline-20260928.1632/doom-modeline-core.el
(defun doom-modeline--font-height ()
  "Calculate the actual char height of the mode-line for the current frame.
The result is cached per-frame to avoid expensive calculations during redisplay."
  (let* ((frame (selected-frame))
         (current-face-height-attr (face-attribute 'mode-line :height frame)) ; Get attribute for the specific frame
         (cache-entry (gethash frame doom-modeline--font-height-cache)))
    (if (and cache-entry
             (equal (cdr cache-entry) current-face-height-attr))
        ;; Return cached value if frame exists in cache and face attribute matches
        (car cache-entry)
      ;; Else, recalculate and update cache for this frame
      (let* ((base-char-height (window-font-height nil 'mode-line)) ; Use window-font-height in the context of the frame/window
             (new-height (round
                          (* 1.0 (cond
                                  ((integerp current-face-height-attr)
                                   (/ current-face-height-attr 10.0)) ; Ensure float division
                                  ((floatp current-face-height-attr)
                                   (* current-face-height-attr base-char-height))
                                  (t base-char-height))))))
        ;; Update cache for the current frame
        (puthash frame (cons new-height current-face-height-attr) doom-modeline--font-height-cache)
        new-height))))