old-www/HOWTO/TT-Debian-2.html

141 lines
6.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>TrueType Fonts in Debian mini-HOWTO: Display (what they never told you)</TITLE>
<LINK HREF="TT-Debian-3.html" REL=next>
<LINK HREF="TT-Debian-1.html" REL=previous>
<LINK HREF="TT-Debian.html#toc2" REL=contents>
</HEAD>
<BODY>
<A HREF="TT-Debian-3.html">Next</A>
<A HREF="TT-Debian-1.html">Previous</A>
<A HREF="TT-Debian.html#toc2">Contents</A>
<HR>
<H2><A NAME="s2">2. Display (what they never told you)</A></H2>
<P>Before we dive into setting up TrueType fonts under X, we should
review the difference between points and pixels... and why we care.
<P>All displayed fonts are measured in <EM>points</EM>. 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.
<P>(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 <EM>much</EM> more
sense for the reason mentioned above.)
<P>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).
<P>In contrast, all video drivers must ultimately measure fonts in
<EM>pixels</EM>. To your video driver, your screen is 1024x800
pixels, not 10 by 8 inches (or 720 by 576 points).
<P>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: <CODE>fonts-75</CODE> is
intended for use on low-end displays with a resolution of approximately
75 dpi, <CODE>fonts-100</CODE> 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.
<P>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.
<P>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.
<P>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).
<P>There are three things we can do to fix this. First, We should tell
the X server our actual screen resolution:
<P>
<BLOCKQUOTE><CODE>
<EM>/etc/X11/xdm/Xservers</EM>
<HR>
<PRE>
#:0 local /usr/X11R6/bin/X -bpp 16
:0 local /usr/X11R6/bin/X -bpp 16 -dpi 120
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>Second, we should ensure that we use the 100 dpi bitmapped fonts
in preference to the 75 dpi fonts.
<P>
<BLOCKQUOTE><CODE>
<EM>/etc/X11/XF86Config</EM>
<HR>
<PRE>
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
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>Finally, if one of our bitmapped fonts isn't an exact match the
<CODE>X</CODE> 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.
<P>
<BLOCKQUOTE><CODE>
<EM>/etc/X11/XF86Config</EM>
<HR>
<PRE>
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
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="ss2.1">2.1 A look ahead to XFree86 4.0</A>
</H2>
<P>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.
<P>You will still need to make the appropriate changes to your font path,
since the server should not second guess your explicit configuration.
<P>
<H2><A NAME="ss2.2">2.2 Review: Preparation before changing <CODE>X</CODE> configuration files.</A>
</H2>
<P>Any time we make changes to the X11 configuration files, it's an
excellent idea to disable <CODE>XDM</CODE> by putting <CODE>exit 0</CODE> somewhere
near the top of the file. If you don't do this and <CODE>X</CODE> is unable
to start for some reason, <CODE>XDM</CODE> will put your system into a nasty
busy loop that is an unspeakable pain to correct. You Have Been Warned.
<P>
<HR>
<A HREF="TT-Debian-3.html">Next</A>
<A HREF="TT-Debian-1.html">Previous</A>
<A HREF="TT-Debian.html#toc2">Contents</A>
</BODY>
</HTML>