From eab954bdfc4f27fd68e88b1b4bc80d8a64a6b0d2 Mon Sep 17 00:00:00 2001 From: skyler544 <64664938+skyler544@users.noreply.github.com> Date: Mon, 10 May 2021 10:56:05 +0200 Subject: [PATCH] Add another potential fix for icon misalignment in doom-modeline (#5017) I've added the code I used to finally fix modeline icon misalignment problems in my own setup as a suggestion in the Troubleshooting section. --- modules/ui/modeline/README.org | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/ui/modeline/README.org b/modules/ui/modeline/README.org index 6ae143d07..50886922b 100644 --- a/modules/ui/modeline/README.org +++ b/modules/ui/modeline/README.org @@ -72,12 +72,12 @@ I believe the consensus is: this is due to oversized icons, i.e. a font issue. S 2. Add some padding to the modeline definition: - #+BEGIN_SRC elisp + #+begin_src elisp (after! doom-modeline (doom-modeline-def-modeline 'main '(bar matches buffer-info remote-host buffer-position parrot selection-info) '(misc-info minor-modes checker input-method buffer-encoding major-mode process vcs " "))) ; <-- added padding here - #+END_SRC + #+end_src 3. Use another font for the mode line (or a different ~:height~) (source) @@ -89,6 +89,24 @@ I believe the consensus is: this is due to oversized icons, i.e. a font issue. S (Mentioned in #1680, #278 and seagle0128/doom-modeline#334) +4. Change the width of icon characters in ~char-width-table~: + + #+BEGIN_SRC elisp + (add-hook! 'doom-modeline-mode-hook + (let ((char-table char-width-table)) + (while (setq char-table (char-table-parent char-table))) + (dolist (pair doom-modeline-rhs-icons-alist) + (let ((width 2) ; <-- tweak this + (chars (cdr pair)) + (table (make-char-table nil))) + (dolist (char chars) + (set-char-table-range table char width)) + (optimize-char-table table) + (set-char-table-parent table char-table) + (setq char-width-table table))))) + #+END_SRC + + If this doesn't help, try different values for ~width~ such as ~width 1~ or ~width 3~. * Appendix ** Autodefs