Add fix for Calibri and Cambria fonts by default

Calibri and Cambria usually end up looking really bad on linux in general (not just Garuda) due to the bitmap data of these old fonts in particular not containing nearly as many resolutions as they oughta. I know a lot of people don’t have any problems with this, likely due to there being a number of different ways to acquire windows fonts and not every single version of Calibri and Cambria you can download is missing lots of bitmap data- in my case, I had a windows partition which I copied all the fonts over from:

(See this guide → [ Microsoft fonts - ArchWiki ] for those specific steps if you were curious.)

Anyway, being a student, I encounter specifically Calibri a lot in many of the assignments I’m given, which makes the fact that Calibri and Cambria are THE premiere problem-fonts very frustrating, as every time I opened an assignment in Libreoffice or what have you, it looks AWFUL with only very occasional anti-aliasing in very specific places.

What makes the issue a bit harder to solve on Garuda over base Arch or other distros is that (for me at least) you need to look to /etc/fonts instead of /usr/share/fonts where the fonts are actually located or in ~/.config where other places would direct you to, and it took a bit of searching and headache to finally discover the solution was to edit the 51-local.conf file located there rather than other config files in other places.

Considering the solution was just to add a simple entry so it appears as such: (see below), and all that entry does is set embeddedbitmap false for fonts of those names if they exist, I really think it’d be worth it to have these checks in place by default, as it’s a small thing, is definitely something others will encounter eventually and get frustrated with too, wouldn’t affect users who don’t have or use these fonts, and it only adds about 700B of data.

(/etc/fonts/conf.d/51-local.conf):

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <description>Load local customization file</description>
	<!-- Load local system customization file -->
	<include ignore_missing="yes">local.conf</include>
  <match target="font">
  <test name="family" compare="contains">
	<string>Calibri</string>
  </test>
	<edit name="embeddedbitmap" mode="assign">
	  <bool>false</bool>
	</edit>
  </match>
  <match target="font">
  <test name="family" compare="contains">
    <string>Cambria</string>
  </test>
    <edit name="embeddedbitmap" mode="assign">
      <bool>false</bool>
    </edit>
  </match>
</fontconfig>

(The above solution was found on the Arch forums, based on another answer given on the Ubuntu forums, though it doesn’t include accurate information about where/what is the correct file to put this in: → [ [SOLVED] Calibri doesn't use anti-aliasing in libreoffice / Newbie Corner / Arch Linux Forums ] )

I realize the obvious response to this would be something along the lines of ‘this is certainly only because of the way you got those fonts on your system, since you could’ve just installed vista-fonts or some other font package which includes them, which most would do just by default or to fix it anyway, so why bother with this?’ but here’s the thing(s): there’s no way I’m going to be the last one who installs Garuda and brings all their windows fonts over this way. I mean, there are advantages to transferring from a windows partition over other methods inherently. In my case, I had hundreds of fonts that collected in my windows partition from various websites and wherever over the years and, yeah, I’d prefer to have them all available to me. Also, since I already tried the import-from-windows method first, it would create the need in me to go through and uninstall every font said package would install for fear of creating unnecessary or conflicting duplicates, which is a lot of work compared to just… pasting this. Granted, it took me hours to figure out what to paste and where to paste it, but aside from that and judging purely on the solutions themselves, this is the inaguably better one.

So yeah, I am still a bit of a newb myself if it wasn’t obvious. Hopefully this can and will be a default configuration in the future. (I say can because I honestly don’t know the limitations of this kind of stuff.) I also hope that one day if someone installs Garuda and encounters this doing the same thing I did that they find this post and all can be well in their world once again.

2 Likes

The ArchWiki article you linked actually mentions this specific issue a little further down, here:

Disable embedded bitmap fonts

Some Microsoft TTF fonts such as Calibri and Cambria contain embedded bitmap fonts for specific font sizes, which are not anti-aliased. If embedded bitmaps are enabled, the fonts are not anti-aliased at those specific sizes. Embedded bitmap fonts can be disabled in the font configuration.

The article linked there describes how to disable embedded bitmap for all fonts, or just for a specific font, or to disable for all fonts except a specific font.

Disable bitmap fonts

Bitmap fonts are sometimes used as fallbacks for missing fonts, which may cause text to be rendered pixelated or too large. Use the 70-no-bitmaps.conf preset to disable this behavior.

To disable embedded bitmap for all fonts:

~/.config/fontconfig/conf.d/20-no-embedded.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="embeddedbitmap" mode="assign">
      <bool>false</bool>
    </edit>
  </match>
</fontconfig>

To disable embedded bitmap fonts for a specific font:

<match target="font">
  <test qual="any" name="family">
    <string>Monaco</string>
  </test>
  <edit name="embeddedbitmap">
    <bool>false</bool>
  </edit>
</match>

If embedded bitmaps are disabled for all fonts, they can still be enabled for a specific font in case it does not function without embedded bitmaps. E.g. for Noto Color Emoji:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="embeddedbitmap" mode="assign">
      <bool>false</bool>
    </edit>
  </match>
  <match target="font">
    <test name="family" qual="any">
      <string>Noto Color Emoji</string>
    </test>
    <edit name="embeddedbitmap">
      <bool>true</bool>
    </edit>
  </match>
</fontconfig>

I think there are a number of possible explanations why this has not been defined as a default. I don’t know the real reasons (I don’t maintain the fontconfig library, nor any font packages), but this is what comes immediately to mind:

  • Not everyone will want to define the same behavior; some folks may wish to disable embedded bitmaps for all fonts, some for only specific ones, and some may wish to leave embedded bitmaps intact.
  • Many users do not install these fonts at all. Defining a configuration default for packages which are not installed is generally poor coding practice, as it can lead to unnecessary complexity, potential errors, and confusion.

Often in Arch Linux, configuration details like this will be left undefined by default, and the user inherits the responsibility of configuring the system according to their preference. For many Arch users, the note in the relevant Wiki article will be enough.

But anyway, good on you for sticking with it and finding a solution. Thank you for sharing the notes from your research, and welcome to the community @ForkMan! :wave:

2 Likes