NOTE: Go here for the current patches. The instructions here are not valid anymore! I'm keeping them here for historical reference.
Simply speaking, this patch makes Freetype's (http://www.freetype.org) Truetype interpreter perform Truetype hinting instructions in the Y direction only, and skip the X direction. This produces a nice visual result at smaller resolution, like those typical at sizes commonly used on the computer screen. This patch is not perfect, and needs some work on certain fonts, however, in my opinion it renders much, much better than the native truetype hinting contained in legacy fonts.
The truetype instructions in legacy fonts were designed with the idea of bi-level (monochrome) hinting in mind, not subpixel (antialiased) hinting. To make these fonts display nicely in the subpixel world, the MS TT interpreter in Windows XP and later works around this by ignoring certain Truetype instructions contained in the font (probably among other things). This patch attempts to duplicate that functionality. Modern free fonts like Liberation and DejaVu also look good with this too, because they were designed with subpixel hinting in mind.
Another benefit to this is that it is modifying the default (native) hinter of Freetype, which all programs would use by default (if not overridden by other fontconfig settings). This means that oo.org, WINE, Xft, Qt and just about everything else will be using this by default, and rendering fonts the same good way.
There are a few patches I'm providing here, and Fedora packages that implement them. Also, in case it isn't clear yet,
*** THIS IS ALPHA/BETA SOFTWARE. EXPECT BUGS / CRASHES. ***
Latest Versions (2011-06-28)
(2011-06-28) Fedora package update only, to freetype-2.4.5. The patch is exactly the same as the 20110604 version. I had to use some trickery with version numbering due to a poor choice I made on the last package. Please report any problems in the forum.
(2011-06-04) ACTION REQUIRED - Finally, you have your update! There are a lot of (nice) changes in this one. Specifically, stem alignment has been greatly improved, and ChromeOS style sharpening has been added. Slight hinting can now be forced. Also, due to the localization problems people were having with commas vs. periods for decimals, all environment variables now use integers, generally between 0 and 100. Please see the file http://www.infinality.net/files/infinality-settings.sh . There are environment variables that have been modified since the 2010-11-14 release and are required in order to enable various functionality. The Fedora package infinality-settings (formerly fonts-config) contains the file automatically, at a system-wide level, and I strongly recommend you install it using yum. It will save your existing configurations at *.rpmsave files, so you can diff them with the new ones. Others will need to download it here: http://www.infinality.net/files/infinality-settings.sh . Also, note that this is based of FREETYPE-GIT, as of today. So, it may be buggy, or may have nice new features. Your mileage may vary. Only Fedora 15 packages are provided. Sorry, I'm having issues compiling anything else at the moment! Also, the code is pretty messy and embarrassing. Don't look at it yet. ;) Comments, issues and bug reports (and compliments! ) can go here: Infinality Forum
(2010-11-16) Something that may need to be called out for this release- IT DEPENDS ON LIBMATH.
I patched the configure file to force LDFLAGS to "$LDFLAGS -lm" but perhaps this dependency still needs to be called out which is why I am posting this.
All below patches are included in the Fedora packages (the local.conf and infinality-settings are contained in the Fedora fonts-config package, the rest are in freetype-infinality):
- Subpixel Hinting Patch (2011-06-04) - This adds the Truetype subpixel hinting functionality to Freetype.
- Subpixel Hinting Enabling Patch – This enables the above functionality.
- Entire (Additional) Infinality Patchset (2011-06-04) – This is now in a single patch. It includes each of the below, which can be modified at runtime using environment variables (See the patchfile for details).
- Fontconfig Settings (2011-06-04) - The local.conf (or copy to ~/.fonts.conf for per-user settings). This has been updated to handle different OS styles. See the file for details.
- Environment Variables (2011-06-04) - This is required to configure each of the features at runtime:
- Emboldening Enhancement - Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.
- Auto-Autohint - Automatically forces autohint on fonts that contain no TT instructions.
- Autohint Enhancement - Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).
- Customized FIR Filter - Select your own filter values at runtime. Works on native TT hinter and autohinter.
- Stem Alignment - Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.
- Pseudo Gamma Correction – Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.
- Embolden Thin Fonts – Embolden thin or light fonts so that they are more visible. Works on autohinter.
- Force Slight Hinting – Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.
- ChromeOS Style Sharpening – ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.
Recommendations
I strongly recommend to do these things:
For system wide results:
- Use this /etc/fonts/local.conf (…or use it as a template… or know what you are doing otherwise) (Updated 2011-06-04)
- Alternatively, you could install my infinality-settings package located in the infinality repository. (Updated 2011-06-04)
- Disable your ~/.fonts.conf by removing everything inside the
<fontconfig>[REMOVE ME]</fontconfig>tags. Then as root do:chattr +i /home/YOUR-USERNAME/.fonts.conf
For just your user:
- Save this /etc/fonts/local.conf as ~/.fonts.conf (…or use it as a template… or know what you are doing otherwise)
In either case:
- Install Windows, Apple and Google fonts. You can find sources for these online. You will want to stick to the most recent version of these fonts (e.g. Use the versions in Vista or Windows 7 and latest OSX).
- If you are running a Fedora below 14, use cairo and libXft packages that make use of LCD FIR filtering (such as the ones here: http://www.infinality.net/blog/?p=5 )
- Have these in your ~/.Xresources:
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.dpi: 96
Xft.rgba: rgb
Please make sure you have done these things before asking why something isn't working. Here is a good resource that explains how to set up and modify a /etc/fonts/local.conf to your personal taste:
http://wiki.archlinux.org/index.php/Font_Configuration
Planned Future Enhancements
- Rewrite of the rule structure and further refinement of hinting rules
- Add and remove pixels to advance width of glyphs
- Additional fonts and features added to local.conf
- Possibly – Patches for fontconfig and XFT to make more freetype features configurable.
- Get bold fonts and larger regular fonts to snap to pixels in better ways.
News and Update Details
(Updated 2011-06-04) Major PATCH AND PACKAGE UPDATE - Enhanced stem alignment routines. Fixes for localization issues. New sharpening features. Forced slight hinting.
(Updated 2010-11-17) PACKAGE UPDATE - Fix for the "missing fonts" issues that some people seem to be having.
(Updated 2010-11-14) Major PATCH AND PACKAGE UPDATE - See the top of each patchfile for details.
(Updated 2010-10-22) PATCH AND PACKAGE UPDATE - See the top of each patchfile for details.
(Updated 2010-10-19) PACKAGE UPDATE - Due to popular demand, there are now Fedora 13, 14, and rawhide packages in the repo. I can't test the 14 and rawhide ones yet so let me know if there are problems. Also, I have normal apache indexes working when you browse the repo. No new functionality, just new packages.
(Updated 2010-10-16) Autohint enhancement patch: http://www.infinality.net/blog/?p=208
(Updated 2010-10-08) PATCH AND PACKAGE UPDATE - Ok, no, really. This time it is fixed!
(Updated 2010-10-08) PATCH AND PACKAGE UPDATE - Fixes crashes in PDF and certain webpages. No new functionality.
(Updated 2010-10-04) PATCH AND PACKAGE UPDATE - Updated for freetype-2.4.3.
(Updated 2010-10-03) PATCH AND PACKAGE UPDATE - See the top of each patchfile for details.
(Updated 2010-09-16) PATCH AND PACKAGE UPDATE - Reverted the slight hinting change from previous patch due to issues. Old behavior is back. See patch for more details.
(Updated 2010-09-14) PATCH AND PACKAGE UPDATE - (DESPITE MY INTENTIONS, IT SEEMS THIS PATCH (or my local.conf) HAS BROKEN AUTOHINTER IN SOME APPS (like Chrome). I WILL INVESTIGATE AS SOON AS I CAN) I will attempt to keep a changelog in the patch from now on. This is what is in the patch. Please see the patch for more details! In preparing this patch, I think I accidentally stumbled on something that makes some fonts look better. See Times New Roman with this patch!
(Updated 2010-09-09) PATCH AND PACKAGE UPDATE - This update adds functionality to tweak the truetype interpreter's subpixel hinting on a font-by-font, size-by-size, and glyph-by-glyph basis (pre-compile). It also formalizes this patch into something that could be merged into freetype, by following the freetype coding conventions better. Packages have been updated to use this patch, and include the emboldening patch as well. In honor of the possibility that this code will soon be merged into freetype, I've changed the name of the packages from freetype-subpixel to freetype-infinality. The new ones should automatically replace and obsolete the old ones. The name change underscores the fact that eventually my packages will simply be turning certain macros on and off in the freetype code, or small code tweaks to fit my preferences, as opposed to providing some extended functionality. Also, I've done some minor updates to the local.conf file.
(Updated 2010-09-07) PACKAGE UPDATE - This update fixes selinux issues. If you have selinux disabled or warning only, you don't need this.
(Updated 2010-09-06) PACKAGE UPDATE – This update fixes the LD_PRELOAD issues in the recent packages. Let me know if problems continue! Also, I will soon have an updated patch that will be cleaner, allow enabling / disabling with a #define macro, and some additional features, including the ability to tweak the hinting on specific fonts, sizes, and glyphs. I will then see about submitting it to Freetype.
(Updated 2010-09-03) PATCH AND PACKAGE UPDATE – This version includes updates that the Gentoo people did for 2.4.2 (http://forums.gentoo.org/viewtopic-p-6350322.html#6350322), as well as a tweak that I made on the synthetic emboldening that Freetype does. This should make synthetically emboldend fonts look spectacular compared to the default. Basically, it disables emboldening in the Y direction, which was causing a lot of smeary looking fonts. Here is a sample of this enhacement, using Andale Mono, which has no bold version available:

http://www.infinality.net/fedora/linux/13/x86_64/freetype-subpixel-2.4.2-2.fc13.x86_64.rpm
http://www.infinality.net/fedora/linux/13/i386/freetype-subpixel-2.4.2-2.fc13.i386.rpm
http://www.infinality.net/files/subpixel-hinting-20100903-1.patch
(Updated 2010-06-17) http://www.infinality.net/fedora/linux/13/x86_64/freetype-subpixel-2.3.12-3.fc13.rpm Also…. It's strongly recommended to use this /etc/fonts/local.conf, and to remove/disable your ~/.fonts.conf, not to mention using the cairo and libXft packages available at that link.
(Updated 2010-04-24) http://www.infinality.net/files/subpixel-hinting-20100424-1.patch
There are a few more tweaks I need to make the patch acceptable for inclusion into Freetype. In the meantime here are the Fedora 13 RPMS. They safely install alongside the system freetype, and use LD_PRELOAD to override system libraries. You may get LD_PRELOAD warnings / errors when running from command-line. These will go away eventually once this patch is in freetype.
Here is a DejaVu Sans sample, rendered with Freetype, using this patch:

Here is a Tahoma sample, rendered with Freetype, using this patch:

Here is an Arial sample, rendered with Freetype, using this patch:

Here is a Liberation Sans sample, rendered with Freetype, using this patch:

