Ubuntu – Change Default Font for a Specific Language

defaultfontslanguage

Is there any way to change the default font for a specific language like Persian/Farsi?
I don't want to change the whole font system. I like Ubuntu Font very much but the Persian/Farsi version is very bad and it's difficult to read.
I've Unity Tweak Tool installed but it doesn't provide any option, to change the font for a specific language/font Family.

Any help would be greatly appreciated,
Thanks a lot.
OS: Ubuntu 14.10

Best Answer

You can create the file ~/.config/fontconfig/conf.d/90-my-farsi.conf and give it this contents as a starter:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="pattern">
        <test name="lang" compare="contains">
            <string>fa</string>
        </test>
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Homa</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>fa</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Homa</string>
        </edit>
    </match>
</fontconfig>

That file results in the Homa font (included in the fonts-farsiweb package) being selected at first hand when Persian is the selected language.

$ LANG=fa_IR fc-match
homa.ttf: "Homa" "Regular"
$ 
Related Question