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?
Ubuntu – Change Default Persian Font
fonts
Related Solutions
Unfortunately, there isn't a GUI configuration editor for you to use to deal with this problem under Ubuntu. The GUI font selectors under Gnome or Unity only allows you to select one font per option, while the Font Manager allows you to enable/disable fonts only.
But, as is the typical case of a Linux system, you actually can configure this, only you'll need to dig up the configuration option from lots of documentations.
Now, straight to the point: you'll need to edit/create the file ~/.fonts.conf
.
- The file does not exist by default. However, if you've used things like Font Manager, then there might be a placeholder file at
~/.fonts.conf
telling you to use~/.config/font-manager/local.conf
instead, in which case you should create the latter. - You should first open
~/.fonts.conf
to check. - To check if the file exists, a simple way would be to open the file manager, go to "Home", check "View->Show Hidden Files" and see if you can find
.fonts.conf
.
Once you've created the file, put the following code in it:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Droid Sans</family>
<family>UKai</family>
</prefer>
</alias>
</fontconfig>
What it does is create a font resolution fallback list. When a program is requesting a sans-serif font (most GUI fonts are sans-serif by default), the system would try to use the first font (Droid Sans) for a character. If the font does not support that character, the second (UKai) will be used. I'm not sure if specifying Droid Sans as the first preference has any significance, but you might as well keep it, just to be safe.
Note also that you'll need to logout of your account and login again to see the effect.
For me, the effect is immediate after logging out and logging in again, and the font choice works system-wide.
The above answer is based on a related blog post: Fedora 中文字体设置
Edit
There is also a more comprehensive configuration sample under /etc/fonts/conf.avail
or /etc/fonts/conf.d
(I don't remember exactly which) whose name contains zh-CN
. Inside is a set of configuration used for adjusting the exact fallback font order, which is far more suitable than the above method. Just copy the content in the file into ~/.fonts.conf
or ~/.config/font-manager/local.conf
and change the ordering of fonts to suit your needs.
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"
$
Best Answer
Create a config file for the font in the following path:
and add these lines to it:
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>
.Place your font in
~/.local/share/fonts
.