blob: 7250290fa44868931fd6d30e92e37df19da83b5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
;;; font-config --- Font Defaults and Related Functionality -*- lexical-binding: t; -*-
;; author: Craig Jennings <c@cjennings.net>
;;; Commentary:
;;; Code:
;; ----------------------- Font Family And Size Selection ----------------------
;; preset your fixed and variable fonts, then apply them to text as a set
(use-package fontaine
:demand t
:bind
("M-F" . fontaine-set-preset)
:config
(setq fontaine-font-families
'((default "Hack Nerd Font Mono" "Fira Code Nerd Font" "MonoLisa" "Codelia Ligatures" "JetBrains Mono Nerd Font")
(fixed-pitch "Fira Code Nerd Font" "Hack Nerd Font" "JetBrains Mono Nerd Font" "Liberation Mono")
(variable-pitch "Literata" "Novaletra Serif CF" "FiraGO" "Nimbus Roman" "Nimbus Sans")))
(setq fontaine-presets
'(
(Berkeley-Merriweather
:default-family "Berkeley Mono"
:default-weight regular
:default-height 130
:fixed-pitch-family nil ;; falls back to :default-family
:fixed-pitch-weight nil ;; falls back to :default-weight
:fixed-pitch-height 1.0
:variable-pitch-family "Merriweather"
:variable-pitch-weight light
:variable-pitch-height 1.0)
(Hack-Only
:default-family "Hack Nerd Font Mono"
:variable-pitch-family "Hack Nerd Font Mono")
(Merriweather-Only
:default-family "Merriweather"
:variable-pitch-family "Merriweather")
(MonoLisa-Novaletra
:default-family "MonoLisa"
:variable-pitch-family "Novaletra Serif CF")
(FiraCode-Literata
:default-family "Fira Code Nerd Font"
:variable-pitch-family "Literata")
(JetBrains0Lato
:default-family "JetBrains Mono"
:variable-pitch-family "Lato")
(Codelia-Only
:default-family "Codelia Ligatures")
(Liberation_Mono-Only
:default-family "Liberation Mono")
(24-point-font
:default-height 240)
(20-point-font
:default-height 200)
(16-point-font
:default-height 160)
(14-point-font
:default-height 140)
(13-point-font
:default-height 130)
(12-point-font
:default-height 120)
(11-point-font
:default-height 110)
(10-point-font
:default-height 100)
(t ;; shared fallback properties go here
:default-family "Berkeley Mono"
:default-weight regular
:default-height 130
: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 "Merriweather"
:variable-pitch-weight light
:variable-pitch-height 1.0
:bold-family nil ;; use whatever the underlying face has
:bold-weight bold
:italic-family nil
:italic-slant italic
:line-spacing nil))))
(with-eval-after-load 'fontaine
(defun cj/apply-font-settings-after-ui-creation()
"Apply font settings when Emacsclient is run in daemon mode.
Emacsclient connects to a headless Emacs daemon, when no UI
exists yet to apply these settings. This solution requests Emacsclient
to apply the default font settings after the server creates a frame.
Note that server-after-make-frame-hook is available only in Emacs 27+."
(interactive)
(fontaine-set-preset 'Berkeley-Only)
(if (daemonp)
(remove-hook 'server-after-make-frame-hook #'cj/apply-font-settings-after-ui-creation)))
(if (daemonp)
(add-hook 'server-after-make-frame-hook #'cj/apply-font-settings-after-ui-creation)
(cj/apply-font-settings-after-ui-creation)))
;; ----------------------------- Font Install Check ----------------------------
;; convenience function to indicate whether a font is available by name.
(defun cj/font-installed-p (font-name)
"Check if font with FONT-NAME is available."
(if (find-font (font-spec :name font-name))
t
nil))
;; ------------------------------- All The Icons -------------------------------
;; icons made available through fonts
(use-package all-the-icons
:demand t
:config
(when (and (not (cj/font-installed-p "all-the-icons"))
(window-system))
(all-the-icons-install-fonts t)))
(use-package all-the-icons-nerd-fonts
:after all-the-icons
:demand t
:config
(all-the-icons-nerd-fonts-prefer))
;; ----------------------------- Emoji Fonts Per OS ----------------------------
;; these are in reverse order of priority
(when (member "Segoe UI Emoji" (font-family-list))
(set-fontset-font
t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend))
(when (member "Apple Color Emoji" (font-family-list))
(set-fontset-font
t 'symbol (font-spec :family "Apple Color Emoji") nil 'prepend))
(when (member "Noto Color Emoji" (font-family-list))
(set-fontset-font
t 'symbol (font-spec :family "Noto Color Emoji") nil 'prepend))
;; ---------------------------------- Emojify ----------------------------------
;; converts emoji identifiers into emojis; allows for easy emoji entry.
(use-package emojify
:hook ((erc-mode . emojify-mode)
(org-mode . emojify-mode)
(prog-mode . (lambda () (emojify-mode -1)))
(gptel-mode . (lambda () (emojify-mode -1))))
:custom
(emojify-download-emojis-p t) ;; don't ask, just download emojis
:bind
("C-c e i" . emojify-insert-emoji) ;; emoji insert
("C-c e l" . emojify-list-emojis) ;; emoji list
:config
(setq emojify-show-help nil)
(setq emojify-point-entered-behaviour 'uncover)
(setq emojify-display-style 'image)
(setq emojify-emoji-styles '(ascii unicode github)))
;; -------------------------- Display Available Fonts --------------------------
;; display all available fonts on the system in a side panel
(defun cj/display-available-fonts ()
"Display a list of all font faces with sample text in another read-only buffer."
(interactive)
(pop-to-buffer "*Available Fonts*" '(display-buffer-in-side-window . ((side . right)(window-width . fit-window-to-buffer))))
(let ((font-list (font-family-list)))
(setq font-list (cl-remove-duplicates (cl-sort font-list 'string-lessp :key 'downcase)))
(with-current-buffer "*Available Fonts*"
(erase-buffer)
(dolist (font-family font-list)
(insert (propertize (concat font-family) 'face `((:foreground "Light Blue" :weight bold))))
(insert (concat "\n"(propertize "Regular: ")))
(insert (propertize (concat "The quick brown fox jumps over the lazy dog I 1 l ! : ; . , 0 O o [ { ( ) } ] ?")
'face `((:family, font-family))))
(insert (concat "\n" (propertize "Bold: ")))
(insert (propertize (concat "The quick brown fox jumps over the lazy dog I 1 l ! : ; . , 0 O o [ { ( ) } ] ?")
'face `((:family, font-family :weight bold))))
(insert (concat "\n" (propertize "Italic: ")))
(insert (propertize (concat "The quick brown fox jumps over the lazy dog I 1 l ! : ; . , 0 O o [ { ( ) } ] ?")
'face `((:family, font-family :slant italic))))
(insert (concat "\n\n"))))
(move-to-window-line 0)
(special-mode)))
(global-set-key (kbd "C-z F") 'cj/display-available-fonts)
;; ----------------------- Increase / Decrease Font Size -----------------------
;; make it easy to enlarge or shrink font sizes with keybindings
(setq text-scale-mode-step 1.08)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C-_") 'text-scale-decrease)
(global-set-key (kbd "C--") 'text-scale-decrease)
;; --------------------------------- Ligatures --------------------------------- '
;; fancy programming glyphs make code easier to read
(use-package ligature
:defer 1
:config
;; Enable the www ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww, if `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable ligatures in markdown mode
(ligature-set-ligatures 'markdown-mode '(("=" (rx (+ "=") (? (| ">" "<"))))
("-" (rx (+ "-")))))
;; Enable ligatures in programming modes
(ligature-set-ligatures 'prog-mode '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" "{-" "::"
":::" ":=" "!!" "!=" "!==" "-}" "----" "-->" "->" "->>"
"-<" "-<<" "-~" "#{" "#[" "##" "###" "####" "#(" "#?" "#_"
"#_(" ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" "/**"
"/=" "/==" "/>" "//" "///" "&&" "||" "||=" "|=" "|>" "^=" "$>"
"++" "+++" "+>" "=:=" "==" "===" "==>" "=>" "=>>" "<="
"=<<" "=/=" ">-" ">=" ">=>" ">>" ">>-" ">>=" ">>>" "<*"
"<*>" "<|" "<|>" "<$" "<$>" "<!--" "<-" "<--" "<->" "<+"
"<+>" "<=" "<==" "<=>" "<=<" "<>" "<<" "<<-" "<<=" "<<<"
"<~" "<~~" "</" "</>" "~@" "~-" "~>" "~~" "~~>" "%%"))
(global-ligature-mode t))
(provide 'font-config)
;;; font-config.el ends here
|