summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfpi2022-05-22 21:13:20 +0200
committerfpi2023-02-19 18:37:22 +0100
commit37544a34067923deb52e2945d10f12d6cabc9c63 (patch)
treec63b41ce3f0c82479e22bbe83e9745430aea93b6
parentRemove zetteldeft (diff)
Update font & theme settings/prose
-rw-r--r--emacs-init.org249
1 files changed, 8 insertions, 241 deletions
diff --git a/emacs-init.org b/emacs-init.org
index ad94e2b..28f9626 100644
--- a/emacs-init.org
+++ b/emacs-init.org
@@ -428,243 +428,15 @@ Also enable =exwm=. This does nothing if =emacs= is not started as window manage
(exwm-enable))
#+end_src
** Font
-I am still not quite sure on my choice of font.
-
-=fpi/set-font= is a safe way to choose a font based on
-availability. When starting with =emacs --daemon= it does not work as
-=(font-family-list)= won't return anything.
-#+begin_src emacs-lisp :tangle no
-(use-package emacs
- :config
- (defun fpi/set-font ()
- (interactive)
- (cond
- ((member "Hack" (font-family-list)e)
- (add-to-list 'default-frame-alist '(font . "Hack-12")))
- ((member "Source Code Pro" (font-family-list))
- (add-to-list 'default-frame-alist '(font . "Source Code Pro-12")))))
- (add-to-list 'default-frame-alist '(font . "Hack-12"))
- ;; :hook (after-init . fpi/set-font)
- )
-#+end_src
-
-Instead of the above code I set the font directly using
-=set-face-attribute=. This is overwritten by my theme settings.
+Font availability can be checked using ~(font-family-list)~. Here I set the font directly using =set-face-attribute= without checking. This just a default and overwritten by my theme settings.
#+begin_src emacs-lisp
(set-face-attribute 'default nil :font "Hack-11")
#+end_src
-#+begin_src emacs-lisp
-(use-package emacs
- :commands (prot/font-set-face-attribute
- prot/font-set-fonts
- prot/font-set-font-size-family
- prot/font-fonts-dwim)
- :config
- (setq x-underline-at-descent-line t)
- (setq underline-minimum-offset 1)
-
- (defconst prot/font-fontconfig-params
- "embeddedbitmap=false:autohint=false:hintstyle=hintslight"
- "Additional parameters for the given font family.
-These are specific to the fontconfig backend for GNU/Linux systems.")
-
- (defvar prot/font-set-fonts-hook nil
- "Hook that is called after setting fonts.
-See, for example, `prot/font-set-fonts'.")
-
- ;; The idea with this association list is to use font combinations
- ;; that are suitable to the given point size and intended function.
- ;; Basically, I have three modes: my laptop's small screen, my laptop
- ;; attached to a larger external monitor in a desktop setup (my normal
- ;; case), and when I do presentations (i.e. my videos on Emacs).
- ;;
- ;; I find that at smaller sizes the open and wide proportions of
- ;; Hack+FiraGO combined with their more intense typographic colour
- ;; work best, while the more compact Iosevka+Source Sans Pro are
- ;; better at larger point sizes. The "desktop" combo is ideal for use
- ;; on a larger monitor at a regular point size. The latter is what I
- ;; typically use to write prose or code.
- ;;
- ;; Note that the "Hack" typeface mentioned here is my patched version
- ;; of it, which uses some alternative glyphs, is built on top of the
- ;; latest dev branch, and is meant to improve both the Roman and
- ;; Italic variants (alt glyphs are part of the Hack project):
- ;; https://gitlab.com/protesilaos/hackfontmod
- (defconst prot/font-sizes-families-alist
- '(("laptop" . (10.5 "Hack" "Source Sans Pro" 1))
- ("desktop" . (13 "Hack" "Alegreya" 4))
- ("presentation" . (19 "Iosevka SS08" "Source Sans Pro" 1)))
- "Alist of desired point sizes and their typefaces.
-Each association consists of a display type mapped to a point
-size, followed by monospaced and proportionately-spaced font
-names, and a difference in desired size between the latter two to
-account for their innate differences in proportions (this number
-represents pixels and is found empirically).
-
-The monospaced typeface is meant to be applied to the `default'
-and `fixed-pitch' faces. The proportionately-space font is
-intended for the `variable-pitch' face.")
-
- (defun prot/font-set-face-attribute (face family size &optional params)
- "Set FACE font to FAMILY at SIZE with optional PARAMS."
- (let ((params (if params
- params
- prot/font-fontconfig-params)))
- (set-face-attribute
- `,face nil :font
- (format "%s-%s:%s" family (number-to-string size) params))))
-
-
-
-
-
- (defun prot/font-set-fonts (&optional points font-mono font-var)
- "Set default font size using presets.
-
-POINTS is the font's point size, represented as either '10' or
-'10.5'. FONT-MONO should be a monospaced typeface, due to the
-alignment requirements of the `fixed-pitch' face. FONT-VAR could
-be a proportionately-spaced typeface or even a monospaced one,
-since the `variable-pitch' it applies to is not supposed to be
-spacing-sensitive. Both families must be represented as a string
-holding the family's name."
- (interactive)
- (let* ((data prot/font-sizes-families-alist)
- (displays (mapcar #'car data))
- (choice (if points
- points
- (completing-read "Pick display size: " displays nil t)))
- (size (if points
- points
- (nth 1 (assoc `,choice data))))
- (mono (if font-mono
- font-mono
- (if (member choice displays)
- (nth 2 (assoc `,choice data))
- nil)))
- (var (if font-var
- font-var
- (if (member choice displays)
- (nth 3 (assoc `,choice data))
- nil)))
- (adjust (nth 4 (assoc `,choice data))))
- (when window-system
- (dolist (face '(default fixed-pitch))
- (prot/font-set-face-attribute `,face mono size))
- (prot/font-set-face-attribute 'variable-pitch var (+ size adjust))))
- (run-hooks 'prot/font-switch-fonts-hook))
-
- (defvar prot/font-monospaced-fonts-list
- '("Hack" "Iosevka SS08" "Iosevka Slab" "Source Code Pro"
- "Ubuntu Mono" "Fantasque Sans Mono" "DejaVu Sans Mono"
- "Fira Code" "Victor Mono" "Roboto Mono")
- "List of typefaces for coding.
-See `prot/font-set-font-size-family' for how this is used.")
-
- (defun prot/font-set-font-size-family ()
- "Set point size and main typeface.
-This command is intended for testing various font families at
-some common point sizes.
-
-See `prot/font-set-fonts' for the function I would normally use
-or `prot/font-fonts-dwim' which just wraps this one with that."
- (interactive)
- (let* ((fonts prot/font-monospaced-fonts-list)
- (font (completing-read "Select main font: " fonts nil t))
- (nums (list 13 14 15 16))
- (sizes (mapcar 'number-to-string nums))
- (size (completing-read "Select or insert number: " sizes nil))
- (var (face-attribute 'variable-pitch :family)))
- (dolist (face '(default fixed-pitch))
- (prot/font-set-face-attribute face font (string-to-number size)))
- (prot/font-set-face-attribute 'variable-pitch var (string-to-number size))
- (run-hooks 'prot/font-switch-fonts-hook)))
-
- (defun prot/font-fonts-dwim (&optional arg)
- "Set fonts interactively.
-This is just a wrapper around `prot/font-set-fonts' and
-`prot/font-set-font-size-family', whose sole purpose is to
-economise on dedicated key bindings."
- (interactive "P")
- (if arg
- (prot/font-set-font-size-family)
- (prot/font-set-fonts)))
-
- (defvar prot/font-fonts-line-spacing-alist
- '(("Iosevka SS08" . 1)
- ("Iosevka Slab" . 1)
- ("Source Code Pro" . 1)
- ("Ubuntu Mono" . 2))
- "Font families in need of extra `line-spacing'.
-See `prot/font-line-spacing' for how this is used.")
-
- (defvar prot/font-fonts-bold-weight-alist
- '(("Source Code Pro" . semibold))
- "Font families in need of a variegated weight for `bold'.
-See `prot/font-bold-face' for how this is used.")
-
- (defmacro prot/font-adjustment (fn doc alist cond1 cond2)
- "Macro for functions that employ `prot/font-switch-fonts-hook'.
-NAME is the name of the resulting function. DOC is its
-docstring. ALIST is an assosiation list of cons cells. COND1
-and COND2 is the body of an `if' statement's 'if' and 'then' part
-respectively."
- `(defun ,fn ()
- ,doc
- (let* ((data ,alist)
- (fonts (mapcar #'car data))
- ;; REVIEW This should be adjusted to account for the
- ;; possibility of a distinct font family for the `bold'
- ;; face.
- (font (face-attribute 'default :family))
- (x (cdr (assoc font data))))
- (if (member font fonts)
- ,cond1
- ,cond2))))
-
- (prot/font-adjustment
- prot/font-line-spacing
- "Determine desirable `line-spacing', based on font family."
- prot/font-fonts-line-spacing-alist
- (setq-default line-spacing `,x)
- (setq-default line-spacing nil))
-
- ;; XXX This will not work with every theme, but only those that
- ;; inherit the `bold' face instead of specifying a weight property.
- ;; The intent is to configure this once and have it propagate wherever
- ;; a heavier weight is displayed. My Modus themes handle this
- ;; properly.
- (prot/font-adjustment
- prot/font-bold-face
- "Determine weight for the `bold' face, based on font family."
- prot/font-fonts-bold-weight-alist
- (set-face-attribute 'bold nil :weight `,x)
- (set-face-attribute 'bold nil :weight 'bold))
-
- (defun prot/font-fonts-per-monitor ()
- "Use font settings based on screen size.
-Meant to be used at some early initialisation stage, such as with
-`after-init-hook'."
- (let* ((display (if (<= (display-pixel-width) 1366)
- "laptop"
- "desktop"))
- (data prot/font-sizes-families-alist)
- (size (cadr (assoc `,display data)))
- (mono (nth 2 (assoc `,display data)))
- (var (nth 3 (assoc `,display data)))
- (adjust (nth 4 (assoc `,display data))))
- (dolist (face '(default fixed-pitch))
- (prot/font-set-face-attribute face mono size))
- (prot/font-set-face-attribute 'variable-pitch var (+ size adjust))
- (run-hooks 'prot/font-switch-fonts-hook)))
-
- :hook ((after-init-hook . prot/font-fonts-per-monitor)
- (prot/font-set-fonts-hook . prot/font-line-spacing)
- (prot/font-set-fonts-hook . prot/font-bold-face))
- ;; Awkward key because I do not need it very often. Maybe once a day.
- ;; The "C-c f" is used elsewhere.
- :bind ("C-c F" . prot/font-fonts-dwim))
+Increase the _underline_ spacing.
+ #+begin_src emacs-lisp :tangle no :noweb-ref emacs-custom
+(x-underline-at-descent-line t)
+(underline-minimum-offset 1)
#+end_src
*** Emoji
For undefined characters in the default font, we can set a fallback font using [[info:emacs#Fontsets][fontsets]].
@@ -678,14 +450,9 @@ Alternatively we could use =OpenMoji= or other icon sets.
(set-fontset-font "fontset-default" 'unicode "OpenMoji")
#+end_src
** Theme & Faces
-=hc-zenburn= is the theme I chose for a long time. Lately I started to
-appreciate light themes more. [[https://gitlab.com/protesilaos/modus-themes][modus-operandi]] is an interesting light
-theme promising high color contrast. I ended up using the
-=spacemacs-light= and =spacemacs-dark= themes.
-
-This is written here for clarity, but only executed at the end of my
-init files, after some variables which depend on the current theme are
-defined, for example ~pdf-view-midnight-colors~.
+=hc-zenburn= is the theme I chose for a long time. Lately I started to appreciate light themes more. [[https://gitlab.com/protesilaos/modus-themes][modus-operandi]] is an interesting light theme promising high color contrast. I ended up using the =spacemacs-light= and =spacemacs-dark= themes.
+
+This is written here for clarity, but only executed at the end of my init files, after some variables which depend on the current theme are defined, for example ~pdf-view-midnight-colors~.
#+NAME: themes
#+begin_src emacs-lisp :tangle no
<<theme-functions>>