Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Info title faces fixed vs variable pitch #29

Open
spepo opened this issue Apr 15, 2022 · 4 comments
Open

Info title faces fixed vs variable pitch #29

spepo opened this issue Apr 15, 2022 · 4 comments
Labels
documentation Improvements or additions to documentation user-level-configuration

Comments

@spepo
Copy link

spepo commented Apr 15, 2022

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
Copy link
Owner

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
Copy link
Author

spepo commented Apr 15, 2022

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
Copy link
Owner

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

@protesilaos protesilaos added documentation Improvements or additions to documentation user-level-configuration labels Apr 15, 2022
@orontee
Copy link

orontee commented Nov 28, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation user-level-configuration
Projects
None yet
Development

No branches or pull requests

3 participants