protesilaos / modus-themes

Highly accessible themes for GNU Emacs, conforming with the highest standard for colour contrast between background and foreground values (WCAG AAA).
https://protesilaos.com/emacs/modus-themes
GNU General Public License v3.0
544 stars 30 forks source link

Info title faces fixed vs variable pitch #29

Open spepo opened 2 years ago

spepo commented 2 years ago

Hi Prot! With Modus themes, the Info title faces become fixed pitch and regular height by default. That is surprising, because the default pitch and height choices work well to achieve a rather pleasant presentation of Info documents. It is one of the rare places where variable pitch is mixed with fixed pitch out of the box.

I would like to keep it that way. Is there an easy way to achieve that without modifying headline scaling and pitch across the board? I don't want to set modus-themes-variable-pitch-headings=t mainly because I view org files more as source/working documents that may optionally get exported to a presentation format like PDF, HTML (or Info for that matter).

I can see some hacky ways of undoing what modus-themes have done to info-title-x faces. Before I do that, would you consider adding an option or a new value (e.g. modus-themes-variable-pitch-headings=default) to keep the info-title faces variable pitch with scaling? Or, more generally, provide a configurable list of faces to exclude from modification by modus-themes?

Thanks! Peter

protesilaos commented 2 years ago

Hi Prot!

Hello Peter!

With Modus themes, the Info title faces become fixed pitch and regular height by default. That is surprising, because the default pitch and height choices work well to achieve a rather pleasant presentation of Info documents. It is one of the rare places where variable pitch is mixed with fixed pitch out of the box.

I would like to keep it that way. Is there an easy way to achieve that without modifying headline scaling and pitch across the board? I don't want to set modus-themes-variable-pitch-headings=t mainly because I view org files more as source/working documents that may optionally get exported to a presentation format like PDF, HTML (or Info for that matter).

In such cases, the easiest way is to modify the faces directly. The manual has lots of code samples like the following, but here is what can work for you:

(defun my-modus-themes-custom-faces ()
  (modus-themes-with-colors
    (custom-set-faces
     `(info-menu-header ((,class :inherit (bold variable-pitch))))
     `(info-title-1 ((,class :inherit (bold variable-pitch) :height 1.2 :foreground ,fg-main)))
     `(info-title-2 ((,class :inherit (bold variable-pitch) :height 1.2 :foreground ,fg-special-warm)))
     `(info-title-3 ((,class :inherit (bold variable-pitch) :height 1.2 :foreground ,fg-special-cold)))
     `(info-title-4 ((,class :inherit (bold variable-pitch) :height 1.0 :foreground ,fg-special-mild))))))

(add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)

Please give it a try and let me know if this is the desired result. You can also tweak the colours, if you want. Don't hesitate to ask me if something is unclear or you need any further help.

[...]

Or, more generally, provide a configurable list of faces to exclude from modification by modus-themes?

This is an interesting idea, though I expect it would greatly complicate things internally. We provide lots of user options and adding an extra dimension that affects hundreds or thousands of faces would be too costly.


For reference, note that all heading-related options are part of a single modus-themes-headings. The old variables were obsoleted in previous versions of the themes and have since been removed altogether.

spepo commented 2 years ago

Thanks Prot, that helped and I was able to get what I wanted with a little tweaking. For reference, here is what was needed to restore the variable pitch and scaling characteristics of the info title faces:

(defun my-modus-themes-custom-faces ()
    (modus-themes-with-colors
      (custom-set-faces
       `(info-menu-header ((,class :inherit (bold variable-pitch))))
       `(info-title-1 ((,class :inherit info-title-2 :height 1.2 :foreground ,fg-main)))
       `(info-title-2 ((,class :inherit info-title-3 :height 1.2 :foreground ,fg-special-warm)))
       `(info-title-3 ((,class :inherit info-title-4 :height 1.2 :foreground ,fg-special-cold)))
       `(info-title-4 ((,class :inherit (bold variable-pitch) :height 1.0 :foreground ,fg-special-mild))))))

  (add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)
protesilaos commented 2 years ago

Excellent! I will keep this issue open until the next stable release of the themes. Just in case someone needs to review this.

orontee commented 9 months ago

Thanks! I found that an explicit call to the "hooked" function is required.

My init.el:

(require 'modus-themes)
(defun personal-modus-themes-custom-faces ()
  (modus-themes-with-colors
    (custom-set-faces
     ;; variable pitch face in info headings
     `(info-title-1 ((,c :inherit info-title-2 :height 1.2 :foreground ,fg-heading-1)))
     `(info-title-2 ((,c :inherit info-title-3 :height 1.2 :foreground ,fg-heading-2)))
     `(info-title-3 ((,c :inherit info-title-4 :height 1.2 :foreground ,fg-heading-3)))
     `(info-title-4 ((,c :inherit (bold variable-pitch) :height 1.0 :foreground ,fg-heading-4)))
     ;; variable pitch face in markdown headings
     `(markdown-header-face-1 ((,c :inherit markdown-header-face-2 :height 1.2 :foreground ,fg-heading-1)))
     `(markdown-header-face-2 ((,c :inherit markdown-header-face-3 :height 1.2 :foreground ,fg-heading-2)))
     `(markdown-header-face-3 ((,c :inherit markdown-header-face-4 :height 1.2 :foreground ,fg-heading-3)))
     `(markdown-header-face-4 ((,c :inherit (bold variable-pitch) :height 1.0 :foreground ,fg-heading-4)))
     ;; smaller line numbers
     `(line-number  ((,c :inherit default :height 0.8 :foreground ,fg-dim))))))

(setq modus-themes-prompts '(bold)
      modus-themes-variable-pitch-ui nil
      modus-themes-to-toggle '(modus-operandi-tinted modus-vivendi-tinted))

(add-hook 'modus-themes-after-load-theme-hook #'personal-modus-themes-custom-faces)
(load-theme 'modus-operandi-tinted :no-confirm)
(personal-modus-themes-custom-faces)