Setting a different font for a specific script or language in Emacs.
|2022-06-19||Gujarati fonts in Emacs|
All Emacs versions ship with a nifty HELLO file that you can quickly
M-x view-hello-file or its default binding
C-h h. This
file lists “Hello” written in dozens of languages to demonstrate some
of the character sets supported by Emacs.
Born and raised in the Gujarat state in India, I grew up speaking the Gujarati (ગુજરાતી) language India officially recognizes 22 languages (as of ) and Gujarati is one of them. and so it’s also the language closest to my heart. So I was pleasantly surprised to see a representation of Gujarati in the “Hello” buffer! In the above screenshot, in the “South Asia” section, the script after the yellow cursor is Gujarati, and it reads namaste.
Setting a “fontset” font #
It was on asked a question regarding that on the help-gnu-emacs mailing list 😃.that I discovered the presence of Gujarati script in that “Hello” buffer, and the reason I know that exact date is because I had
This was the time when Emacs was using the m17n library for
multi-lingual font rendering by default. The question was regarding a
font rendering issue I was seeing. As I learn later in that thread, it
was because I didn’t have the m17n database installed on my machine
At least in 2022, the harfbuzz library is the recommended library for
text shaping and font rendering. Someone please correct me if that’s
wrong. In any case, I have switched to using harfbuzz instead of
m17n for a while now and haven’t found any font-rendering issues
with non-English scripts.
. But it’s in that support thread that, thanks to Andy Moreton, I
learned that you can change the font for the Gujarati script using
This applies in general to any script. You can read more details about this function in Emacs Info: Modifying Fontsets, but here’s the gist:
(set-fontset-font "fontset-default" 'gujarati "<FONT NAME>")
That led me down the path of exploring the available Gujarati fonts out there ..
Gujarati fonts #
After looking around for a bit, I found a wonderful collection of Gujarati fonts in this GitHub repository: github.com/samyakbhuta/chhapkaam The repo name is chhapkaam (I would have spelled it as chhaapkaam) which is the Gujarati word છાપકામ, meaning “printing”. .
Below is my further curated list of fonts from the above list:
|Mukta Vaani||serif||Ek Type – Mukta Vaani||GitHub|
|Lohit Gujarati||sans serif||Pagure – Lohit||pagure releases|
To use these fonts, after downloading and installing them on your
system, evaluate Code Snippet 1 above with the
correct “FONT NAME”. For example, to set the Gujarati text to use the
Shruti font, evaluate
(set-fontset-font "fontset-default" 'gujarati "Shruti").
Thanks for reading (વાંચવા બદલ આભાર) 🙏!