Tag Archives: fonts

Changing default hindi / marathi / devanagari font in Linux

Difference between Lohit Devanagari and Noto Sans Devanagari
Difference between Lohit Devanagari and Noto Sans Devanagari

Assuming that you are running a fairly modern Linux distro like Ubuntu or Fedora, most likely you’ll get “Lohit Devanagari” pre-installed and should work just fine.

However if you have an itch to change the default devanagari font (which in most of the systems should be Lohit Devanagari), Then all you need a change in ~/.fonts.conf.

Create a .fonts.conf file in your home folder ie. ~/. Or edit the file and add / write the following contents.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match>
    <test name="lang" compare="contains">
      <string>hi</string>
    </test>
    <test name="family">
      <string>sans-serif</string>
    </test>
    <edit name="family" mode="prepend">
      <!-- <string>Lohit Devanagari</string> -->
      <string>Noto Sans Devanagari</string>
    </edit>
  </match>
  <match>
    <test name="lang" compare="contains">
      <string>mr</string>
    </test>
    <test name="family">
      <string>sans-serif</string>
    </test>
    <edit name="family" mode="prepend">
      <!-- <string>Lohit Devanagari</string> -->
      <string>Noto Sans Devanagari</string>
    </edit>
  </match>
  <match>
    <test name="lang" compare="contains">
      <string>hi</string>
    </test>
    <test name="family">
      <string>serif</string>
    </test>
    <edit name="family" mode="prepend">
      <!-- <string>Lohit Devanagari</string> -->
      <string>Noto Sans Devanagari</string>
    </edit>
  </match>
  <match>
    <test name="lang" compare="contains">
      <string>mr</string>
    </test>
    <test name="family">
      <string>serif</string>
    </test>
    <edit name="family" mode="prepend">
      <!-- <string>Lohit Devanagari</string> -->
      <string>Noto Sans Devanagari</string>
    </edit>
  </match>
</fontconfig>

What we are really doing over here is asking the system to use Noto Sans Devanagari font whenever language is hi (Hindi) or mr (Marathi) and consider the same font for both serif and sans-serif families.

Some of the really beautiful fonts that I’ve seen in Devanagari are

Do check the Ek Type Foundry, I’m quite a fan of their fonts!

Note: I’ve tested my settings on Ubuntu 18.04, so anything newer, should work as well.

Update: Focal Fossa (20.04) / GNOME 3.36

I recently updated to the latest Ubuntu LTS, and… the above changes didn’t work. 🙁 After a lot of tinkering (and reading man fonts.conf) I managed to get them working by creating the font config file ~/.config/fontconfig/conf.d/10-devanagari-substitution.conf. The 2 character numerical number is a priority and is a necessity according to Font Configuration – Arch Linux.

Also personally, I’ve found to use just the Noto Sans font downloaded from Google fonts as it tends to include the roman Glyphs along with Devanagari ones.