Dec 19 2006
03:45 GMT
03:45 GMT
Autohinting, Hinting, Bytecode Interpreting: Freetype2 Clarifications .02$ 

Updated Feb. 5, 2007
During the last 3 years, I could read dozens of articles on font hinting and auto-hinting, the patent-bound Bytecode Interpreter, smoothing, anti-aliasing and subpixel rendering, and whatever else you might want to say about "the optimal use of fonts in Linux".
This is not only boring and confusing for the newbies, it's also unnecessarily complicated by overzealous people.
Let's try to expose the whole story.
§
We need to define in very plain language some overused (and often misused) terms:
§
Under X, the freetype2 is responsible for rendering the fonts in a pleasant way for your eyes.
§
Here's a recent post about this: Enable Smooth fonts on Ubuntu Linux. It simply copies the info about auto-hinting posted more than two years ago, here: Change font hinting settings.
The topic "pollutes" the Internet, and you can't find clear and consistent recommendations about how to fix it (neither this article will give you one). Here's another set:
Let's try to put some things straight.
§
How can you take care of how your fonts are looking like? Again, there is more than one way to do this.
§
The topic will be long, but this isn't my fault. Now, most articles recommend you to use per-user configuration settings, in ~/.fonts.conf. I would rather go with global settings, which can be read from:
Here's a sample contents took from a Debian machine:
/etc/fonts/conf.avail/ is more generous, containing mutually exclusive options, so you could link to the one you want:
As a personal recommendation, you should use this kind of settings:
IMPORTANT! The auto-hinting was designed independently and is unconnected to the "regular" TrueType hinting. In my opinion, there is little to gain if you enable it as long as the "regular" hinting is used. The default options with most freetype2 packages should be:
§
In my opinion (your mileage may vary), the problems when using the highly-acclaimed Bytecode Interpreter don't only rely in the need to recompile the package with the option:
§
Configuring the fonts appearance in KDE is pretty much straightforward:


Compared to GNOME, it also offers the option to exclude a range of (presumably small fonts) from anti-aliasing, so this should be all you need.
To my taste, the way fonts look under KDE in a freshly-installed Slackware 11 (Bytecode Interpreter OFF) is close to perfect even on LCDs.
§
Configuring the fonts appearance in GNOME is rather against the spirit of simplicity that reigns in the GNOME land: the two dialog boxes seem simple enough, but their functionality overlaps.


The first temptation (and the subsequent ones too...) is to select a rendering option in the first dialog, then to go to "Details" to customize it with regards to smoothing and hinting. Few people notice that the four choices in the first dialog map to predefined combinations in the second one!
Here's how things are:
To be frank with you, I don't like the subpixel stuff, because I can see the colors! The gray scale is just fine, thank you. The worst incarnation of the subpixel idea is the ClearType(TM) thingie from Microsoft. When I first saw it in Microsoft Reader, I only thought it was a dumb thing: was it only me to clearly see the annoying colored outlines even on CRTs?! Much later, when I saw the overemphasized ClearType in Internet Explorer 7 Beta, I simply could not read the displayed pages! (It took me a while to see how to disable the ClearlyTheWrongType.)
§
I will put now, for comparison purposes, sample texts under different rendering methods. Since showing them at 1:1 (100%) wouldn't make much of a difference, I scaled them up to 200%. Note that this will make them look slightly better than in reality, because the resize algorithm uses a certain amount of smoothing itself, but you will spot the differences anyway.
No smoothing, no hinting:
No smoothing, no hinting, but auto-hinting enabled (it's even worse!):
Best contrast:
Best contrast, plus auto-hinting enabled:
Best shapes:
Best shapes, plus auto-hinting enabled:
Subpixel smoothing (LCDs):
To me, if it's not "Best contrast" the best looking, it's then "Best contrast + Auto-hinting". But again, YMMV, and your eyes are not my eyes.
§
A quick note on Ubuntu and Debian. As stated here, in recent versions of Ubuntu, reconfiguring
§
A last part hosts some rants on Dropline GNOME over Slackware 11 and fonts. Someone asked me a pertinent question as a comment to another post: «with so many packages changed from the stock 11.0, does KDE still work properly?»
Right now, after having played a lot with Dropline GNOME 2.16.2 and after several "installs from zero", I can hereby assert that...
Some features:
§
The bottom line: the fonts rendering is important (hey! it can even break your distro :-), but it should be simpler than that. You'd be better to use a distro where you are are happy with the default options and with what you can change from the GUI tools.
While answering to a comment of my reader Greg, I noticed that my whole rant lacks clarity with regards to my personal font config preferences. Well, as I said, I don't like the BCI, nor the auto-aliasing feature, and should we keep apart the customized settings for some specific fonts and font sizes, here's how I prefer the smoothing and hinting to be, regardless of the CRT/LCD display (yes, I don't like to see colored stripes or colored clouds behind my eyes):

That makes it "Best Contrast" as a shortcut in GNOME.
P.S.: Here's what I dislike the most: colored rainbows!

7 (+0) comments so far [view/add comments] [permalink]
This is not only boring and confusing for the newbies, it's also unnecessarily complicated by overzealous people.
Let's try to expose the whole story.
We need to define in very plain language some overused (and often misused) terms:
- Smoothing is a form of anti-aliasing that tries to improve the outlines by adding some interpolated pixels, either in shades of grays, or with RGB hashing at the pixel level.
- Bytecode Interpreting is the native (original) method to interpret and execute the binary instructions that describe the glyphs that define a TrueType font. It is covered by 3 patents granted to Apple;
- Hinting is a "patent-free" alternate way to adjust the rendering of the glyphs that define a TrueType font outline in order to produce a best looking bitmap.
- Auto-hinting is separate feature of the FreeType2 library, capable of hinting monochrome and anti-aliased glyphs differently, and it's not TrueType-specific! It can be also used with fonts that don't provide a hinting algorithm, like Type 1 fonts. Hower, auto-hinting should be disabled for some fonts at small sizes.
Under X, the freetype2 is responsible for rendering the fonts in a pleasant way for your eyes.
- Due to the patent restrictions, most Linux distros don't enable the Bytecode Interpreting by default, and some of them are even compiled without the support for the patent-encumbered hinting method!
- The auto-hinting is also unused by default in most distros, but you should be able to enable it using config files.
- The freetype2-specific hinting options can be configured and used in several ways:
- through config file options;
- through dialog-based configuration in KDE Control Center;
- through dialog-based configuration in GNOME (gnome-font-properties).
Here's a recent post about this: Enable Smooth fonts on Ubuntu Linux. It simply copies the info about auto-hinting posted more than two years ago, here: Change font hinting settings.
The topic "pollutes" the Internet, and you can't find clear and consistent recommendations about how to fix it (neither this article will give you one). Here's another set:
- Optimal Use of MS TrueType Core Fonts for a KDE Desktop on SuSE
- Mini HOWTO: Getting Perfect Fonts on Mandrake 10.1
- Making non-antialiased fonts looks nice.
Let's try to put some things straight.
How can you take care of how your fonts are looking like? Again, there is more than one way to do this.
- You can enable the Bytecode Interpreter in freetype2, and "native hinting" will be available in all the window managers! Some extra smoothing (GNOME, WindowMaker), a.k.a. anti-aliasing (KDE) should be set from within the window manager, and everything will look close to perfect.
- You can enable the freetype2-specific auto-hinting, by using WM-independent config files (see below).
- You can enable the freetype2 patent-free hinting, by either using config files (see below), or by configuring the hinting in GNOME or in KDE. With proper smoothing (anti-aliasing) options, you should be satisfied with the results, although they are supposed to be suboptimal. This is the default in many Linux distros.
The topic will be long, but this isn't my fault. Now, most articles recommend you to use per-user configuration settings, in ~/.fonts.conf. I would rather go with global settings, which can be read from:
- /etc/fonts/fonts.conf
- /etc/fonts/local.conf
- /etc/fonts/conf.d/*.conf
Here's a sample contents took from a Debian machine:
10-defoma.conf -> /var/lib/defoma/fontconfig.d/fonts.conf
20-fix-globaladvance.conf -> ../conf.avail/20-fix-globaladvance.conf
20-lohit-gujarati.conf -> ../conf.avail/20-lohit-gujarati.conf
20-unhint-small-vera.conf -> ../conf.avail/20-unhint-small-vera.conf
30-amt-aliases.conf -> ../conf.avail/30-amt-aliases.conf
30-defoma.conf -> /var/lib/defoma/fontconfig.d/fonts.conf
30-urw-aliases.conf -> ../conf.avail/30-urw-aliases.conf
40-generic.conf -> ../conf.avail/40-generic.conf
49-sansserif.conf -> ../conf.avail/49-sansserif.conf
50-user.conf -> ../conf.avail/50-user.conf
51-local.conf -> ../conf.avail/51-local.conf
60-latin.conf -> ../conf.avail/60-latin.conf
65-fonts-persian.conf -> ../conf.avail/65-fonts-persian.conf
65-nonlatin.conf -> ../conf.avail/65-nonlatin.conf
69-unifont.conf -> ../conf.avail/69-unifont.conf
70-yes-bitmaps.conf -> ../conf.avail/70-yes-bitmaps.conf
80-delicious.conf -> ../conf.avail/80-delicious.conf
90-synthetic.conf -> ../conf.avail/90-synthetic.conf
autohint.conf
no-bitmaps.conf
no-sub-pixel.conf
sub-pixel.conf
unhinted.conf
yes-bitmaps.conf
20-fix-globaladvance.conf -> ../conf.avail/20-fix-globaladvance.conf
20-lohit-gujarati.conf -> ../conf.avail/20-lohit-gujarati.conf
20-unhint-small-vera.conf -> ../conf.avail/20-unhint-small-vera.conf
30-amt-aliases.conf -> ../conf.avail/30-amt-aliases.conf
30-defoma.conf -> /var/lib/defoma/fontconfig.d/fonts.conf
30-urw-aliases.conf -> ../conf.avail/30-urw-aliases.conf
40-generic.conf -> ../conf.avail/40-generic.conf
49-sansserif.conf -> ../conf.avail/49-sansserif.conf
50-user.conf -> ../conf.avail/50-user.conf
51-local.conf -> ../conf.avail/51-local.conf
60-latin.conf -> ../conf.avail/60-latin.conf
65-fonts-persian.conf -> ../conf.avail/65-fonts-persian.conf
65-nonlatin.conf -> ../conf.avail/65-nonlatin.conf
69-unifont.conf -> ../conf.avail/69-unifont.conf
70-yes-bitmaps.conf -> ../conf.avail/70-yes-bitmaps.conf
80-delicious.conf -> ../conf.avail/80-delicious.conf
90-synthetic.conf -> ../conf.avail/90-synthetic.conf
autohint.conf
no-bitmaps.conf
no-sub-pixel.conf
sub-pixel.conf
unhinted.conf
yes-bitmaps.conf
/etc/fonts/conf.avail/ is more generous, containing mutually exclusive options, so you could link to the one you want:
10-autohint.conf
10-no-sub-pixel.conf
10-sub-pixel-bgr.conf
10-sub-pixel-rgb.conf
10-sub-pixel-vbgr.conf
10-sub-pixel-vrgb.conf
10-unhinted.conf
20-fix-globaladvance.conf
20-lohit-gujarati.conf
20-unhint-small-vera.conf
30-amt-aliases.conf
30-urw-aliases.conf
40-generic.conf
49-sansserif.conf
50-user.conf
51-local.conf
60-latin.conf
65-fonts-persian.conf
65-nonlatin.conf
69-unifont.conf
70-no-bitmaps.conf
70-yes-bitmaps.conf
80-delicious.conf
90-synthetic.conf
The system is a mixed Debian testing/unstable, and there are some duplicates, like the files /etc/fonts/conf.d/autohint.conf and /etc/fonts/conf.avail/10-autohint.conf. This should be avoided.10-no-sub-pixel.conf
10-sub-pixel-bgr.conf
10-sub-pixel-rgb.conf
10-sub-pixel-vbgr.conf
10-sub-pixel-vrgb.conf
10-unhinted.conf
20-fix-globaladvance.conf
20-lohit-gujarati.conf
20-unhint-small-vera.conf
30-amt-aliases.conf
30-urw-aliases.conf
40-generic.conf
49-sansserif.conf
50-user.conf
51-local.conf
60-latin.conf
65-fonts-persian.conf
65-nonlatin.conf
69-unifont.conf
70-no-bitmaps.conf
70-yes-bitmaps.conf
80-delicious.conf
90-synthetic.conf
As a personal recommendation, you should use this kind of settings:- for enabling WM-independent settings for use outside GNOME and KDE, especially for turning auto-hinting on if desired;
- for disabling the hinting with certain fonts like Bitstream Vera under 8pt (this is to be taken into account in either 20-unhint-small-vera.conf, or in the global fonts.conf);
- in cases when you want to use the Bytecode Interpreter, to make sure you disable the hinting, and possibly the auto-aliasing for small fonts.
IMPORTANT! The auto-hinting was designed independently and is unconnected to the "regular" TrueType hinting. In my opinion, there is little to gain if you enable it as long as the "regular" hinting is used. The default options with most freetype2 packages should be:- Hinting: automatically ON;
- Auto-hinting: automatically OFF (can be turned on);
- Bytecode Interpreting: automatically OFF (not supported / not defined).
In my opinion (your mileage may vary), the problems when using the highly-acclaimed Bytecode Interpreter don't only rely in the need to recompile the package with the option:
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
in /usr/include/freetype2/freetype/config/ftoption.h, it's more than that. As I wrote in an older article (Optimal use MS TrueType Fonts)...- ...the gain in performance (quality?) over the non-patented method is minimal;
- ...since the "open world" has since then built itself around the use of the freetype2-specific hinting and smoothing, when you use the Bytecode Interpreter (BCI) you must take care to disable anti-aliasing in several places, e.g. in OpenOffice.org.
Configuring the fonts appearance in KDE is pretty much straightforward:


Compared to GNOME, it also offers the option to exclude a range of (presumably small fonts) from anti-aliasing, so this should be all you need.
To my taste, the way fonts look under KDE in a freshly-installed Slackware 11 (Bytecode Interpreter OFF) is close to perfect even on LCDs.
Configuring the fonts appearance in GNOME is rather against the spirit of simplicity that reigns in the GNOME land: the two dialog boxes seem simple enough, but their functionality overlaps.


The first temptation (and the subsequent ones too...) is to select a rendering option in the first dialog, then to go to "Details" to customize it with regards to smoothing and hinting. Few people notice that the four choices in the first dialog map to predefined combinations in the second one!
Here's how things are:
- «Monochrome» maps to:
- Smoothing = None
- Hinting = None
- «Best shapes» maps to:
- Smoothing = Greyscale
- Hinting = Medium
- «Best contrast» maps to:
- Smoothing = Greyscale
- Hinting = Full
- «Subpixel smoothing (LCDs)» maps to:
- Smoothing = Subpixel (LCDs)
- Hinting = Full
To be frank with you, I don't like the subpixel stuff, because I can see the colors! The gray scale is just fine, thank you. The worst incarnation of the subpixel idea is the ClearType(TM) thingie from Microsoft. When I first saw it in Microsoft Reader, I only thought it was a dumb thing: was it only me to clearly see the annoying colored outlines even on CRTs?! Much later, when I saw the overemphasized ClearType in Internet Explorer 7 Beta, I simply could not read the displayed pages! (It took me a while to see how to disable the ClearlyTheWrongType.)
I will put now, for comparison purposes, sample texts under different rendering methods. Since showing them at 1:1 (100%) wouldn't make much of a difference, I scaled them up to 200%. Note that this will make them look slightly better than in reality, because the resize algorithm uses a certain amount of smoothing itself, but you will spot the differences anyway.
No smoothing, no hinting:
No smoothing, no hinting, but auto-hinting enabled (it's even worse!):
Best contrast:
Best contrast, plus auto-hinting enabled:
Best shapes:
Best shapes, plus auto-hinting enabled:
Subpixel smoothing (LCDs):
To me, if it's not "Best contrast" the best looking, it's then "Best contrast + Auto-hinting". But again, YMMV, and your eyes are not my eyes.
A quick note on Ubuntu and Debian. As stated here, in recent versions of Ubuntu, reconfiguring
sudo dpkg-reconfigure fontconfig
should provide you to the end with some configuration dialogs. I don't know how things are in the Etch-to-be, but my Debian testing (not fully up-to-date) doesn't offer any dialogs after the plain reconfiguration.A last part hosts some rants on Dropline GNOME over Slackware 11 and fonts. Someone asked me a pertinent question as a comment to another post: «with so many packages changed from the stock 11.0, does KDE still work properly?»
Right now, after having played a lot with Dropline GNOME 2.16.2 and after several "installs from zero", I can hereby assert that...
- Dropline GNOME actually replaces Slack's freetype with a stupid one, so that fonts in KDE look ugly right after you try to change the Font settings.
- Reverting to the original Slackware version of freetype breaks fonts rendering in GNOME too!
- I could reproduce the process more than once (the lucky part is that installing Slackware is quick).
- I don't know what the heck is DLG doing, it seems that the BCI is enabled, but maybe my S3 Savage video card can't cope with it.
- Even if DLG doesn't replace X, it messes with the stability of my laptop (and I suspect the font-rendering to play a role): if changes in X are made, Ctrl+Alt+Bksp can't restart it properly, and I got stuck with a freezed screen and keyboard (and a frozen GDM greeter). I have to SSH from a remote machine to reboot it. This never happens with the packages provided by Pat, in none of the included WMs, not even in KDE!
- I also don't like the way DLG copied in /etc/fonts/conf.d the "independent" scripts... from Debian (listed upwards)!
Some features:
- Build and install a full GNOME 2.16.2 desktop
- Minimal GNOME install is possible (everything needed to login using GDM only)
- Extra GNOME applications available
- It is very easy to use (extract archive, run the script)
- SlackBot is working on vanilla Slackware 10.2 and 11.0
- Can be used with kernel 2.4 or 2.6
- Menu driven setup/configuration
- Using slackware packages for install
- Re-use created packages for a new install using install scripts
- Build and install a full KDE 3.5.5 desktop that operates nice with GNOME
- Automatically download the source packages required
- Report everything to logfiles
- Can be updated using slackpacks
- Build individual packages (using packages.conf.overwrite)
- Can be build with or without HAL (give it a try, it's nice)
- Can be build with or without MONO (Test the sample app: TomBoy)
- Can be build with or without LibNotify
- Select the packages you want to install
- See a list of packages to be replaced
- About 300 packages included with lots of extra applications
The bottom line: the fonts rendering is important (hey! it can even break your distro :-), but it should be simpler than that. You'd be better to use a distro where you are are happy with the default options and with what you can change from the GUI tools.
While answering to a comment of my reader Greg, I noticed that my whole rant lacks clarity with regards to my personal font config preferences. Well, as I said, I don't like the BCI, nor the auto-aliasing feature, and should we keep apart the customized settings for some specific fonts and font sizes, here's how I prefer the smoothing and hinting to be, regardless of the CRT/LCD display (yes, I don't like to see colored stripes or colored clouds behind my eyes):
That makes it "Best Contrast" as a shortcut in GNOME.
P.S.: Here's what I dislike the most: colored rainbows!

7 (+0) comments so far [view/add comments] [permalink]

