Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

Changelog

  • 10.01.2017 23:22: Changed typo Windings to Wingdings in the /etc/fonts/local.conf template, users are advised to update their files.
  • 11.01.2017 00:42: Fixed another bug in /etc/fonts/local.conf, thank you edgard.
  • 11.01.2017 13:08: Instruct users to symlink configuration from /etc/fonts/conf.avail instead of setting interpreter instructions in /etc/fonts/local.conf. This prevents the overwriting of specialized fontconfig instructions in lower prefixes and might change the looks slightly. To restore the old behavior you can simply insert:
  <match target="font">
    <edit name="hintstyle" mode="assign">
      <const>hintslight</const>
    </edit>
  </match>

below <fontconfig> in /etc/fonts/local.conf. Here's the old look and the new look, I urge you to test it on more sites to get a feel for the differences. There are advantages and disadvantages to both, though in general I feel that the new look preserves more of the actual shape.

  • 11.01.2017 15:22: Added some screenshots at the very top of the gist.
  • 11.01.2017 21:44: Fixed typos in the symlink-creation part
  • 15.01.2017 22:06: Added alternative instructions on how to symlink the infinality-substitution snippet to /etc/fonts/conf.d, since it is now part of the fonts-meta-extended-lt package.
  • 23.01.2017 16:41: Added mirror links to missing optional fonts in step 2 in the "Creating an Infinality-like fontconfig Configuration"-section, since bohoomil's font repository seems to be offline now.

General

If you installed infinality-bundle or the patched freetype2-infinality(-ultimate) package, you'll most likely recently have run into an error relating to the harfbuzz package (>= 1.4.1-1), specifically something like: /usr/lib/libharfbuzz.so.0: undefined symbol: FT_Get_Var_Blend_Coordinates.

This is because the packages provided by the Infinality repositories or even the freetype2-infinality on AUR are and have been outdated for quite some time, since infinality-bundle's creator, bohoomil, has been missing/unresponsive for the past few months. freetype2 since has gotten new features and a changed ABI, one of which is a symbol named FT_Get_Var_Blend_Coordinates which the updated libharfbuzz tries to reference.

What this means for you is: you'll need a freetype2 version >= 2.7.1 where this change was initially introduced. Since the future of the infinality-bundle is uncertain this is a good time as any to bite the bullet and remove it completely from your system until more is known. The font rendering won't be exactly the same, but with a few tweaks it will at least be similar.

Removing the infinality-bundle

If you still have the infinality-bundle installed, specifically fontconfig-infinality-ultimate, run sudo fc-presets set, choose option 4) to reset and then 5) to quit fc-presets -- this will save you some work of removing dead symlinks in step 4) of the guide. If the package is already removed, that is no problem: removing broken symlinks isn't hard and there's only 4 of them.

A useful tool to remove all traces of the infinality-bundle will be pkgbrowser. To prevent problems with using pkgbrowser down the line, start by doing the most important thing first: replacing the various packages from the infinality-bundle repository which caused the problem in the first place. Replace all packages listed below (as long as they are installed on your system) with their original versions (make sure to replace the packages all in one go to prevent potential dependency errors: pacman -S <package1> <package2> ...):

  • freetype2-infinality-ultimate -> freetype2
  • lib32-freetype2-infinality-ultimate -> lib32-freetype2
  • fontconfig-infinality-ultimate -> fontconfig
  • lib32-fontconfig-infinality-ultimate -> lib32-fontconfig
  • cairo-infinality-ultimate -> cairo
  • lib32-cairo-infinality-ultimate -> lib32-cairo
  • jdk8-openjdk-infinality -> jdk8-openjdk
  • jre8-openjdk-infinality -> jre8-openjdk
  • jre8-openjdk-infinality -> jre8-openjdk-headless

If for some reason you don't want to install pkgbrowser, you can also use pacman -Sl <repository> and pacman -Sg <group> (for example: infinality-bundle, infinality-bundle-fonts etc.) to list packages belonging to repositories and groups (and their installed-state marked by [installed]) respectively. pacman -Qi <package> can be used to get more detailed information on an installed package, such as the "Conflicts with" field.

If you explicitly installed fonts or font groups (for example ibfonts-meta-extended) from the infinality-bundle-fonts repository it is advised that you remove these, since some of them were specifically patched to work with the modifications the infinality-bundle made to the various packages mentioned above. The pkgbrowser tool is useful during this process: mark the infinality-bundle-fonts in the sidebar and sort using the Status column, remove those that were explicitly installed using: pacman -Rns <package>. If you simply installed ibfonts-meta-extended or a similar group of fonts, pacman -Rns ibfonts-meta-extended will have the expected effect.

After doing this, refresh the view in pkgbrowser using F5 and sort again by status. It is quite possible that still some packages are left which are marked as dependencies: these are packages that were most likely installed as dependencies by other packages, before you started using the infinality-bundle and subsequently replaced by Infinality-specific versions. For these, select them and search for the fields "Conflicts with" which should give you a good idea which package they originally replaced. The goal is to replace the Infinality-specific versions (ending in -ibx) with the original ones. For example:

  • t1-urw-fonts-ib conflicts with gsfonts: pacman -S gsfonts (answer yes to replace)
  • ttf-dejavu-ib conflicts with ttf-dejavu: pacman -S ttf-dejavu (answer yes to replace)

After taking care of all packages, no packages should be installed anymore when you check infinality-bundle, infinality-bundle-multilib and infinality-bundle-fonts in the sidebar. Your system should now be in a pre-infinality-bundle state.

Creating an Infinality-like fontconfig Configuration

From this clean slate we can now create a similar fontconfig configuration to the infinality-bundle's without having to use the patched packages. Thanks to a few comments on previous versions of this article, it is now possible to easily get great-looking results with the default freetype2 truetype interpreter.

  1. Create the following symlinks using root to instruct freetype2 to use good-looking rendering defaults:
  • ln -s /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d
  • ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d
  • /etc/fonts/conf.avail/10-hinting-slight.conf should already be linked to /etc/fonts/conf.d

Modify (or create) /etc/fonts/local.conf to contain these contents. These are all font substitutions originally made by Infinality's fontconfig configuration. A big thanks to tylerswagar for creating the font substitution snippet! Alternatively run: ln -s /etc/fonts/conf.avail/30-infinality-aliases.conf /etc/fonts/conf.d after installing fonts-meta-extended-lt in step 2; DoctorJellyFace, the maintainer of the fonts-meta-extended-lt package, decided to make the substitution snippet part of the package.

  1. Now we need to actually make sure that we have all fonts on the system that were defined as substitutions earlier. Install the package fonts-meta-extended-lt from the AUR, which will help us install and keep track of which fonts are required to do this. Fonts that are defined as optional dependencies for this PKGBUILD are those that are not yet available in the AUR. A big thanks to DoctorJellyface for creating these AUR packages and maintaining them!

Install all optional dependencies of the fonts-meta-base and fonts-meta-extended-lt package. Do this by running pacman -Qi fonts-meta-base fonts-meta-extended-lt and noting the entries listed unter "Optional Deps". Then install them using pacman -S <optdep1> <optdep2> ... --asdeps. Currently missing optional font packages in the AUR are t1-cursor-ib and ttf-gelasio-ib. Mirrors to these packages (exactly as they were contained in the, now offline, infinality-bundle-fonts repository) are here:

You can install these using pacman -U <filename> --asdeps.

  1. Modify /etc/profile.d/jre.sh if you had the patched openjdk/openjre packages installed to look like this:
# Do not change this unless you want to completely by-pass Arch Linux' way
# of handling Java versions and vendors. Instead, please use script `archlinux-java`
export PATH=${PATH}:/usr/lib/jvm/default/bin

# https://wiki.archlinux.org/index.php/java#Better_font_rendering
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true'

This will enable font anti-aliasing for Java applications according to the instructions found here. Without these, fonts in Java applications will look completely aliased, unless a different provider for java-environment is used which might implement different font rendering.

  1. After having done all this, restarting the X-server by logging in and out should apply all changes. Try to get used to them, because the future of the infinality-bundle is unknown for now. Keep an eye on this and this and maybe this "guide" if you are curious about changes.

You should also consider checking /etc/fonts/conf.d/ for broken symlinks pointing to /etc/fonts/conf.avail.infinality/..., that might have been left by the fc-presets script if you ran it, and removing them to be thorough. Finally, you can remove the various infinality-bundle* repositories from your /etc/pacman.conf.

@funn
Copy link

funn commented Feb 1, 2017

@morealaz
Looks like the only new thing that package introduces to this configuration is embeddedbitmap line, which was already mentioned by @jaro3:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
	<match target="font">
		<edit mode="assign" name="antialias">
			<bool>true</bool>
		</edit>
		<edit mode="assign" name="embeddedbitmap">
			<bool>false</bool>
		</edit>
		<edit mode="assign" name="hinting">
			<bool>true</bool>
		</edit>
		<edit mode="assign" name="hintstyle">
			<const>hintslight</const>
		</edit>
		<edit mode="assign" name="lcdfilter">
			<const>lcddefault</const>
		</edit>
		<edit mode="assign" name="rgba">
			<const>rgb</const>
		</edit>
	</match>
</fontconfig>

@moralrecordings
Copy link

moralrecordings commented Feb 6, 2017

Worth mentioning is that there's still a cairo-infinality package that's worth installing; I noticed this when monospaced fonts rendered in GNOME Terminal were hinted a pixel shorter than in GVIM. The reason for this is (of course!) a ten year old bug in Cairo's font hinting switcher that was fixable in 4 lines of code. Except someone well-meaning offered to rewrite the whole thing, guaranteeing that no-one would ever want to review it for fear of breaking every GTK app!

@ctjhoa
Copy link

ctjhoa commented Feb 7, 2017

In addition, you also can delete bohoomil key with pacman-key -d 962DDE58 as there is no reason to keep an inactive key in your keyring.

@exentio
Copy link

exentio commented Feb 10, 2017

Hi, I tried following the guide, being sure to follow every single step, but my font rendering looks awful.
I tried a lot of fixes but nothing changed. Telegram, Transmission-qt and jDownloader look fine, instead. Also, my bitmap fonts are not being recognized. Can anyone help me?

@cryzed
Copy link
Author

cryzed commented Feb 11, 2017

@exentio: Hey, it's possible that you have configuration files in /etc/fonts/conf.d activated that have strange effects. It might be interesting to check where the symlinks in that directory point to, and checking the owner of each symlink with pacman -Qo -- this might give you an idea where the problem lies.

However, to me it kind of looks like all or some of the settings are simply not activated. I would almost say that your /etc/fonts/conf.d directory is either completely missing or inaccessible -- is that possible?

@exentio
Copy link

exentio commented Feb 11, 2017

@cryzed I checked all the symlinks and it doesn't look like there are broken links. If you're curious, this is the output of ls -l /etc/fonts/conf.d and this of ls -l /etc/fonts/conf.avail. pacman -Qo's output on both folders doesn't look like something is broken, but in case, here it is

@cryzed
Copy link
Author

cryzed commented Feb 11, 2017

@exentio yeah that looks fine... I'm a bit puzzled now too. Is your fontconfig at 2.12.1-4? Does a /etc/profile.d/freetype2.sh exist? If so, what are its contents (try removing the file)? This is a long shot, but maybe simply try reinstalling fontconfig: pacman -S fontconfig. Also is it possible that your DE/WM has created files that override the global fontconfig with a local one here: $XDG_CONFIG_HOME/fontconfig/? Also what are the directory permissions on /etc/fonts/conf.d and /etc/fonts/conf.avail -- you showed me their owners, but not the permissions like you did with their contents.

Sorry I'm just guessing wildly at this point. You made sure to restart X at some point, yes?

@exentio
Copy link

exentio commented Feb 12, 2017

@cryzed fontconfig 2.12.1-4 is installed, and /etc/profile.d/freetype2.sh looks fine. There isn't any local variable for font config, neither any fontconfig folder in my .config or in .local/share. Permissions on both folders are rwx r-x r-x. I obviously restarted X, updated GTK cache (I assume this is a problem of GTK because Qt and Java apps work fine), also rebooted and updated the whole system. But, I noticed that LightDM with the GTK greeter looks fine (but with the wrong font because bitmaps are not being recognized), so maybe it could be just something in my config, but I don't really know what

EDIT: Ok, problem solved, apparently something in .Xresources was the problem. My bitmap fonts still aren't being recognized, but I can fix it

@cryzed
Copy link
Author

cryzed commented Feb 12, 2017

@exentio It's possible that your bitmap fonts aren't being recognized due to the update to the latest freetype2 version, which prefixes some fonts with their foundry name. Google "freetype2 xos4" for more information on this issue -- good luck!

@debiansid
Copy link

debiansid commented Mar 3, 2017

which xwindow manager can do this better? My xfce4 still not great at terminal on Lenovo X61

@roshhh
Copy link

roshhh commented Mar 13, 2017

Thanks for this article. Just switched to arch from Ubuntu and the fonts are horrible. Once I've installed this any fonts that are not listed in the folder come out with random spacing. Is there any way to configure other fonts to work?

Copy link

ghost commented Mar 19, 2017

t1-cursor-ib is no more an optional dependency. I don't know if this is okay, just for your information.

@dbouras
Copy link

dbouras commented Apr 24, 2017

While playing around with openSuse Leap 42.2 for the past few days (zypp-upgrading from 13.1 was quite a journey :)) I also ran into issues with newer freetype releases and the absence of Infinality. For those of you who would rather not delve into the intricacies of font configuration files I suggest:

a) finding a freetype build with sub-pixel rendering enabled, and
b) installing the fontconfig-infinality scripts that exist as a stand-alone package

In my case, for (a) I switched fontconfig and freetype packages to the following (e.g. save as "/etc/zypp/repos.d/Subpixel_Repository.repo"):

[Subpixel_Repository]
name=Subpixel Repository
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/repositories/home:/gldickens3/openSUSE_Leap_42.2/
path=/
type=rpm-md
keeppackages=0

For (b) I installed fontconfig-infinality from (pick your distribution from the list):
https://software.opensuse.org/package/fontconfig-infinality

Don't forget to run infinality-ctl setstyle (as root) for choosing your preferred rendering "style".
With hopes that the above will help.

@Anton-Kapustin
Copy link

Anton-Kapustin commented Aug 11, 2017

wonderful! I get great fonts in Debain)) Thanks!

@mashwell
Copy link

mashwell commented Nov 6, 2017

FYI: currently, ttf-impallari-cantora AUR package no longer builds (the source URL is down). I found a package someone else compiled and installed it --asdeps. Also used changed freetype2.sh to use 'infinality' autohinter and enabled autohinting. Everything else works fine!

@pluehne
Copy link

pluehne commented Nov 16, 2017

@cryzed: Instead of “restarting the X-server by logging in and out should apply all changes” at the end of the article, it should read “restarting the X-server by logging out and in should apply all changes.”

@atemate
Copy link

atemate commented Feb 13, 2018

In my case the following helped: get rid of all infinality-packages + call gdk-pixbuf-query-loaders --update-cache

Copy link

ghost commented Feb 20, 2018

@mashwell can you provide that package? I cannot find it anywhere.

@raku-cat
Copy link

raku-cat commented Mar 22, 2018

I've been having a problem with java apps where the text is missing completely or is obscured and menus, buttons, etc are all stretched or squished seemingly out of nowhere, I eventually reinstalled arch even to fix it, which upon first boot a test worked, and then it started popping up again. I finally realized it was because of my /etc/fonts/local.conf which I recall at one point basing off this guide, which is why I'm here. I'll edit this with a link to the config file later today, but any help would be appreciated.
Edit: here's the local.conf https://gist.github.com/raku-cat/7c33c945ba007184f35925c313269f08

@onotype
Copy link

onotype commented Mar 28, 2018

Really grateful for this. My eyes are rejoicing!

I was wondering if anyone else is having problems with monospace fonts though: in the local.conf, monospace should use Liberation Mono but it's not doing that. After some digging, I found out that it's using Courier Prime, which is confirmed by fc-match monospace. Doing fc-match -s monospace lists Liberation Mono as the second font with Courier Prime as the first. I'm not sure where it's being defined at all.

@darthdebitux
Copy link

darthdebitux commented Apr 10, 2018

@Revc3654: also source=("https://fontlibrary.org/assets/downloads/cantora/4406a0c9a8ee2a4de1352e74f0640bb7/cantora.zip").
Don't forget to change md5sum... :-)

@jlouiss
Copy link

jlouiss commented Sep 15, 2018

Thank you very much. I was pretty much desperate about my font situation. Now it works perfectly 👍

@zaknafein99
Copy link

zaknafein99 commented Nov 15, 2018

Nice walkthrough!
Ihave one problem, after installing and configuring everything I ended up with my i3blocks bar showing no colored icons, just lines with the same color as text. Is there a way to restore the appereance of said icons?

Screenshot: https://imgur.com/a/q72OS23

@knowhy
Copy link

knowhy commented Jan 3, 2019

Thanks a lot. Only now I realize how much I missed good fonts. I have automated the steps with Ansible if anyone is interested in automating this process.

@jibarofoss
Copy link

jibarofoss commented Dec 20, 2020

I tried following this guide and now I have the same problem as I would have with infinality (arch won't make it to the DE) except now I don't know how to solve it!

@alEXE-tech
Copy link

alEXE-tech commented Mar 20, 2021

For those like me who went through the process of removing the infinality repo, removing dead symlinks, and replicating its functionality in freetype, you may be wondering why sites in your web browser still don't look like you remember. This is because infinality applied a set of font aliases and replacements.

After going out and finding all the fonts needed (no small task as many were missing from the AUR; scour Google as needed, but special thanks to DoctorJellyface for providing a metapackage for the ones already in Arch), I combined the list of fonts from bohoomil's site with a guide I found on setting font defaults. This is now what my giant /etc/fonts/local.conf looks like:

http://pastebin.com/pKg2JeTT

Maybe there was an easier way to do this, but it feels like home again. No more squinting to read my Facebook feed. I didn't go through the extra effort of tracking down the infinality-bundle-fonts-extra group, so if you really need Baskerville, modify as needed.

Added this as well as followed the advice in the link below to add the java option listed in /etc/profile.d/jre.sh directly in the Java Runtime Environment /etc/environment and everything is rendering smoothly. Currently using FiraCode font w/ ligatures.

https://wiki.archlinux.org/index.php/Java_Runtime_Environment_fonts

@Pillgar
Copy link

Pillgar commented Mar 31, 2021

Looks like the original location /etc/fonts/conf.avail/ for the symlinks got moved to /usr/share/fontconfig/conf.avail/.

Would this be the new symlink to use?
ln -s /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d
ln -s /usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d

Using Arch BTW.

@gbc921
Copy link

gbc921 commented Dec 2, 2021

Would this be the new symlink to use?
ln -s /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d
ln -s /usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d

I agree with @Pillgar too (here on Arch as well)

@ramon501
Copy link

ramon501 commented May 30, 2022

I had to remove the old symlinks and create new ones as suggested by @Pillgar
It works fine here now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment