Merge the two sections on text faces
This commit is contained in:
parent
e77d10bf38
commit
a5ecc703b1
162
README.org
162
README.org
@ -337,27 +337,77 @@ the contents of packages and allows to update packages to the latest version.
|
|||||||
ok))
|
ok))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* [[info:emacs#Faces][Text faces or look (info)]]
|
* [[info:emacs#Faces][Text faces or styles (info)]]
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: sec:text-faces-or-look
|
:CUSTOM_ID: sec:text-faces-or-styles
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
Section [[#sec:text-faces-or-styles][text faces or styles]] tells that this setup does not use theming.
|
This setup does not configure [[info:emacs#Custom Themes][custom themes (info)]] in order to prevent endless
|
||||||
However, in order to improve visibility, it relies on:
|
useless tweaking. See the [[https://protesilaos.com/codelog/2020-09-05-emacs-note-mixed-font-heights/][note on mixed font heights in Emacs]] for how to setup
|
||||||
1. Tweaking the background color of the already loaded =region= face as in
|
fonts properly. It boils down to two rules:
|
||||||
listing [[lst:tweak-region-face-background-color]].
|
1. The height of the default face must be an integer number to make the height a
|
||||||
|
physical quantity.
|
||||||
|
2. The heights of all other faces must be real numbers to scale those heights
|
||||||
|
with respect to the height of the face (those heights default to 1.0 for no
|
||||||
|
scaling).
|
||||||
|
The code in listing [[lst:configure-face-attributes]] source implements those rules.
|
||||||
|
Listing [[lst:set-default-face-height]] shows that font scaling is easy in case of
|
||||||
|
proper initialization of all face heigths. Listing
|
||||||
|
[[lst:fix-gtk-color-for-invert-default-face]] and listing [[lst:shadow-font-lock-faces]]
|
||||||
|
show a few tweaks to improve visibility without theming:
|
||||||
|
1. Fixing the =gtk= background color of the already loaded =region= face.
|
||||||
2. Toggling between a dark and light background by means of
|
2. Toggling between a dark and light background by means of
|
||||||
src_emacs-lisp{(invert-default-face)} in listing [[lst:invert-default-face]].
|
src_emacs-lisp{(invert-default-face)}.
|
||||||
3. Shadowing the definition of faces before loading as in listing
|
3. Shadowing the definition of faces before loading. The last item in the page
|
||||||
[[lst:tweak-org-block-face]] and [[lst:tweak-sh-heredoc-face]]. The last item in the
|
on [[https://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html#org5c4406f][fontifying Org mode source code blocks]] describes this method.
|
||||||
page on [[https://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html#org5c4406f][fontifying Org mode source code blocks]] describes this method.
|
|
||||||
|
|
||||||
#+caption[Tweak the background color of the =region= face in =faces.el=]:
|
#+caption[Configure =face-attributes=]:
|
||||||
#+caption: Tweak the background color of the =region= face in =faces.el=.
|
#+caption: Configure =face-attributes=.
|
||||||
#+name: lst:tweak-region-face-background-color
|
#+name: lst:configure-face-attributes
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(with-eval-after-load 'emacs
|
(with-eval-after-load 'emacs
|
||||||
(defun tweak-region-face-background-color ()
|
;; Set face attributes.
|
||||||
|
(cond
|
||||||
|
((eq system-type 'darwin)
|
||||||
|
(set-face-attribute 'default nil :family "Hack" :height 120)
|
||||||
|
(set-face-attribute 'fixed-pitch nil :family "Hack")
|
||||||
|
(set-face-attribute 'variable-pitch nil :family "FiraGo"))
|
||||||
|
((eq system-type 'gnu/linux)
|
||||||
|
(set-face-attribute 'default nil :family "Hack" :height 110)
|
||||||
|
(set-face-attribute 'fixed-pitch nil :family "Hack")
|
||||||
|
(set-face-attribute 'variable-pitch nil :family "FiraGo"))
|
||||||
|
(t
|
||||||
|
(set-face-attribute 'default nil :family "Hack" :height 110)
|
||||||
|
(set-face-attribute 'fixed-pitch nil :family "Hack")
|
||||||
|
(set-face-attribute 'variable-pitch nil :family "DejaVu Sans"))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+caption[Implement =set-default-face-height=]:
|
||||||
|
#+caption: Implement =set-default-face-height=.
|
||||||
|
#+name: lst:set-default-face-height
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(with-eval-after-load 'emacs
|
||||||
|
(defun set-default-face-height ()
|
||||||
|
"Set the default face height in all current and future frames.
|
||||||
|
|
||||||
|
Scale all other faces with a height that is a real number."
|
||||||
|
(interactive)
|
||||||
|
(let* ((prompt (format "face heigth (%s): "
|
||||||
|
(face-attribute 'default :height)))
|
||||||
|
(choices (mapcar #'number-to-string
|
||||||
|
(number-sequence 50 200 10)))
|
||||||
|
(height (string-to-number
|
||||||
|
(completing-read prompt choices nil 'require-match))))
|
||||||
|
(message "Setting the height of the default face to %s" height)
|
||||||
|
(set-face-attribute 'default nil :height height))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+caption[Fix a `gtk' color and implement =invert-default-face=]:
|
||||||
|
#+caption: Fix a `gtk' color and implement =invert-default-face=.
|
||||||
|
#+name: lst:fix-gtk-color-for-invert-default-face
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(with-eval-after-load 'emacs
|
||||||
|
(defun fix-gtk-region-face-background-color ()
|
||||||
(when (featurep 'gtk)
|
(when (featurep 'gtk)
|
||||||
(set-face-attribute
|
(set-face-attribute
|
||||||
'region nil
|
'region nil
|
||||||
@ -365,24 +415,18 @@ However, in order to improve visibility, it relies on:
|
|||||||
'(("white" . "LightGoldenrod2")
|
'(("white" . "LightGoldenrod2")
|
||||||
("black" . "blue3")))))))
|
("black" . "blue3")))))))
|
||||||
|
|
||||||
(tweak-region-face-background-color))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+caption[Implement =invert-default-face=]:
|
|
||||||
#+caption: Implement =invert-default-face=.
|
|
||||||
#+name: lst:invert-default-face
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(with-eval-after-load 'emacs
|
|
||||||
(defun invert-default-face ()
|
(defun invert-default-face ()
|
||||||
"Invert the default face."
|
"Invert the default face."
|
||||||
(interactive)
|
(interactive)
|
||||||
(invert-face 'default)
|
(invert-face 'default)
|
||||||
(tweak-region-face-background-color)))
|
(fix-gtk-region-face-background-color))
|
||||||
|
|
||||||
|
(fix-gtk-region-face-background-color))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+caption[Improve the visibility of the =org-block= face in =org-faces.el=]:
|
#+caption[Shadow font-lock faces to improve the readability]:
|
||||||
#+caption: Improve the visibility of the =org-block= face in =org-faces.el=.
|
#+caption: Shadow font-lock faces to improve the readability.
|
||||||
#+name: lst:tweak-org-block-face
|
#+name: lst:shadow-font-lock-faces
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(with-eval-after-load 'emacs
|
(with-eval-after-load 'emacs
|
||||||
;; Shadow the definition in org-faces.el:
|
;; Shadow the definition in org-faces.el:
|
||||||
@ -405,14 +449,8 @@ However, in order to improve visibility, it relies on:
|
|||||||
|
|
||||||
When `org-fontify-quote-and-verse-blocks' is not nil, text inside
|
When `org-fontify-quote-and-verse-blocks' is not nil, text inside
|
||||||
verse and quote blocks are fontified using the `org-verse' and
|
verse and quote blocks are fontified using the `org-verse' and
|
||||||
`org-quote' faces, which inherit from `org-block'."))
|
`org-quote' faces, which inherit from `org-block'.")
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+caption[Improve the visibility of the =sh-heredoc= face in =sh-script.el=]:
|
|
||||||
#+caption: Improve the visibility of the =sh-heredoc= face in =sh-script.el=.
|
|
||||||
#+name: lst:tweak-sh-heredoc-face
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(with-eval-after-load 'emacs
|
|
||||||
;; Shadow the definition in sh-script.el:
|
;; Shadow the definition in sh-script.el:
|
||||||
(defface sh-heredoc
|
(defface sh-heredoc
|
||||||
'((((class color) (background dark))
|
'((((class color) (background dark))
|
||||||
@ -3613,64 +3651,6 @@ on tables by means of =org-narrow-to-table=.
|
|||||||
(define-key ctl-x-map (kbd "C-n") #'narrow-or-widen-dwim))
|
(define-key ctl-x-map (kbd "C-n") #'narrow-or-widen-dwim))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** [[info:emacs#Faces][Text faces or styles (info)]]
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: sec:text-faces-or-styles
|
|
||||||
:END:
|
|
||||||
|
|
||||||
This setup does not configure [[info:emacs#Custom Themes][custom themes (info)]] in order to prevent endless
|
|
||||||
useless tweaking. See the [[https://protesilaos.com/codelog/2020-09-05-emacs-note-mixed-font-heights/][note on mixed font heights in Emacs]] for how to setup
|
|
||||||
fonts properly. It boils down to two rules:
|
|
||||||
1. The height of the default face must be an integer number to make the height a
|
|
||||||
physical quantity.
|
|
||||||
2. The heights of all other faces must be real numbers to scale those heights
|
|
||||||
with respect to the height of the face (those heights default to 1.0 for no
|
|
||||||
scaling).
|
|
||||||
The code in listing [[lst:configure-face-attributes]] source implements those rules.
|
|
||||||
In case of proper initialization of all face heigths, font scaling is easy as
|
|
||||||
listing [[lst:set-default-face-height]] shows.
|
|
||||||
|
|
||||||
#+caption[Configure =face-attributse=]:
|
|
||||||
#+caption: Configure =face-attributes=.
|
|
||||||
#+name: lst:configure-face-attributes
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(with-eval-after-load 'emacs
|
|
||||||
;; Set face attributes.
|
|
||||||
(cond
|
|
||||||
((eq system-type 'darwin)
|
|
||||||
(set-face-attribute 'default nil :family "Hack" :height 120)
|
|
||||||
(set-face-attribute 'fixed-pitch nil :family "Hack")
|
|
||||||
(set-face-attribute 'variable-pitch nil :family "FiraGo"))
|
|
||||||
((eq system-type 'gnu/linux)
|
|
||||||
(set-face-attribute 'default nil :family "Hack" :height 110)
|
|
||||||
(set-face-attribute 'fixed-pitch nil :family "Hack")
|
|
||||||
(set-face-attribute 'variable-pitch nil :family "FiraGo"))
|
|
||||||
(t
|
|
||||||
(set-face-attribute 'default nil :family "Hack" :height 110)
|
|
||||||
(set-face-attribute 'fixed-pitch nil :family "Hack")
|
|
||||||
(set-face-attribute 'variable-pitch nil :family "DejaVu Sans"))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+caption[Implement =set-default-face-height=]:
|
|
||||||
#+caption: Implement =set-default-face-height=.
|
|
||||||
#+name: lst:set-default-face-height
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(with-eval-after-load 'emacs
|
|
||||||
(defun set-default-face-height ()
|
|
||||||
"Set the default face height in all current and future frames.
|
|
||||||
|
|
||||||
Scale all other faces with a height that is a real number."
|
|
||||||
(interactive)
|
|
||||||
(let* ((prompt (format "face heigth (%s): "
|
|
||||||
(face-attribute 'default :height)))
|
|
||||||
(choices (mapcar #'number-to-string
|
|
||||||
(number-sequence 50 200 10)))
|
|
||||||
(height (string-to-number
|
|
||||||
(completing-read prompt choices nil 'require-match))))
|
|
||||||
(message "Setting the height of the default face to %s" height)
|
|
||||||
(set-face-attribute 'default nil :height height))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** [[https://jblevins.org/log/rainbow-mode][Visualize color codes and names]]
|
** [[https://jblevins.org/log/rainbow-mode][Visualize color codes and names]]
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: sec:rainbow-mode
|
:CUSTOM_ID: sec:rainbow-mode
|
||||||
|
Loading…
Reference in New Issue
Block a user