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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.