Finally fixed my fonts so that variable-pitch works in org

At least, it works in Org with the ability to change the font sizes,
which is important when giving presentations with larger fonts.

The real culprit was the mixed-pitch project that didn't allow for
changing font sizes (which was easy enough to configure).
This commit is contained in:
Howard Abrams 2022-03-18 13:50:40 -07:00
parent 1a5e20a359
commit 0599164dec
3 changed files with 51 additions and 40 deletions

View file

@ -780,6 +780,8 @@ While the ~C-h~ is easy enough, I am now in the habit of typing ~SPC h~ instead.
"h" '(:ignore t :which-key "help") "h" '(:ignore t :which-key "help")
"h e" '("errors" . view-echo-area-messages) "h e" '("errors" . view-echo-area-messages)
"h f" '("function" . describe-function) "h f" '("function" . describe-function)
"h F" '("font" . describe-font)
"h =" '("face" . describe-face)
"h v" '("variable" . describe-variable) "h v" '("variable" . describe-variable)
"h k" '("key binding" . describe-key) "h k" '("key binding" . describe-key)
"h B" '("embark" . embark-bindings) "h B" '("embark" . embark-bindings)
@ -1172,9 +1174,7 @@ Let's extend Magit with [[https://github.com/magit/forge][Magit Forge]] for work
"g c p" '("Pull request" . forge-create-pullreq))) "g c p" '("Pull request" . forge-create-pullreq)))
#+END_SRC #+END_SRC
Every /so often/, pop over to the following URLs and generate a new Every /so often/, pop over to the following URLs and generate a new token where the *Note* is =forge=, and then copy that into the [[file:~/.authinfo.gpg][~/.authinfo.gpg]]:
token where the *Note* is =forge=, and then copy that into the
[[file:~/.authinfo.gpg][~/.authinfo.gpg]]:
- [[https://gitlab.com/-/profile/personal_access_tokens][Gitlab]] - [[https://gitlab.com/-/profile/personal_access_tokens][Gitlab]]
- [[https://github.com/settings/tokens][Github]] - [[https://github.com/settings/tokens][Github]]
@ -1318,16 +1318,14 @@ Let's try [[https://github.com/bastibe/annotate.el][annotate-mode]], which allow
#+END_SRC #+END_SRC
Keep the annotations simple, almost /tag-like/, and then the summary allows you to display them. Keep the annotations simple, almost /tag-like/, and then the summary allows you to display them.
** Demo It ** Demo It
Making demonstrations /within/ Emacs with [[https://github.com/howardabrams/demo-it][demo-it]]. Making demonstrations /within/ Emacs with my [[https://github.com/howardabrams/demo-it][demo-it]] project. While it is on MELPA, I want to use my own cloned version to make sure I can keep debugging aspects of it. Especially since its use of [[https://github.com/takaxp/org-tree-slide][org-tree-slide]] has separated.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package demo-it (use-package demo-it
:straight (:type git :protocol ssh :host github :repo "howardabrams/demo-it") :straight (:type git :protocol ssh :host github :repo "howardabrams/demo-it")
:commands (demo-it-create demo-it-start)) :commands (demo-it-create demo-it-start))
#+END_SRC #+END_SRC
Perhaps I should change the reference to this for more local development:
#+begin_example
:straight (:local-repo "~/other/demo-it")
#+end_example
* Technical Artifacts :noexport: * Technical Artifacts :noexport:
Let's provide a name so that the file can be required: Let's provide a name so that the file can be required:

View file

@ -130,7 +130,6 @@ Most of the time, Emacs is on my desk is a darkened room, so I choose the dark t
(interactive) (interactive)
(load-theme 'sanityinc-tomorrow-night t) (load-theme 'sanityinc-tomorrow-night t)
(set-face-attribute 'region nil :background "#000096") (set-face-attribute 'region nil :background "#000096")
;; font-lock-comment-face #8a8b8a
(set-face-attribute 'mode-line nil :background "black") (set-face-attribute 'mode-line nil :background "black")
(set-face-attribute 'mode-line-inactive nil :background "#333333")) (set-face-attribute 'mode-line-inactive nil :background "#333333"))
#+END_SRC #+END_SRC
@ -142,7 +141,6 @@ But, when feeling adventurous, I /sometimes/ take my laptop outside:
(interactive) (interactive)
(load-theme 'sanityinc-tomorrow-day t) (load-theme 'sanityinc-tomorrow-day t)
(set-face-attribute 'region nil :background "orange1") (set-face-attribute 'region nil :background "orange1")
;; font-lock-comment-face #8a8b8a
(set-face-attribute 'mode-line nil :background "#cccccc") (set-face-attribute 'mode-line nil :background "#cccccc")
(set-face-attribute 'mode-line-inactive nil :background "#888888")) (set-face-attribute 'mode-line-inactive nil :background "#888888"))
#+END_SRC #+END_SRC
@ -248,28 +246,24 @@ I probably don't need to have such a ranking system, as chances are really good
"My variable width font available to org-mode files and whatnot.") "My variable width font available to org-mode files and whatnot.")
#+END_SRC #+END_SRC
Simple function that gives me the font information based on the size I need. This calls =set-frame-font=, but also sets the monospaced font for org code blocks. Simple function that gives me the font information based on the size I need. Recently updated after reading [[https://protesilaos.com/codelog/2020-09-05-emacs-note-mixed-font-heights/][this essay]], as I wanted my =fixed-pitch= to scale along with my =variable-pitch= font.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun ha-set-favorite-font-size (size) (defun ha-set-favorite-font-size (size)
"Set the default font size as well as equalize the fixed and variable fonts."
(let ((fav-font (format "%s-%d" ha-fixed-font size))) (let ((fav-font (format "%s-%d" ha-fixed-font size)))
(set-frame-font fav-font nil t) (set-face-attribute 'default nil :font fav-font)
(set-face-attribute 'fixed-pitch nil :family ha-fixed-font :inherit 'default :height 1.0)
;; When using variable-pitch in org, we need to specifically set the (set-face-attribute 'variable-pitch nil :family ha-variable-font :inherit 'default :height 1.15)))
;; fixed-pitch as my default fixed-pitched font.
(custom-theme-set-faces
'user
`(variable-pitch ((t (:family ,ha-variable-font :slant normal :weight normal :height 1.3 :width normal))))
`(fixed-pitch ((t (:family ,ha-fixed-font :slant normal :weight normal :height 1.0 :width normal)))))))
#+END_SRC #+END_SRC
Define /interactive/ functions to quickly adjusting the font size based on my computing scenario: Define /interactive/ functions to quickly adjusting the font size based on my computing scenario:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun ha-mac-monitor-fontsize () (defun ha-mac-monitor-fontsize ()
"Quickly set reset my font size when I connect my laptop to a monitor on a Mac." "Quickly set reset my font size when I connect my laptop to a monitor on a Mac."
(interactive) (interactive)
(ha-set-favorite-font-size 16)) (ha-set-favorite-font-size 17))
(defun ha-linux-monitor-fontsize () (defun ha-linux-monitor-fontsize ()
"Quickly set reset my font size when I connect my laptop to a monitor on Linux." "Quickly set reset my font size when I connect my laptop to a monitor on Linux."

View file

@ -94,7 +94,7 @@ I really want to use the Org Beautify package, but it overrides my darker themes
First step is to make all Org header levels to use the variable font, and be the same color as the default text: First step is to make all Org header levels to use the variable font, and be the same color as the default text:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(when window-system (when window-system
(let ((default-color (face-attribute 'default :foreground))) (let ((default-color (face-attribute 'default :foreground)))
(dolist (face '(org-level-1 org-level-2 org-level-3 org-level-4 org-level-5 org-level-6 org-level-7 org-level-8)) (dolist (face '(org-level-1 org-level-2 org-level-3 org-level-4 org-level-5 org-level-6 org-level-7 org-level-8))
(set-face-attribute face nil (set-face-attribute face nil
@ -104,18 +104,40 @@ First step is to make all Org header levels to use the variable font, and be the
Next, we just need to change the header sizes: Next, we just need to change the header sizes:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(when window-system (when window-system
(set-face-attribute 'org-level-1 nil :height 2.2 :inherit 'default) (set-face-attribute 'org-level-1 nil :height 2.2)
(set-face-attribute 'org-level-2 nil :height 1.8 :inherit 'default) (set-face-attribute 'org-level-2 nil :height 1.8)
(set-face-attribute 'org-level-3 nil :height 1.4 :inherit 'default) (set-face-attribute 'org-level-3 nil :height 1.4)
(set-face-attribute 'org-level-4 nil :height 1.1 :inherit 'default)) (set-face-attribute 'org-level-4 nil :height 1.1))
#+END_SRC #+END_SRC
While we are at it, lets make sure the code blocks are using my fixed with font: While we are at it, lets make sure the code blocks are using my fixed with font:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package mixed-pitch (when window-system
:init (setq mixed-pitch-set-height t) (dolist (face '(org-block org-code org-verbatim org-table org-drawer
:hook (org-mode . mixed-pitch-mode)) org-special-keyword org-property-value org-document-info-keyword))
(set-face-attribute face nil :inherit 'fixed-pitch)))
#+END_SRC
Not sure why the above code removes the color of =org-verbatim=, so lets make it stand out slightly:
#+BEGIN_SRC emacs-lisp
(set-face-attribute 'org-verbatim nil :foreground "#aaaacc")
#+END_SRC
And some slight adjustments to the way blocks are displayed:
#+BEGIN_SRC emacs-lisp
(set-face-attribute 'org-block-begin-line nil :background "#282828")
(set-face-attribute 'org-block nil :height 0.95)
(set-face-attribute 'org-block-end-line nil :background "#262626")
#+END_SRC
And decrease the prominence of the property drawers:
#+BEGIN_SRC emacs-lisp
(set-face-attribute 'org-drawer nil :height 0.8 :line-height 0.8)
(set-face-attribute 'org-property-value nil :height 0.85)
(set-face-attribute 'org-special-keyword nil :height 0.85)
#+END_SRC
This process allows us to use =variable-pitch= mode for all org documents.
#+BEGIN_SRC emacs-lisp
(use-package org
:hook (org-mode . variable-pitch-mode))
#+END_SRC #+END_SRC
* Superstar * Superstar
Now that headers are noticeable, I have no reason to see a number of asterisks. Once I used the [[https://github.com/sabof/org-bullets][org-bullets]] package, but believe we've replaced it with [[https://github.com/integral-dw/org-superstar-mode][org-superstar-mode]], so the following is an improvement, especially with the sub-bullets: Now that headers are noticeable, I have no reason to see a number of asterisks. Once I used the [[https://github.com/sabof/org-bullets][org-bullets]] package, but believe we've replaced it with [[https://github.com/integral-dw/org-superstar-mode][org-superstar-mode]], so the following is an improvement, especially with the sub-bullets:
@ -148,9 +170,8 @@ If this works, then we get the prettier bulleted list:
- Birds - Birds
Oh, and as I indent lists, they should change the /bulleting/ in a particular sequence. If I begin with an =*= asterisk, I walk down the chain, but with the dashed bullets (my default choice), I just stay with dashed bullets. Numeric bullets should cycle: Oh, and as I indent lists, they should change the /bulleting/ in a particular sequence. If I begin with an =*= asterisk, I walk down the chain, but with the dashed bullets (my default choice), I just stay with dashed bullets. Numeric bullets should cycle:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq org-list-demote-modify-bullet '(("*" . "+") ("+" . "-") ("-" . "-") (setq org-list-demote-modify-bullet '(("*" . "+") ("+" . "-") ("-" . "-")
("1." . "a.") ("a." . "1."))) ("1." . "a.") ("a." . "1.")))
#+END_SRC #+END_SRC
@ -183,13 +204,11 @@ According to an idea by [[https://jft.home.blog/2019/07/17/use-unicode-symbol-to
#+END_SRC #+END_SRC
And now we can attach it to a newly loaded org files: And now we can attach it to a newly loaded org files:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook 'ha-org-prettify-checkboxes) (add-hook 'org-mode-hook 'ha-org-prettify-checkboxes)
#+END_SRC #+END_SRC
To make it more distinguishable, he also changed the colors: To make it more distinguishable, he also changed the colors:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defface org-checkbox-done-text (defface org-checkbox-done-text
'((t (:foreground "#71696A" :strike-through t))) '((t (:foreground "#71696A" :strike-through t)))
@ -258,7 +277,7 @@ However, I'm just going to have to write a function to clean this.
Now that is some complicated regular expressions. Now that is some complicated regular expressions.
* Pasting * Pasting
I like the idea that I will paste HTML text from the clipboard and have it converted to org-formatted text: I like the idea that I will paste HTML text from the clipboard and have it converted to org-formatted text:
#+BEGIN_SRC emacs-lisp :results silent #+BEGIN_SRC emacs-lisp
(defun ha-org-paste () (defun ha-org-paste ()
(interactive) (interactive)
(if (eq system-type 'gnu/linux) (if (eq system-type 'gnu/linux)