Next Previous Contents

2. Display (what they never told you)

Before we dive into setting up TrueType fonts under X, we should review the difference between points and pixels... and why we care.

All displayed fonts are measured in points. One inch is exactly 72 points. Why 72? Partly because of the limitations of mechanical typesetting machines and partly because it's evenly divisible by 2, 3, 4, 6, 8, 9, 12, 18 and 24. It's also worth noting that the default unit in PostScript is one point.

(Historical note: I lied. Until the introduction of PostScript an inch was exactly 72.27 points, but that point size was set in the era of mechanical printers with metal stamps in a handful of standard sizes. With computer displays and laser printers, it's easy to get fonts in any size and 72 makes much more sense for the reason mentioned above.)

As a general rule, most text should be between 7 and 12 points. Anything smaller than 6 points is literally "the fine print." Line printers used 9 or 12 point type (for 8 or 6 lines/inch, respectively).

In contrast, all video drivers must ultimately measure fonts in pixels. To your video driver, your screen is 1024x800 pixels, not 10 by 8 inches (or 720 by 576 points).

To map from points (which we use to specify a font size) to pixels (which we use to blit the video memory) we must know our screen's resolution. This is usually measured in "dots per inch (dpi)," although it's really pixels per inch. These are the units used in the two sets of bitmap fonts included with XFree86: fonts-75 is intended for use on low-end displays with a resolution of approximately 75 dpi, fonts-100 is intended for use on mid-range displays with a resolution of approximately 100 dpi. There are no bitmap fonts intended for use on high-end displays with a resolution of over 120 dpi.

As a concrete example, a 13" diagonal screen (11.1" usable) displaying a 640x480 pixel image has a resolution of 72.0 dpi. This Is Not A Coincidence. In fact, most web pages (and Microsoft applications) are designed around a canonical display with a resolution of exactly 72 dpi. XFree86's default configuration assumes a display with a resolution of 75 dpi.

Back in the real world, nobody runs 640x480 video anymore. Nobody uses 13" diagonal screens anymore. Since video cards have improved faster than video monitors it's not uncommon to have a configuration like mine: 19" diagonal screen, (17+" usable), 1600x1200 pixels, 117 dpi resolution.

If I run a stock X configuration, all of my fonts are approximately 2/3 of the intended size. It's not an exaggeration to say that all fonts are cut down by a full size: large fonts (12 pts) appear medium (9). Medium fonts (9 pts) appear small (6).

There are three things we can do to fix this. First, We should tell the X server our actual screen resolution:

/etc/X11/xdm/Xservers
#:0 local /usr/X11R6/bin/X -bpp 16
:0 local /usr/X11R6/bin/X -bpp 16 -dpi 120

Second, we should ensure that we use the 100 dpi bitmapped fonts in preference to the 75 dpi fonts.

/etc/X11/XF86Config
Section "Files"
    RgbPath    "/usr/X11R6/lib/X11/rgb"
    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/"
    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/"
    FontPath   "/usr/X11R6/lib/X11/fonts/misc/"
    FontPath   "/usr/X11R6/lib/X11/fonts/Type1/"
    FontPath   "/usr/X11R6/lib/X11/fonts/Speedo/"
EndSection

Finally, if one of our bitmapped fonts isn't an exact match the X server will attempt to "scale" a similar font via pixel replication. The results are rarely pleasant to use. Assuming we have a reasonably powerful system, we can tell the server to use scaled fonts by default, then bitmaps which are exact matches, and scaled bitmaps as a last resort.

/etc/X11/XF86Config
Section "Files"
    RgbPath    "/usr/X11R6/lib/X11/rgb"
    FontPath   "/usr/X11R6/lib/X11/fonts/Type1/"
    FontPath   "/usr/X11R6/lib/X11/fonts/Speedo/"
    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
    FontPath   "/usr/X11R6/lib/X11/fonts/misc/"
    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/"
    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/"
EndSection

2.1 A look ahead to XFree86 4.0

I've just been informed that XFree86 will support DDC communications, if the video card and monitor both support it. This will allow the X server to query the monitor for its physical dimensions and the server will automatically compute the correct DPI setting.

You will still need to make the appropriate changes to your font path, since the server should not second guess your explicit configuration.

2.2 Review: Preparation before changing X configuration files.

Any time we make changes to the X11 configuration files, it's an excellent idea to disable XDM by putting exit 0 somewhere near the top of the file. If you don't do this and X is unable to start for some reason, XDM will put your system into a nasty busy loop that is an unspeakable pain to correct. You Have Been Warned.


Next Previous Contents

mirror server hosted at Truenetwork, Russian Federation.