11

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?

4
  • Can you explain exactly which font you are referring to? Providing a screenshot might be helpful ;)
    – Ravexina
    Jun 18, 2017 at 14:12
  • For example, Windows default Persian font. Jun 18, 2017 at 14:15
  • By default, the packages fonts-farsiweb and fonts-sil-scheherazade are installed if you install Persian on Ubuntu. Do you have those packages installed? Jun 21, 2017 at 13:26
  • Yes I have installed them. Jun 21, 2017 at 14:52

3 Answers 3

7
  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.

2
  • Thanks, works great. I just put the directory to my current fonts location. <dir>~/.fonts</dir>
    – H. Najafi
    Jun 11, 2020 at 15:32
  • It works great!
    – soheil yo
    Feb 12, 2021 at 8:44
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).

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.