branch: externals/fontaine commit 095524dc79740f0e2b61073c7af99c5da11e7cd6 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Add support for more faces: mode lines, header line, line numbers Thanks to Ashlin Eldridge for suggesting the inclusion of mode line and line number faces. This was done in issue 4: <https://github.com/protesilaos/fontaine/issues/4>. --- README.org | 94 ++++++++++++++++++++++++++++++++++++-------------- fontaine.el | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 179 insertions(+), 27 deletions(-) diff --git a/README.org b/README.org index fdbbc61ee4..2aa87dd3bf 100644 --- a/README.org +++ b/README.org @@ -71,12 +71,17 @@ Fontaine lets the user specify presets of font configurations and set them on demand on graphical Emacs frames. The user option ~fontaine-presets~ holds all such presets. -Presets consist of a list of properties that govern the family, weight, -and height of the faces ~default~, ~fixed-pitch~, ~fixed-pitch-serif~, -~variable-pitch~, ~bold~, and ~italic~. Each preset is identified by a -user-defined symbol as the car of a property list. It looks like this -(check the default value of ~fontaine-presets~ for how everything is -pieced together): +[ The support for the mode line, header line, and line number faces is + part of {{{development-version}}}. ] + +Presets consist of a list of properties that govern the family, +weight, and height of the faces ~default~, ~fixed-pitch~, +~fixed-pitch-serif~, ~variable-pitch~, ~mode-line-active~ (and +~mode-line~ for older Emacs version), ~mode-line-inactive~, +~header-line~, ~line-number~, ~bold~, and ~italic~. Each preset is +identified by a user-defined symbol as the car of a property list. It +looks like this (check the default value of ~fontaine-presets~ for how +everything is pieced together): #+begin_src emacs-lisp (regular @@ -85,15 +90,35 @@ pieced together): :default-family "Monospace" :default-weight regular :default-height 100 + :fixed-pitch-family nil ; falls back to :default-family :fixed-pitch-weight nil ; falls back to :default-weight :fixed-pitch-height 1.0 + :fixed-pitch-serif-family nil ; falls back to :default-family :fixed-pitch-serif-weight nil ; falls back to :default-weight :fixed-pitch-serif-height 1.0 + :variable-pitch-family "Sans" :variable-pitch-weight nil :variable-pitch-height 1.0 + + :mode-line-active-family nil ; falls back to :default-family + :mode-line-active-weight nil ; falls back to :default-weight + :mode-line-active-height 1.0 + + :mode-line-inactive-family nil ; falls back to :default-family + :mode-line-inactive-weight nil ; falls back to :default-weight + :mode-line-inactive-height 1.0 + + :header-line-family nil ; falls back to :default-family + :header-line-weight nil ; falls back to :default-weight + :header-line-height 1.0 + + :line-number-family nil ; falls back to :default-family + :line-number-weight nil ; falls back to :default-weight + :line-number-height 1.0 + :bold-family nil ; use whatever the underlying face has :bold-weight bold :italic-family nil @@ -187,6 +212,8 @@ The user option ~fontaine-presets~ may look like this (though check its default value before you make any edits): #+begin_src emacs-lisp +;; NOTE this example does not include all the properties that +;; `fontaine-presets' accepts. (setq fontaine-presets '((regular :default-family "Hack" @@ -287,6 +314,9 @@ multiple presets, such as the =regular= and =large= we have illustrated thus far. Here is how verbose presets can be expressed succinctly: #+begin_src emacs-lisp +;; NOTE this example does not include all the properties that +;; `fontaine-presets' accepts. + ;; Notice the duplication of properties and how we will avoid it. (setq fontaine-presets '((regular @@ -545,28 +575,20 @@ Remember to read the relevant doc strings. ;; Iosevka Comfy Wide == like Iosevka Comfy, but wider ;; Iosevka Comfy Wide Fixed == like Iosevka Comfy Fixed, but wider (setq fontaine-presets - '((tiny - :default-family "Iosevka Comfy Wide Fixed" - :default-height 70) - (small - :default-family "Iosevka Comfy Fixed" - :default-height 90) - (regular - :default-height 100) + '((small + :default-family "Iosevka Comfy Motion" + :default-height 80 + :variable-pitch-family "Iosevka Comfy Duo") + (regular) ; like this it uses all the fallback values and is named `regular' (medium - :default-height 110) - (large :default-weight semilight - :default-height 140 + :default-height 115 :bold-weight extrabold) + (large + :inherit medium + :default-height 150) (presentation - :default-weight semilight - :default-height 170 - :bold-weight extrabold) - (jumbo - :default-weight semilight - :default-height 220 - :bold-weight extrabold) + :default-height 180) (t ;; I keep all properties for didactic purposes, but most can be ;; omitted. See the fontaine manual for the technicalities: @@ -574,15 +596,35 @@ Remember to read the relevant doc strings. :default-family "Iosevka Comfy" :default-weight regular :default-height 100 + :fixed-pitch-family nil ; falls back to :default-family :fixed-pitch-weight nil ; falls back to :default-weight :fixed-pitch-height 1.0 + :fixed-pitch-serif-family nil ; falls back to :default-family :fixed-pitch-serif-weight nil ; falls back to :default-weight :fixed-pitch-serif-height 1.0 - :variable-pitch-family "Iosevka Comfy Duo" + + :variable-pitch-family "Iosevka Comfy Motion Duo" :variable-pitch-weight nil :variable-pitch-height 1.0 + + :mode-line-active-family nil ; falls back to :default-family + :mode-line-active-weight nil ; falls back to :default-weight + :mode-line-active-height 0.9 + + :mode-line-inactive-family nil ; falls back to :default-family + :mode-line-inactive-weight nil ; falls back to :default-weight + :mode-line-inactive-height 0.9 + + :header-line-family nil ; falls back to :default-family + :header-line-weight nil ; falls back to :default-weight + :header-line-height 0.9 + + :line-number-family nil ; falls back to :default-family + :line-number-weight nil ; falls back to :default-weight + :line-number-height 0.9 + :bold-family nil ; use whatever the underlying face has :bold-weight bold :italic-family nil @@ -674,7 +716,7 @@ Fontaine is meant to be a collective effort. Every bit of help matters. + Contributions to the code or manual :: Christopher League, Eli Zaretskii, Florent Teissier, Terry F. Torrey. -+ Ideas and user feedback :: Joe Higton, Ted Reed. ++ Ideas and user feedback :: Ashlin Eldridge, Joe Higton, Ted Reed. * GNU Free Documentation License :PROPERTIES: diff --git a/fontaine.el b/fontaine.el index 06b28ff5ff..f20a4b9efd 100644 --- a/fontaine.el +++ b/fontaine.el @@ -150,15 +150,35 @@ :default-family "Monospace" :default-weight regular :default-height 100 + :fixed-pitch-family nil ; falls back to :default-family :fixed-pitch-weight nil ; falls back to :default-weight :fixed-pitch-height 1.0 + :fixed-pitch-serif-family nil ; falls back to :default-family :fixed-pitch-serif-weight nil ; falls back to :default-weight :fixed-pitch-serif-height 1.0 + :variable-pitch-family "Sans" :variable-pitch-weight nil :variable-pitch-height 1.0 + + :mode-line-active-family nil ; falls back to :default-family + :mode-line-active-weight nil ; falls back to :default-weight + :mode-line-active-height 1.0 + + :mode-line-inactive-family nil ; falls back to :default-family + :mode-line-inactive-weight nil ; falls back to :default-weight + :mode-line-inactive-height 1.0 + + :header-line-family nil ; falls back to :default-family + :header-line-weight nil ; falls back to :default-weight + :header-line-height 1.0 + + :line-number-family nil ; falls back to :default-family + :line-number-weight nil ; falls back to :default-weight + :line-number-height 1.0 + :bold-family nil ; use whatever the underlying face has :bold-weight bold :italic-family nil @@ -209,6 +229,26 @@ The properties in detail: They all fall back to the respective default values, as described above. +- The `:mode-line-active-family', `:mode-line-active-weight', and + `:mode-line-active-height' apply to the `mode-line' and + `mode-line-active' faces. They all fall back to the respective + default values, as described above. + +- The `:mode-line-inactive-family', `:mode-line-inactive-weight', + and `:mode-line-inactive-height' apply to the + `mode-line-inactive' face. They all fall back to the + respective default values, as described above. + +- The `:header-line-family', `:header-line-weight', and + `:header-line-height' apply to the `header-line' face. They + all fall back to the respective default values, as described + above. + +- The `:line-number-family', `:line-number-weight', and + `:line-number-height' apply to the `line-number' face. They + all fall back to the respective default values, as described + above. + - The `:bold-family' and `:italic-family' are the font families of the `bold' and `italic' faces, respectively. Only set them if you want to override that of the underlying face. @@ -281,6 +321,22 @@ Caveats or further notes: ((const :tag "Variable pitch regular weight" :variable-pitch-weight) ,fontaine--weights-widget) ((const :tag "Variable pitch height" :variable-pitch-height) float) + ((const :tag "Active mode line font family" :mode-line-active-family) string) + ((const :tag "Active mode line regular weight" :mode-line-active-weight) ,fontaine--weights-widget) + ((const :tag "Active mode line height" :mode-line-active-height) float) + + ((const :tag "Inactive mode line font family" :mode-line-inactive-family) string) + ((const :tag "Inactive mode line regular weight" :mode-line-inactive-weight) ,fontaine--weights-widget) + ((const :tag "Inactive mode line height" :mode-line-inactive-height) float) + + ((const :tag "Header line font family" :header-line-family) string) + ((const :tag "Header line regular weight" :header-line-weight) ,fontaine--weights-widget) + ((const :tag "Header line height" :header-line-height) float) + + ((const :tag "Line number font family" :line-number-family) string) + ((const :tag "Line number regular weight" :line-number-weight) ,fontaine--weights-widget) + ((const :tag "Line number height" :line-number-height) float) + ((const :tag "Font family of the `bold' face" :bold-family) string) ((const :tag "Weight for the `bold' face" :bold-weight) ,fontaine--weights-widget) @@ -300,7 +356,7 @@ Caveats or further notes: ;; because it does not re-read `fontaine-presets'. ((const :tag "Inherit another preset" :inherit) symbol))) :key-type symbol) - :package-version '(fontaine . "0.5.0") + :package-version '(fontaine . "1.1.0") :group 'fontaine :link '(info-link "(fontaine) Shared and implicit fallback values for presets")) @@ -480,6 +536,56 @@ ARGS are its routines." (or (plist-get properties :variable-pitch-height) 1.0) frame)) +(fontaine--apply-preset + fontaine--apply-mode-line-preset + "Set `mode-line' face attributes based on PRESET for optional FRAME." + (fontaine--set-face-attributes + 'mode-line + (or (plist-get properties :mode-line-family) (plist-get properties :default-family)) + (or (plist-get properties :mode-line-weight) (plist-get properties :default-weight)) + (or (plist-get properties :mode-line-height) 1.0) + frame)) + +(fontaine--apply-preset + fontaine--apply-mode-line-active-preset + "Set `mode-line-active' face attributes based on PRESET for optional FRAME." + (fontaine--set-face-attributes + 'mode-line-active + (or (plist-get properties :mode-line-active-family) (plist-get properties :default-family)) + (or (plist-get properties :mode-line-active-weight) (plist-get properties :default-weight)) + (or (plist-get properties :mode-line-active-height) 1.0) + frame)) + +(fontaine--apply-preset + fontaine--apply-mode-line-inactive-preset + "Set `mode-line-inactive' face attributes based on PRESET for optional FRAME." + (fontaine--set-face-attributes + 'mode-line-inactive + (or (plist-get properties :mode-line-inactive-family) (plist-get properties :default-family)) + (or (plist-get properties :mode-line-inactive-weight) (plist-get properties :default-weight)) + (or (plist-get properties :mode-line-inactive-height) 1.0) + frame)) + +(fontaine--apply-preset + fontaine--apply-header-line-preset + "Set `header-line' face attributes based on PRESET for optional FRAME." + (fontaine--set-face-attributes + 'header-line + (or (plist-get properties :header-line-family) (plist-get properties :default-family)) + (or (plist-get properties :header-line-weight) (plist-get properties :default-weight)) + (or (plist-get properties :header-line-height) 1.0) + frame)) + +(fontaine--apply-preset + fontaine--apply-line-number-preset + "Set `line-number' face attributes based on PRESET for optional FRAME." + (fontaine--set-face-attributes + 'line-number + (or (plist-get properties :line-number-family) (plist-get properties :default-family)) + (or (plist-get properties :line-number-weight) (plist-get properties :default-weight)) + (or (plist-get properties :line-number-height) 1.0) + frame)) + (fontaine--apply-preset fontaine--apply-bold-preset "Set `bold' face attributes based on PRESET for optional FRAME." @@ -559,6 +665,10 @@ Call `fontaine-set-preset-hook' as a final step." (fontaine--apply-fixed-pitch-preset preset frame) (fontaine--apply-fixed-pitch-serif-preset preset frame) (fontaine--apply-variable-pitch-preset preset frame) + (fontaine--apply-mode-line-active-preset preset frame) + (fontaine--apply-mode-line-inactive-preset preset frame) + (fontaine--apply-header-line-preset preset frame) + (fontaine--apply-line-number-preset preset frame) (fontaine--apply-bold-preset preset frame) (fontaine--apply-italic-preset preset frame) (setq fontaine-current-preset preset)