Emacs, scripting and anything text oriented.

Gujarati fonts in Emacs

Kaushal Modi

Setting a different font for a specific script or language in Emacs.

This is a post in the “Gujarati in Emacs” series.

2022-06-27Gujarati Transliteration
2022-06-19Gujarati fonts in Emacs

All Emacs versions ship with a nifty HELLO file that you can quickly open using 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.

Figure 1: “Hello” buffer in Emacs

Figure 1: “Hello” buffer in Emacs

Born and raised in the Gujarat state in India, I grew up speaking the Gujarati (ગુજરાતી) language  India officially recognizes 22 languages (as of <2022-06-19 Sun>) 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 <2018-08-13 Mon> that I discovered the presence of Gujarati script in that “Hello” buffer, and the reason I know that exact date is because I had asked a question regarding that on the help-gnu-emacs mailing list 😃.

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 set-fontset-font.

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>")
Code Snippet 1: Setting default font for Gujarati script using set-fontset-font

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:

Table 1: Gujarati Fonts
Font NameNamasteCategoryHomepageDownload
Shrutiserifwfonts.com
Mukta VaaniserifEk Type – Mukta VaaniGitHub
Lohit Gujaratisans serifPagure – Lohitpagure 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 (વાંચવા બદલ આભાર) 🙏!


Versions used: emacs 28.1.50
This is Day 32 of #100DaysToOffload.