Fixing Rendering of Microsoft Calibri & Cambria Fonts on Linux
If you're frequently working with text documents created on Windows, chances are you've encountered the Calibri and Cambria fonts, which became the default in Microsoft Office 2007. These fonts are TrueType typefaces, so if you have access to the original .ttf/.ttc files (perhaps through an Office license), you can easily use them on your favourite Linux distribution. However, a common issue with these fonts on Linux is poor rendering. Some characters might appear stronger than others, which can be quite distracting. This happens because Microsoft has embedded poor-quality bitmaps in their fonts. Fortunately, you can configure your system to ignore these embedded bitmaps. Here's how.
To fix the rendering of bitmap-embedded fonts on a per-user basis on Ubuntu 16.04 (and possibly earlier or later versions), create a fonts.conf
file in the directory ~/.config/fontconfig/
. This file should contain the following content:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="embeddedbitmap" mode="assign">
<bool>false</bool>
</edit>
</match>
</fontconfig>
After editing the file, log out and back in again for the changes to take effect.
If you only want to disable bitmap rendering for specific fonts, you can add a <test> ... </test>
block right after the <match>
tag and before the <edit>
tag. For example, if you have the original Calibri .ttf/.ttc files stored in /usr/share/fonts/truetype
, you can run sudo fc-cache -f -v
and then modify the fonts.conf
file like this to disable bitmap rendering for Calibri:
<test name="family" compare="contains">
<string>Calibri</string>
</test>
Unfortunately, matching more than one font is somewhat tricky right now, so turning off bitmaps globally might be the simpler option. If you prefer a system-wide change, you'll need to edit a system fontconfig file, as explained in this guide.
Lastly, keep in mind that this issue doesn't arise if you use free substitutes for Microsoft's Calibri and Cambria fonts, such as Carlito and Caladea. To install these substitute fonts, simply run sudo apt-get install fonts-crosextra-carlito fonts-crosextra-caladea
.
And voilĂ ! Your fonts should now look sharp and sleek across the board.