Playing with Emacs’ fontsets definitions should be the answer.
After reading
In our init file we should be able to set one font for full range of characters:
(let ((my-font "DejaVu Sans Mono-14"))
(set-fontset-font "fontset-startup" '(#x000000 . #x3FFFFF) my-font)
(set-fontset-font "fontset-default" '(#x000000 . #x3FFFFF) my-font)
(set-fontset-font "fontset-standard" '(#x000000 . #x3FFFFF) my-font))
But to set a font for a range of characters and force it as a fallback font for characters not supported by it we also must add nil
as a target:
(let ((my-font "DejaVu Sans Mono-14")
(font-sets '("fontset-default"
"fontset-standard"
"fontset-startup")))
(mapcar
(lambda (font-set)
;; all the characters in that range (which is the full possible range)
(set-fontset-font font-set '(#x000000 . #x3FFFFF) my-font)
;; for all characters without font specification
;; in another words it is a setting for lack of fallback font
;; if e.g. ℕ called DOUBLE-STRUCK CAPITAL N is not covered by our font
;; it will be displayed as placeholder-box,
;; because fallback for our font is now... our font :)
(set-fontset-font font-set nil my-font))
font-sets))
Now as we can see under point (cursor) with C-u C-x =
or M-x describe-char
:
position: 1430 of 1954 (73%), column: 16
character: ℕ (displayed as ℕ) (codepoint 8469, #o20425, #x2115)
preferred charset: unicode (Unicode (ISO10646))
code point in charset: 0x2115
script: symbol
syntax: w which means: word
category: .:Base, L:Left-to-right (strong)
to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME"
buffer code: #xE2 #x84 #x95
file code: #xE2 #x84 #x95 (encoded by coding system utf-8-unix)
display: no font available
Character code properties: customize what to show
name: DOUBLE-STRUCK CAPITAL N
old-name: DOUBLE-STRUCK N
general-category: Lu (Letter, Uppercase)
decomposition: (font 78) (font 'N')
Important part: display: no font available.
It should be possible to set that in our .Xresources file:
With the X resource ‘Emacs.Font’, you can specify a fontset name
just like an actual font name.
I do not know what is a proper syntax for that though.
Before that change I was able to see a lot of unicode glyphs not supported by my font of choice.
After that change — I can only see one font in my Emacs and empty boxes-placeholders for glyphs not supported by it.
It works in my system and should be enough for now before someone
else give you a detailed, technical and correct answer.
(set-fontset-font t nil MY-FONT)
whereMY-FONT
is the name of your font?describe-char
).(set-fontset-font t nil "fontset-default")
. P.S.: It's necessary to set thedefault
face (Menu bar:Options > Set Default Font... > {choose font}
thenOptions > Save Options
).