- Font Woes
- Font Configuration Files
- Setting Default Fonts
- Aliasing Microsoft Fonts
- The Result
- Other Notes
- Font configuration/Examples
- Hinted fonts
- No hinting for italic or bold
- Enable anti-aliasing only for bigger fonts
- Disable bold font
- Disable ligatures for monospaced fonts
- Default fonts
- Arabic
- Japanese
- Chinese
- Chinese in Noto Fonts
- CJK, but other Latin fonts are preferred
- Alternate stylistic sets for fonts
- How to set default system font in CentOS?
- 1 Answer 1
- You must log in to answer this question.
- Related
- Hot Network Questions
- Subscribe to RSS
Font Woes
It’s fairly straightforward to set the default font used in native apps on a modern Linux desktop, or the default fonts used to render web pages in your browser of choice.
But if you’re reading this, you probably know that that’s far from the end of the story. You might have noticed that Firefox and Chrome rudely ignore your font settings for many websites. This is because many (if not most) popular sites, including Google, Yahoo, Facebook or GitHub, specify preferred fonts for text:
- Google: arial, sans-serif
- Yahoo: Helvetica Neue, Helvetica, Arial
- Facebook: lucida grande, tahoma, verdana, arial, sans-serif
- GitHub: Helvetica, arial, freesans, clean, sans-serif
You might immediately notice that the most commonly used fonts on these sites, Arial and Helvetica, are fonts that come bundled with Microsoft Windows, and are most likely not installed on your Linux system. In this case, what font is actually used is anyone’s guess. If they are installed (e.g., via a package like ttf-ms-fonts or directly copied from a Windows machine), well, you still probably want to display your favorite font instead 🙂
So, let’s find out what your default fonts and aliases are with fc-match :
for family in serif sans-serif monospace Arial Helvetica Verdana "Times New Roman" "Courier New"; do echo -n "$family: " fc-match "$family" done
This is what I get on my machine by default:
serif: DejaVuSerif.ttf: "DejaVu Serif" "Book" sans-serif: DejaVuSans.ttf: "DejaVu Sans" "Book" monospace: DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book" Arial: DejaVuSans.ttf: "DejaVu Sans" "Book" Helvetica: n019003l.pfb: "Nimbus Sans L" "Regular" Verdana: DejaVuSans.ttf: "DejaVu Sans" "Book" Times New Roman: DejaVuSerif.ttf: "DejaVu Serif" "Book" Courier New: DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
Font Configuration Files
So, assuming you’ve installed your fonts of choice (via a package, copying to /usr/share/fonts or ~/.fonts — please verify with the fc-list command), how do you set them as default in all apps and web sites?
Well, there are two places where fonts are configured: system-wide configuration resides in /etc/fonts/ , and per-user configs are stored in ~/.config/fontconfig/fonts.conf (note that this used to be ~/.fonts.conf before fontconfig 2.10.1). For simplicity’s sake, we’ll do it in ~/.config/fontconfig/fonts.conf .
Let’s open up ~/.config/fontconfig/fonts.conf , or create it if it doesn’t already exist. Put the following skeleton structure in there:
We will put all of our custom configuration between
Setting Default Fonts
First, let’s set the default serif, sans serif, and monospace fonts. I’ll use the beautiful Chrome OS fonts as an example ( ttf-croscore if you’re running Arch Linux). Insert the following between
serif Tinos sans-serif Arimo sans Arimo monospace Cousine
Aliasing Microsoft Fonts
Now, we will create aliases for commonly used fonts like Arial and Helvetica, so that our favorite fonts will always be used instead of these fonts, e.g. when requested by a web site.
Insert the following between
Arial Arimo Helvetica Arimo Verdana Arimo Tahoma Arimo Comic Sans MS Arimo Times New Roman Tinos Times Tinos Courier New Cousine
Note that the Microsoft fonts are aliased directly to the our preferred substitute fonts. Aliasing to generic families (serif, sans-serif etc.) may or may not work depending on your configuration in /etc/fonts (they didn’t work for me), so it’s safer this way.
This list is of course by no means definitive; add/remove aliases as you like.
The Result
You’ll need to log out and back in for all applications to update. You should see the difference immediately:
Google search results, before (Arial):
Google search results, after (Arimo):
You can verify that the aliases have been set up correctly with fc-match :
for family in serif sans-serif monospace Arial Helvetica Verdana "Times New Roman" "Courier New"; do echo -n "$family: " fc-match "$family" done
which should now give you something like:
serif: Tinos-Regular.ttf: "Tinos" "Regular" sans-serif: Arimo-Regular.ttf: "Arimo" "Regular" monospace: Cousine-Regular.ttf: "Cousine" "Regular" Arial: Arimo-Regular.ttf: "Arimo" "Regular" Helvetica: Arimo-Regular.ttf: "Arimo" "Regular" Verdana: Arimo-Regular.ttf: "Arimo" "Regular" Times New Roman: Tinos-Regular.ttf: "Tinos" "Regular" Courier New: Cousine-Regular.ttf: "Cousine" "Regular"
Other Notes
Some existing examples you may find online show the following syntax:
This will produce an error message like
Fontconfig error: "/home/username/.config/fontconfig/fonts.conf", line 38: invalid attribute 'name'
The fix is to change to just , as shown above.
Font configuration/Examples
Configurations can vary to a degree. Please post Fontconfig configurations with an explanation for why they were done.
Hinted fonts
~/.config/fontconfig/fonts.conf
true false true hintslight lcddefault rgb
No hinting for italic or bold
true false lcddefault hintslight true rgb 15 lcdlight hintnone medium hintnone lcdlight 0 hintnone lcdlight
Enable anti-aliasing only for bigger fonts
Some users prefer the sharper rendering that anti-aliasing does not offer:
false 12 true 16 true
Disable bold font
For when a font does not present itself well in bold and you cannot disable bold fonts in the application (st for example).
.. Envy Code R medium medium
Disable ligatures for monospaced fonts
This prevents letter combinations like «ffi» from being squashed into a single-width character in some monospaced fonts. The whole block needs to be duplicated to include extra fonts.
Disable ligatures for monospaced fonts to avoid ff, fi, ffi, etc. becoming only one character wide Nimbus Mono PS liga off dlig off
Some other fonts may also require disabling features such as calt and/or clig .
You can test the effectiveness of this with the following command:
$ echo -e "| worksheet |\n| buffering |\n| difficult |\n| finishing |\n| different |\n| efficient |" | pango-view --font="Nimbus Mono PS" /dev/stdin
Some programs (such as Firefox) do not support the fontfeatures tag, so for those replacing the font with another is the only option. See Font configuration#Set default or fallback fonts for details.
Note: Starting with Firefox version 114, fontconfig settings such as fontfeatures will be supported.
Default fonts
For font consistency, all applications should be set to use the serif, sans-serif, and monospace aliases, which are mapped to particular fonts by fontconfig. See Metric-compatible fonts for options and examples.
Arabic
Example fonts.conf which specifies a default font for the Arabic language and keeps western style fonts for Latin letters. You will require either ttf-arabeyes-fonts AUR or noto-fonts for the below to work. You can also choose to install any other Arabic fonts and accordingly change the font name below based on your preference
The above should work for most applications but some applications like Chromium do not work with the language match test. If you find some applications not using your selected fonts, you can use the below alias and prefer tags which seems to work.
sans-serif Noto Sans Open Sans Droid Sans Roboto Tholoth Noto Sans Arabic serif Noto Serif Droid Serif Roboto Slab Tholoth Noto Sans Arabic monospace Noto Sans Mono Inconsolata Droid Sans Mono Roboto Mono
Japanese
Example fonts.conf which also specifies a default font for the Japanese locale (ja_JP) and keeps western style fonts for Latin letters.
Noto Sans ja Noto Sans CJK JP sans-serif ja -->Noto Sans serif Noto Serif IPAPMincho HanaMinA monospace Noto Sans Mono Inconsolatazi4 IPAGothic sans-serif Noto Sans Open Sans Droid Sans Ubuntu Roboto NotoSansCJK Source Han Sans JP IPAPGothic VL PGothic Koruri serif Noto Serif Droid Serif Roboto Slab IPAPMincho monospace Noto Sans Mono Inconsolatazi4 Ubuntu Mono Droid Sans Mono Roboto Mono IPAGothic
Chinese
~/.config/fontconfig/fonts.conf or /etc/fonts/local.conf
false serif Noto Serif sans-serif Roboto monospace DejaVu Sans Mono zh serif Source Han Serif CN zh sans-serif Source Han Sans CN zh monospace Noto Sans Mono CJK SC WenQuanYi Zen Hei Source Han Sans CN WenQuanYi Micro Hei Source Han Sans CN WenQuanYi Micro Hei Light Source Han Sans CN Microsoft YaHei Source Han Sans CN SimHei Source Han Sans CN SimSun Source Han Serif CN SimSun-18030 Source Han Serif CN
Chinese in Noto Fonts
Apply Noto Fonts while replacing Microsoft Fonts with WenQuanYi Micro Hei
~/.config/fontconfig/fonts.conf or /etc/fonts/local.conf
false serif Noto Serif sans-serif Noto Sans monospace Noto Sans Mono zh serif Noto Serif CJK SC zh sans-serif Noto Sans CJK SC WenQuanYi Micro Hei --> zh monospace Noto Sans Mono CJK SC WenQuanYi Zen Hei WenQuanYi Micro Hei WenQuanYi Zen Hei Lite WenQuanYi Micro Hei Lite WenQuanYi Micro Hei --> WenQuanYi Zen Hei Mono WenQuanYi Micro Hei Mono Microsoft YaHei WenQuanYi Micro Hei SimHei WenQuanYi Micro Hei SimSun WenQuanYi Micro Hei SimSun-18030 WenQuanYi Micro Hei
CJK, but other Latin fonts are preferred
You can replace PT Serif / Roboto / Cascadia Code PL with your favorite serif / sans-serif / monospace fonts.
~/.config/fontconfig/fonts.conf
serif PT Serif sans-serif Roboto monospace Cascadia Code PL system-ui Roboto serif Noto Serif CJK SC ja serif Noto Serif CJK JP ko serif Noto Serif CJK KR zh serif Noto Serif CJK SC zh-hans serif Noto Serif CJK SC zh-hant serif Noto Serif CJK TC zh-cn serif Noto Serif CJK SC zh-tw serif Noto Serif CJK TC sans-serif Noto Sans CJK SC ja sans-serif Noto Sans CJK JP ko sans-serif Noto Sans CJK KR zh sans-serif Noto Sans CJK SC zh-hans sans-serif Noto Sans CJK SC zh-hant sans-serif Noto Sans CJK TC zh-hant-hk sans-serif Noto Sans CJK HK zh-cn sans-serif Noto Sans CJK SC zh-tw sans-serif Noto Sans CJK TC zh-hk sans-serif Noto Sans CJK HK monospace Noto Sans Mono CJK SC ja monospace Noto Sans Mono CJK JP ko monospace Noto Sans Mono CJK KR zh monospace Noto Sans Mono CJK SC zh-hans monospace Noto Sans Mono CJK SC zh-hant monospace Noto Sans Mono CJK TC zh-hant-hk monospace Noto Sans Mono CJK HK zh-cn monospace Noto Sans Mono CJK SC zh-tw monospace Noto Sans Mono CJK TC zh-hk monospace Noto Sans Mono CJK HK system-ui Noto Sans CJK SC ja system-ui Noto Sans CJK JP ko system-ui Noto Sans CJK KR zh system-ui Noto Sans CJK SC zh-hans system-ui Noto Sans CJK SC zh-hant system-ui Noto Sans CJK TC zh-hant-hk system-ui Noto Sans CJK HK zh-cn system-ui Noto Sans CJK SC zh-tw system-ui Noto Sans CJK TC zh-hk system-ui Noto Sans CJK HK
Alternate stylistic sets for fonts
Certain fonts come with alternate stylistic sets for characters through an OpenType feature. Generally these stylistic sets are named ss0x and contain small changes to individual characters. This shows how to change the default dotted zero to a slashed zero for the monospace version of ttf-ibm-plex .
~/.config/fontconfig/fonts.conf
See What are «Stylistic Sets?» for more information on this.
How to set default system font in CentOS?
I want to change system font used by applications globally (or per user) in CentOS. How to do that? Perhaps I should modify ~/.config/fontconfig/fonts.conf file? I would like to set Tahoma font for applications like it was in WinXP.
Can you give some example applications you want to change to font in? Usually the way I would suggest is to change the GTK and Qt themes.
For example — NetBeans. I can set the font of NetBeans text editor, output window, etc., but not L&F font — the system font.
1 Answer 1
As a solution — inserted lines below to file /etc/fonts/fonts.conf :
sans-serif Tahoma Arial serif Times New Roman monospace Courier New false true false hintfull
Then updated font cache with fc-cache . Now desired fonts available system wide.
You must log in to answer this question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.