Different Linux distributions map different fonts to generic font families like serif, sans-serif and monospace and thats fine. Unfortunately as a web developer I need those families consistent on all my machines and as similar as possible to generic font families mapping my code users have. Because of that the first thing I do when I decide to keep Linux distribution around is to configure serif, sans-serif and monospace generic font families mapping.
I usually do this only for my user account but it is also easy to configure this mappings globally. For per user configuration just login as target user and create file named
.fonts.conf in target users home directory.
Now you can place following inside and replace font families to font families you require for your work:
<!--?xml version="1.0"?>--> <!--DOCTYPE fontconfig SYSTEM "fonts.dtd">--> <!-- ~/.fonts.conf for per-user font configuration --> <fontconfig> <alias> <family>serif</family> <prefer> <family>Liberation Serif</family> </prefer> </alias> <alias> <family>sans-serif</family> <prefer> <family>Liberation Sans</family> </prefer> </alias> <alias> <family>monospace</family> <prefer> <family>Liberation Mono</family> </prefer> </alias> </fontconfig>
Instead of only one font family you can place multiple ones and fontconfig will search trough this list and pick first font that exists on your system. I usually place Liberation Sans (open source version of Arial) as sans-serif, Liberation Serif (open source version of Times New Roman) as serif and Liberation Mono (open source version of Courier New) as monospace but you can place any font that comes to your mind.
If you want to configure this for all users on Debian based machine like Ubuntu just place your file named
/etc/fonts/conf.avail/ and create symlink inside
sudo nano /etc/fonts/conf.avail/99-webfont-mapping.conf sudo ln -s /etc/fonts/conf.avail/99-webfont-mapping.conf /etc/fonts/conf.d/99-webfont-mapping.conf
You should reboot now for changes to take an effect. Enjoy!