Category: Fonts


This patch makes Freetype's (http://www.freetype.org) Truetype interpreter render fonts similarly to MS Cleartype.  It is not perfect, and needs some work on certain fonts, however, in my opinion it renders much, much better than the bi-level Freetype hinting does when doing subpixel rendering.  Anything previous to this that I've worked on is simply a hack.  This is the real thing finally.

This patch is different than all previous so-called "cleartype fixes" for Linux.  The reason is that the MS truetype interpreter does subpixel filtering, but also subpixel hinting, which has never been done before in Freetype.  ("Subpixel hinting" means that the outlines of the letters are rounded to subpixel boundaries instead of pixel boundaries.  "Subpixel filtering" means that the part of the renderer that chooses which pixels to light up does so with the idea of subpixel boundaries instead of pixel boundaries.)   The Freetype library has hitherto only done subpixel filtering, and WHOLE pixel hinting.  This looks great when using non-antialised fonts (circa Win98), but looks bad on legacy fonts when doing antialiasing and subpixel filtering, because the legacy fonts were designed with the idea of bi-level (monochrome) hinting in mind, not subpixel (antialiased) hinting.  The MS TT interpreter in Windows XP and later works around this by ignoring certain Truetype instructions contained in the font.  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 this is modifying the default (native) hinter of Freetype, which all programs should use by default.  This means that oo.org, WINE, Xft, Qt and just about everything else will be using this by default.  In other words, almost all programs will render fonts the same good way.   

Please feel free to make suggestions and criticisms of the approach and implementation. My goal is to make this patch quality and accurate, and get it into the freetype tree if possible. There are plenty of improvements that can still be made, in features and implementation.   This is an all-in-one patch that should cleanly patch freetype-2.4.2, enable LCD filtering, subpixel rendering, and the new subpixel hinting.


Latest Versions (2010-09-06)

strongly recommended to:

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

 


(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)  PACKAGE AND PATCH 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:

My /etc/fonts/local.conf

Here is the current version of my local.conf file.  

 (2010-08-29)  I updated this to clean up some inaccurate comments, as well as streamline a few things.  Not a major change.

 (2010-08-16)  This assumes use of my subpixel hinting patch or package for freetype!  It also assumes that you are not using a ~/.fonts.conf file.  If you have one, you can disable it by doing:  mv ~/.fonts.conf ~/.fonts.conf.disabled.

 (2010-09-03)   This is updated to reflect changes in my patch located here (http://www.infinality.net/blog/?p=67).  I've fixed some replacements for fonts that just suck, and removed replacements for bold fonts, given the new enhancements to the freetype synthetic emboldening.

This is a really old version of my .fonts.conf.   I'm leaving it here, as I think it may be useful to some people.

Font Testing Page

 I use this page to visually check fonts.  It’s kinda hacky and sloppy but it works.  Maybe it would be useful to others, so I’m linking it:

http://www.infinality.net/files/font.html

As part of my quest for "perfect" fonts in Linux on my LCD monitor, I stumbled across some patches that David Turner of freetype.org put out in 2006.  They modify cairo and libXft to use significantly better subpixel rendering techniques.  The patches I found to work were from Jaganath's page.  I started getting annoyed when I would update Fedora and these libraries would be overwritten, requiring me to download, patch and recompile updated source code.  So, I figured out how to make RPM packages instead, which suprisingly took very little time to figure out and are much more portable and generally easy to deal with.  In many cases, the rendering now looks superior to any other OS I've seen.  Jim Bevenhall's page provides similar packages.

For Fedora 11, I have redesigned how the packages work.  They used to replace the original packages.  Now, they use ldconfig to override the existing packages.  This makes installation and uninstallation a breeze, and Fedora updates to the original packages shouldn't stop the modified packages from working.  I chose the suffix "freeworld" because it seemed like that is the agreed upon suffix in the FOSS world for stuff like this.  I am no longer providing the freetype packages, as those are already available at rpmfusion.org.  Once you install rpmfusion, you would do this:

yum install freetype-freeworld.i586
yum install freetype-freeworld.x86_64       (if you are running x64, I recommend installing both)

Then, download these packages and in the download directory do:

yum install *.rpm

If running x86_64, I recommend installing x86_64 and i386 packages, in case you have some x86 binaries that you would also like to look nice.
 
Update June 13, 2009:  Due to problems with some application startup scripts overriding ldconfig with forced LD_LIBRARY_PATH settings, I've added LD_PRELOAD functionality to /etc/profile.d/ in these packages.  It should make more applications use the better rendering, but may spit out errors when it can't load a library for various reasons.  If you don't want this LD_PRELOAD functionality, create a file /etc/sysconfig/fonts with PRELOAD=0 in it.  Also, the cairo packages include LD_PRELOAD functionality for the freetype from rpmfusion.org, as I assume anyone installing these packages also will be installing the modified freetype (otherwise it's pretty pointless ;) )
 
Update June 17, 2010:  Fedora 13 Packages are available!

 
 
 
Source RPMs for those interested in building the package themselves:
 
 

Keep in mind that the cairo packages also have an additional tweak to make them respect fontconfig settings (~/.fonts.conf and/or /etc/fonts/local.conf). This means that hinting type, antialiasing, etc. must be configured through those files, not through gnome-appearance-properties.

Sample Image:

Fedora 12 RPMS

Fedora 12 RPMS have been added to the repository.  QtCurve-common package is now obsolete, as it is included in the gtk2 package.  This gets past some goofy dependency issues.   Let me know if you experience any issues with the F12 packages!

http://www.infinality.net/fedora/linux/

http://www.infinality.net/fedora/linux/

I've created a repository for my posted rpms, for both my and your convenience.  I'm still working out how to get Apache indexes turned on so it looks normal-  for some reason they aren't working, even when the .htaccess is set up properly.  I have some poor man's indexes I created from a shell script though, so it's now browseable.   Currently it has RPMS for Fedora 11, 12 and 13.

Install this file and you can then do stuff like "yum install cairo-freeworld libXft-freeworld qtcurve*".  I can't guarantee this will always be up to date, but I'll try to keep it as current as I keep my own system.

 

Last updated on June 17, 2010.

infinality-repo-1.0-1.noarch.rpm

Please see http://www.infinality.net/blog/?p=67

 

(I recently posted this on the Wine Bug List here:  http://bugs.winehq.org/show_bug.cgi?id=16745    They seem unwilling to implement it.)

This patch is an attempt to use fontconfig (specifically, what is defined in /etc/fonts and/or ~/.fonts.conf) to handle the hinting and replacements of fonts. This should allow the end user to make WINE programs appear more integrated with the rest of the desktop, if they choose to enable it.  

The general idea is to inject the fontconfig data at the step in WineEngCreateFontInstance prior to opening the font face. This allows the GdiFont to be satisfied that it is getting the face it requested, and also rendering it the way fontconfig says to. This method still allows for the font replacement mechanism in WINE to work, as this works beneath it, not trying to compete with it. The fontconfig data and load flags for freetype are stored in tagGdiFont, and the load flags are then used in the rendering step. Also, Fontconfig initialization was brought out into a separate function, as fontconfig is now used in more than one place.

As I figured people may not want this on by default, it can be enabled by setting this DWORD registry key:
HKCU\Software\Wine\Fonts\UseFontconfig = 1

If fontconfig is not available, the code is #ifdef’ed out, and if turned off in the registry (default), WINE uses its normal behavior.

I am not a bigtime C coder, and this is my first patch that deals with WINE, freetype, and fontconfig. So, there may be memory leaks that need fixing, as well as poor coding practices and errors. ;) I have not attempted to handle every type of configurable feature in fontconfig, just hinting and replacements, as those are the most major things. I am basically just a guy who wanted this feature hard enough to go about figuring out how to do it myself.

This patch is against freetype.c from 1.1.12. I welcome any suggestions and modifications to this patch, and info on how to get this into the development version of WINE.

 

wine-respect-fontconfig.patch


  

I’ve been searching for this for almost a year.  I found someone’s solution here:  https://bugs.launchpad.net/ubuntu/+bug/161058    Gnome and GTK+ apps never respected my per-font hinting settings in .fonts.conf which drove me totally bonkers.  Apparently, what causes them to ignore the hinting settings is actually cairo’s fault, from is this lowly line in cairo-ft-font.c:

if (options->base.hint_style == CAIRO_HINT_STYLE_DEFAULT)

Commenting it out:

// if (options->base.hint_style == CAIRO_HINT_STYLE_DEFAULT)

…will cause cairo to now RESPECT MY AUTHORITA.  I’ve provided a source rpm for F8 as well as a patch file for directly patching the source.  Enjoy!

Powered by WordPress | Theme: Motion by 85ideas.