3

I use Emacs with monospace fonts, and I would like all the characters to have the same width, which is the purpose of monospace fonts. The issue is that the main font may not support all the characters, and a different font may need to be used as a fallback. So I want the width of the fallback font to be the same as the default font, and this needs to be done automatically. To simplify, consider that the fallback font is always the same, say DejaVu Sans Mono (not including a size, which needs to be selected automatically), but the main font may vary in various invocations of Emacs, e.g. with the -fn option + font (possibly with a size), such as:

emacs -fn "DejaVu Sans Mono"
emacs -fn "Fantasque Sans Mono"
emacs -fn "Fantasque Sans Mono-15"

If I just use

(set-fontset-font t 'unicode (font-spec :name "DejaVu Sans Mono"))

in my .emacs, this fallback font will always have the same width, thus may not match the width of the main font, so this is not OK. What can I do?

Note: I'm not requiring the fontsize to be the same. For two different fonts, the fontsizes of the main font and the fallback font may need to be different to get the same width.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.