diff --git a/README.md b/README.md index bb7f0d9..7fcd137 100644 --- a/README.md +++ b/README.md @@ -134,10 +134,11 @@ Strongly recommend to use ## Customize ``` emacs-lisp -;; How tall the mode-line should be (only respected in GUI Emacs). +;; How tall the mode-line should be. It's only respected in GUI. +;; If the actual char height is larger, it respects the actual height. (setq doom-modeline-height 25) -;; How wide the mode-line bar should be (only respected in GUI Emacs). +;; How wide the mode-line bar should be. It's only respected in GUI. (setq doom-modeline-bar-width 3) ;; Determines the style used by `doom-modeline-buffer-file-name'. diff --git a/doom-modeline-core.el b/doom-modeline-core.el index 7acc8a1..7e0ed3e 100644 --- a/doom-modeline-core.el +++ b/doom-modeline-core.el @@ -131,14 +131,12 @@ It returns a file name which can be used directly as argument of ;; Variables ;; -(defvar doom-modeline-height (let ((font (face-font 'mode-line))) - (if (and font (fboundp 'font-info)) - (* 2 (aref (font-info font) 2)) - 25)) - "How tall the mode-line should be (only respected in GUI Emacs).") +(defvar doom-modeline-height 25 + "How tall the mode-line should be. It's only respected in GUI. +If the actual char height is larger, it respects the actual char height.") (defvar doom-modeline-bar-width (if (eq system-type 'darwin) 3 6) - "How wide the mode-line bar should be (only respected in GUI Emacs).") + "How wide the mode-line bar should be. It's only respected in GUI.") (defvar doom-modeline-buffer-file-name-style 'truncate-upto-project "Determines the style used by `doom-modeline-buffer-file-name'. @@ -488,6 +486,14 @@ It returns a file name which can be used directly as argument of "Whether is an active window." (eq (selected-window) doom-modeline-current-window)) +(defun doom-modeline--char-height () + "Calculate the actual char height of the mode-line." + (or + (let ((font (face-font 'mode-line))) + (when (and font (fboundp 'font-info)) + (* 2 (aref (font-info font) 2)))) + (round (* 1.3 (frame-char-height))))) + (defsubst doom-modeline-vspc () "Text style with icons in mode-line." (propertize " " 'face (if (doom-modeline--active) diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 2abba64..bfb2496 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -1226,12 +1226,12 @@ Returns \"\" to not break --no-window-system." (doom-modeline--make-xpm 'doom-modeline-bar (or width doom-modeline-bar-width) (max (or height doom-modeline-height) - (ceiling (* 1.3 (frame-char-height))))) + (doom-modeline--char-height))) doom-modeline--bar-inactive (doom-modeline--make-xpm 'doom-modeline-inactive-bar (or width doom-modeline-bar-width) (max (or height doom-modeline-height) - (ceiling (* 1.3 (frame-char-height))))))) + (doom-modeline--char-height))))) (when (>= emacs-major-version 26) (add-variable-watcher