Updated 2011-09-12 08:58:34 by dkf

What is XFT edit

The Xft library provides support for antialiased TrueType fonts, full Unicode, and an un-brain-damaged font selection mechanism for X11.

It relies on fontconfig [1], FreeType [2], and the X Render extension (although it will still work if XRender is not available on the server). Xft 2.0 is included in most recent Linux distributions (circa May 2003). Mozilla, Qt, and GTk have all been updated to use Xft.

How to enable or disable XFT edit

The Xft renderer was made the default (where Tk's configure script can work out how to get the required pieces) for 8.5, but you can always force it to be the reverse using --disable-xft if you prefer the old way of doing it or require access to the old list of fonts. (The last point is because Xft has a fundamentally different way of dealing with fonts than Xservers provide; this is completely outside of Tk's control, and it just reports what it is told by the underlying APIs.)

To check for Xft support inside a Tcl/Tk script, use:
   if {[catch {::tk::pkgconfig get fontsystem} xft]} {set xft no-xft}

As of tk 8.5, you either have Xft and not being able to use old list of fonts, or not use Xft at all. There is no option to allow both new font and old font.

how to switch between bitmap font and anti-aliased font edit

Although Xft handles both type of fonts, on modern xorg distributions usually bitmap font is turned off in Xft, thus to use bitmap font for tk 8.5 and above, either to compile a version without xft enabled, or change the fontconfig configuration (for example, instruction on Ubuntu Linux )

In debian squeeze it's much the same, with a tclkit 8.5 that is Xft enabled, you can still get 'old' unix fixed bitmap fonts like so:

  1. copy /etc/fonts/conf.avail/70-force-bitmaps.conf to ~/.fonts.conf and if you already have a ~/.fonts.conf then merge
  2. download miscfixed.zip and unzip in ~/.fonts
  3. reload the font list: fc-cache -f -v

now in Tk you can set a font to {miscfixed 8} and it works.

Discussion edit


The Details edit