Fix rendering of Microsoft Calibri & Cambria fonts on Linux

If you frequently work with text documents created on Windows, you will most likely have come across Calibri and Cambria, the “new” default fonts on Microsoft Office since version 2007. Both fonts are TrueType typefaces, so if you have access to the original .ttf/.ttc files (e.g. from an Office license), using them on a Linux distribution is fairly straightforward. One issue that pops up often when using the original fonts, though, is bad rendering. Certain characters might appear stronger than others, which can be quite distracting. The reason is that Microsoft apparently decided to embed surprisingly bad bitmaps in their fonts. Fortunately, you can tell your system not to use embedded bitmaps. Here is how.px.gif

To fix rendering of bitmap-embedded fonts on a per-user basis on Ubuntu 16.04 (and possibly earlier/later versions), create a file fonts.conf in the directory ~/.config/fontconfig/ (start from your home folder, show hidden folders, open .config, then create and open a folder fontconfig and create a file fonts.conf). That file will need to contain the following content:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
  <match target="font">
    <edit name="embeddedbitmap" mode="assign">

Now log out and log back in again, and the changes should be visible immediately. Note that if you want to restrict disabling bitmap rendering to certain fonts, you could add a <test> ... </test> block right after the <match> tag and before the <edit> tag:

<test name="family" compare="contains">

Unfortunately, matching more than one font is somewhat difficult at the moment, so simply turning off bitmaps globally would probably be the easier option. Also, note that if you want this to be a system-wide change, you will need to edit a system fontconfig file, as described in this guide. Finally, keep in mind that none of this is an issue if you use free substitutes for Microsoft's fonts, called Carlito and Caladea. To use the replacement fonts, simply run sudo apt-get install fonts-crosextra-carlito fonts-crosextra-caladea. If you prefer the originals instead, copy the original .ttf/.ttc files to /usr/share/fonts/truetype and run sudo fc-cache -f -v.