Skip to content

Instantly share code, notes, and snippets.

@cryzed
Last active January 19, 2024 08:56
Show Gist options
  • Save cryzed/e002e7057435f02cc7894b9e748c5671 to your computer and use it in GitHub Desktop.
Save cryzed/e002e7057435f02cc7894b9e748c5671 to your computer and use it in GitHub Desktop.
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.

@debiansid
Copy link

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

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

@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

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

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!

@al-dot-exe
Copy link

al-dot-exe 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

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