Endless Parentheses

Concise ramblings on Emacs productivity.

Manually Choose a Fallback Font for Unicode

Jon Snader over at Irreal mentioned that Trey Harris shared on G+ how to use a fallback font for Unicode Symbols. I won't repeat what they said here, you've probably seen it already (and if you haven't then go). I merely come to offer my own solution to this predicament, which doesn't require any package installation and is pretty configurable to boot.

I ran into this a few months ago, while optimising my jabber+gtalk setup, and the answer turns out to be remarkably simple. After installing Symbola on your system, it's a 1-line solution.

(set-fontset-font "fontset-default" nil 
                  (font-spec :size 20 :name "Symbola"))

Some remarks:

  • If you just glanced over that, go back and read the first function's name. Now try to say it 3 times quickly.
  • The documentation of set-fontset-font doesn't even remotely allude to the fact it can be used for setting a fallback fonts. Makes me wonder its intended purpose.
  • The :size 20 argument (which you're free to remove) increases the size of this font only. It's useful because some complex unicode symbols are hard to see in small font.
  • The nil would allow you to restrict the range of glyphs affected by this font. Setting it to nil makes it the fallback font.

Tags: init.el, unicode, emacs

Say thanks on Gratipay
comments powered by Disqus