Change Default Persian Font

I am using Ubuntu 16.04 LTS and I want to change its default Persian font because I think it looks bad. And I don't want to change the default English font. Is this possible? If it is, how should I do this?


Solution 1:

  1. Create a config file for the font in the following path:

    $HOME/.config/fontconfig/fonts.conf
    

    and add these lines to it:

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
    <fontconfig>
    
     <match>
      <edit mode="prepend" name="family">
       <string>Vazir</string>
      </edit>
     </match>
    
     <dir>~/.local/share/fonts</dir>
     <dir>/usr/share/fonts/</dir>
    
    </fontconfig>
    

    I used Vazir font, if you want to use another font(e.g. Tahoma) you must change the <string>Vazir</string> to <string>Tahoma</string>.

  2. Place your font in ~/.local/share/fonts.

Solution 2:

You can change your font configuration to change the font of only Persian texts.

Create/Edit a font config file:

vim ~/.fonts.conf

Paste this into it:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
        <match target="pattern">
                <test name="lang" compare="contains">
                        <string>az</string>
                </test>
                <test name="family">
                        <string>sans-serif</string>
                </test>
                <edit name="family" mode="prepend" binding="same">
                        <string>Noto Naskh Arabic</string>
                </edit>
        </match>

        <match target="pattern">
                <test name="lang" compare="contains">
                        <string>az</string>
                </test>
                <test name="family">
                        <string>serif</string>
                </test>
                <edit name="family" mode="prepend" binding="same">
                        <string>Noto Naskh Arabic</string>
                </edit>
        </match>
</fontconfig>

To use another font (e.g. Vazir) instead of Noto Naskh Arabic, if you have already installed Vazir.ttf font, run this:

fc-list : family file | grep Vazir.ttf

this will show an output like this:

/usr/share/fonts/truetype/Vazir/vazir-font-master/dist/Vazir.ttf: Vazir

The second part of the output (after :) is the actual name of the font which you should use.

Save it and it will make effect on every new application you open.

If you want to learn how to install a font, read this.

NOTE: The lang property must be ISO 639 compatible language tag, and Persian is tagged fa. But with fa it didn't change the fonts (I don't know why. I hope it works for you with fa), so I used az (Azerbaijani).

Solution 3:

The default Ubuntu font not support your interest Persian font but you have two solutions:

  1. user other beauty persian support form and open source same as the Vazir or etc.

  2. but other solution If you need necessary Ubuntu Latin form use the font-forge and merge any favorite fonts.

And for change default font you can use the Ubuntu Tweak or unity tweak tool