Документ взят из кэша поисковой машины. Адрес оригинального документа : http://rtm-cs.sinp.msu.ru/manual/howto/Font-HOWTO.html
Дата изменения: Thu May 4 19:18:04 2000
Дата индексирования: Mon Oct 1 20:54:32 2012
Кодировка:
Font HOWTO

Font HOWTO

Donovan Rebbechi, elflord@panix.com

1. Introduction

2. Fonts 101 -- A Quick Introduction to Fonts

3. Fonts 102 -- Typography

4. Making Fonts Available To X

5. Making Fonts Available To Ghostscript

6. True Type to Type1 Conversion

7. WYSIWYG Publishing and Fonts

8. Netscape

9. TeX / LaTeX

10. Getting Fonts For Linux

11. Useful Font Software for Linux

12. Ethics and Licensing Issues Related to Type

13. References

14. Glossary


1. Introduction

1.1 The Location of This Document

This document is located at my webpage

1.2 Rationale

I'm going to make this brief (-; The purpose of this document is to address what was a gaping hole in font documentation. While previously, there were several documents about fonts for Linux, I felt that none of them were comprehensive, all of them had a relatively narrow focus. Hence the goal of this document is not to provide radical new insight into the issue of font handling ( though I have included material previously unavailable ), the main aim is to provide a comprehensive source to act as a starting point for any and all font questions about Linux.

1.3 Credits and Acknowledgements

Special thanks are due to Rod Smith, who made several helpful suggestions, and fixed pfm2afm. Also thanks to Doug Holland, whose Font Deuglification HOWTO proved to be a good reference, John McLaughlin, author of the document that helped me come to grips with Star Office, and the Linux community for their suggestions and construtive comments.


2. Fonts 101 -- A Quick Introduction to Fonts

2.1 Types of fonts

Bitmap Fonts

A bitmap is a matrix of dots. Bitmap fonts are represented in precisely this way -- as matrices of dots. Because of this, they are device dependent -- they are only useful at a particular resolution. A 75 DPI screen bitmap font is still 75 DPI on your 1200 DPI printer.

There are two types of bitmap fonts -- bitmap printer fonts, such as the pk fonts generated by dvips, and bitmap screen fonts, used by X and the console. The bitmap screen fonts typically have a bdf or pcf extension. Bitmap screen fonts are most useful for terminal windows, consoles and text editors, where the lack of scalability and the fact that they are unprintable is not an issue.

Type1 Fonts

The Type1 font standard was devised by Adobe, and Type1 fonts are supported by Adobe's postscript standard. Because of this, they are also well supported under linux. They are supported by X and ghostscript. Postscript fonts have traditionally been the choice of font for anything on UNIX that involves printing.

Typically, a UNIX Type1 font is distributed as an afm ( adobe font metric ) file, and an outline file, which is usually a pfb ( printer font binary ) or pfa ( printer font ascii ) file. The outline file contains all the glyphs, while the metric file contains the metrics.

Type 1 fonts for other platforms may be distributed in different formats. For example, postscript fonts for windows often use a different format ( pfm ) for the metric file.

Type3 fonts

These fonts are distributed in a similar manner to Type1 files -- in groups of afm font metrics, and pfa files. While they are supported by the postscript standard, they are not supported by X, and hence have limited use.

TrueType fonts

True type fonts were developed by Apple. They made the format available to Microsoft, and succesfully challenged Adobe's grip on the font market. True type fonts store the metric and shape information in a single file ( usually one with a ttf extension ). Recently, font servers have been developed that make TrueType available to X. And postscript and ghostscript have supported TrueType fonts for some time. Because of this, TrueType fonts are becoming more popular on linux.

Type42 Fonts

Type42 fonts are actually just TrueType fonts with headers that enable them to be rendered by a postscript interpreter. Most applications, such as ghostscript and SAMBA handle these fonts transparently. However, if you have a postscript printer, it may be necessary to explicitly create Type42 font files.

Type1 vs TrueType -- a comparison

Despite the historical feuding between the proponents to Type1 and TrueType fonts, both have a lot in common. Both are scalable outline fonts. Type1 fonts use cubic as opposed to quadratic curves for the glyphs. This is in theory at least a slight advantage since they include all the curves available to TrueType fonts. In practice, it makes very little difference.

TrueType fonts have the apparent advantage that their support for hinting is better ( Type1 fonts do have hinting functionality, but it is not as extensive as that of TrueType fonts ). However, this is only an issue on low resolution devices, such as screens ( the improved hinting makes no discernable difference on a 600dpi printer, even at small point sizes. ) The other point that makes this apparent advantage somewhat questionable is the fact that well hinted TrueType fonts are rare. This is because software packages that support hinting functionality are out of the budget of most small time designers. Only a few major foundries, such as Monotype make well hinted fonts available.

In conclusion, the main differences between TrueType and Type1 fonts are in availability and application support. The widespread availability of TrueType fonts for Windows has resolted in webpages designed with the assumption that certain TrueType fonts are available. Also, many users have large numbers of TrueType fonts because they ship with the users Windows applications. However, on Linux, most applications support Type1 fonts but do not have the same level of support for TrueType. Moreover, most major font foundries still ship most of their fonts in Type1 format. For example, Adobe ship very few TrueType fonts. My recommendation to users is to use whatever works for your application, and try to avoid converting from one format to another where possible ( because the format conversion is not without loss ).

Metafont

Metafont was developed by Donald E Knuth as part of the TeX typesetting system. Metafont is a graphics programming language ( like postscript ) that has applications wider than just fonts. Metafonts exhibit some very desirable qualities. One of the important features is that metafonts can scale very gracefully. The metafont Computer Modern has different shape at 20 point and 10 point. The shape changes with size, because it is desirable for a smaller font to be proportionately wider than a larger font ( this makes the larger fonts more elegant and the smaller font more readable ).

Metafonts typically have a mf extension. They are rendered to device dependent bitmap fonts. The rendering is slow, so they are of excellent quality, but are not well suited to WYSIWYG publishing.

2.2 Families of Typefaces

Typically typically come in groups of a few variants. For example, most fonts come with a bold, italic, and bold-italic variant. Some fonts may also have small caps, and demibold variants. A group of fonts consisting of a font and its variants is called a family of typefaces. For example, the Garamond family consists of Garamond, Garamond-italic, Garamond-bold, Garamond bold-italic, Garamond demi-bold, and Garamond demi-bold-italic. The Adobe expert Garamond font also makes available Garamond small caps, and Garamond titling capitals.


3. Fonts 102 -- Typography

Here, we discuss some typography basics. While this information is not essential, many font lovers will find it interesting.

3.1 Classifications of Typefaces

Fixed versus variable width

There are several classifications of typefaces. Firstly, there are fixed width fonts, and variable width fonts. The fixed width fonts look like typewriter text, because each character is the same width. This quality is desirable for something like a text editor or a computer console, but not desirable for the body text of a long document. The other class is variable width. Most of the fonts you will use are variable width, though fixed with can be useful also ( for example, all the example shell commands in this document are illustrated with a fixed with font ). The most well known fixed width font is courier.

To serif or not to serif ?

Serifs are little hooks on the ends of characters. For example, the letter i in a font such as Times Roman has serifs protruding from the base of the i and the head of the i. Serif fonts are usually considered more readable than fonts without serifs. There are many different types of serif fonts.

Sans serif fonts do not have these little hooks, so they have a starker appearance. One usually does not write a long book using a sans serif font for the body text. There are sans serif fonts that are readable enough to be well suited to documents that are supposed to be browsed / skimmed ( web pages, catalogues, marketting brochures ). Another application that sans serif fonts have is as display fonts on computer screens, especially at small sizes. The lack of detail in the font can provide it with more clarity. For example, Microsoft touts Verdana as being readable at very small sizes on screen.

Notable sans serif fonts include Lucida sans, MS Comic Sans, Verdana, Myriad, Avant Garde, Arial, Century Gothic and Helvetica. By the way, Helvetica is considered harmful by typographers. It is somewhat overused, and many books by typographers plead users to stay away from it.

The old and the new -- different types of Serif fonts

Old Style

Old style fonts are based on very traditional styles dating as far back as the late 15th century. Old style fonts tend to be conservative in design, and very readable. They are well suited to writing long documents. The name ``old style'' refers to the style of the font, as opposed to the date of its design. There are classic old style fonts, such as Goudy Old Style, which wre designed in the 20th century. The old style class of fonts has the following distinguishing features:

Notable Old Style fonts include Garamond, Goudy Old Style, Jenson, and Caslon ( the latter is contentious -- some consider it transitional )

Moderns ( or didone )

The moderns are the opposite of old style fonts. These fonts typically have more character, and more attitude than their old style counterparts, and can be used to add character to a document rather than to typeset a long piece. However, nothing is black and white -- and there are some modern fonts such as computer modern and Monotype modern, and New Century Schoolbook are very readable ( the contrast between heavy and light is softened to add readability ). They are based on the designs popular in the 19th century and later. Their distinguishing features include:

Bodoni is the most notable modern. Other moderns include computer modern, and Monotype modern ( on which computer modern is based ).

Transitional

Transitional fonts fit somewhere in between moderns and old style fonts. Many of the transitionals have the same kind of readability as the old styles. However, they are based on slightly later design. While a move in the direction of the moderns may be visible in these fonts, they are still much more subtle than the the moderns. Examples of transitionals include Times Roman, Utopia, Bulmer, and Baskerville. Of these, Times leans towards old style, while Bulmer looks very modern.

Slab Serifs

The slab serif fonts are so named because they have thick, block like serifs, as opposed to the smooth hooks of the old styles or the thin lines of some of the moderns. Slab serif fonts tend to be sturdy looking and are generally quite readable. Many of the slab serifs have Egyptian names -- such as Nile, and Egyptienne ( though they are not really in any way Egyptian ). These fonts are great for producing readable text that may suffer some dilution in quality ( such as photocpied documents, and documents printed on newspaper ). These fonts tend to look fairly sturdy. The most notable slab serif fonts are Clarendon, Memphis and Egyptienne, as well as several typewriter fonts. Many of the slab serif fonts are fixed width. Conversely, most ( almost all ) fixed width fonts are slab serif.

The Sans Serif Revolution

Surprisingly, the rise of sans serif fonts is a fairly recent phenomenon. The first well known sans serif fonts were designed in the 19th early 20th century. The earlier designs include Futura, Grotesque and Gill Sans. These fonts represent respectively the ``geometric'', ``grotesque'' and ``humanist'' classes of sans serif fonts.

Grotesque

The grotesques where so named because the public were initially somewhat shocked by their relatively stark design. Groteques are very bare in appearance due to the absence of serifs, and the simpler, cleaner designs. Because of their ``in your face'' appearance, grotesques are good for headlines. The more readable variations also work quite well for comic books, and marketting brochures, where the body text comes in small doses. Grotesques don't look as artsy as their geometric counterparts. Compared to the geometrics, they have more variation in weight, more strokes, they are squarer ( because they don't use such circular arcs ). They use a different upper case G and lower case a to the geometrics. While they are minimalistic but don't go to the same extreme as the brutally avant-garde geometrics.

Notable grotesques include the overused Helvetica, Grotesque, Arial, Franklin Gothic, and Univers.

Geometric

The Futura font came with the manifesto: form follows function. The geometric class of fonts has a stark minimalistic appearance. Distinguishing features include a constant line thickness ( no weight ). This is particularly conspicuous in the bold variants of a font. Bold groteques and humanist fonts often show some notable variation in weight while this rarely happens with the geometric fonts. Also notable is the precise minimalism of these designs. The characters almost always are made up from straight horizontal and vertical lines, and arcs that are very circular ( to the point where they often look as though they were drawn with a compass ). The characters have a minimal number of strokes. This gives them a contemporary look in that they embrace the minimalistic philosophy that would later take the world of modern art by storm. A tell tale sign that a font is a geometric type is the upper case ``G'', which consists of a minimalistic combination of two strokes -- a long circular arc and a horizontal line. The other character that stands out is the lower case ``a'' -- which is again two simple strokes, a straight vertical line and a circle ( the other ``a'' character is more complex which is why it is not used ). Notable geometrics include Avant Garde, Futura, and Century Gothic.

Humanist

As the name might suggest, humanist fonts were designed with a goal of being less mechanical in appearance. In many ways, they are more similar to the serif fonts than the geometrics and the grotesques. They are said to have a ``pen drawn'' look about them. They tend to have subtle variation in weight, especially observable in bold variants. The curve shapes are considerably less rigid than those of the geometrics. Many of them are distinguishable by the ``double story'' lower case g, which is the same shape as the g used in the old style serif fonts. The humanist typefaces are the easiest to use without producing an ugly document as they are relatively compatible with the old style fonts.

Compatible Typefaces

Grouping typefaces is not easy, so it pays to avoid using too many on the one page. A logical choice of two typefaces consists of a serif and a sans serif. Monotype's Typography 101 page provides a category-matchup. They conclude that the moderns and geometrics form good pairs, while the old styles and humanists also go together well. The transitionals are also paired with the humanists. The slab serifs are paired with the grotesques, and some variants of the slab serifs are also said to match the geometrics or humanists.

From reading this, one gets the impression that their philosophy is essentially to match the more conservative serifs with the more moderate sans serifs, and pair the wilder modern serifs with the avant garde looking ( pun unavoidable ) geometrics.

3.2 Ligatures, Small caps fonts and expert fonts

Ligatures

Properly spacing fonts brings with it all sorts of issues. For example, to properly typeset the letters ``fi'', the i should be very close to the f. The problem is that this causes the dot on the i to collide with the f, and the serif on the head of the i to collide with the horizontal stroke of the f. To deal with this problem, font collections include ligatures. For example, the ``fi'' ligature character is a single character that one can substitute for the the two character string ``fi''. Most fonts contain fi and fl ligatures. Expert fonts discussed later often include extra ligatures, such as ffl, ffi, and a dotless i character.

Small caps fonts

Small caps fonts are fonts that have reduced size upper case letters in place of the lower case letters. These are useful for writing headings that require emphasis ( and they are often used in LaTeX ). Typically, when one writes a heading in small caps, they use a large cap for the beginning of each word, and small capitals for the rest of the word ( ``title case'' ). The advantage of this over using all caps is that you get something that is much more readable ( using all caps is a big typographic sin ).

Expert fonts

Expert fonts consist of several extras designed to supplement a typeface. These include things like ligatures, ornaments ( much like a mini-dingbats collection designed to go with the typeface ), small caps fonts, and swash capitals ( fancy, calligraphic letters ).

3.3 Font Metrics and Shapes

Font metrics define the spacing between variable width fonts. The metrics include information about the size of the font, and kerning information, which assigns kerning pairs -- pairs of characters that should be given different spacing. For example, the letters ``To'' would usually belong in a kerning pair, because correctly spaced ( or kerned ), the o should partly sit under the T. Typesetting programs such as LaTeX need to know information about kerning so that they can make decisions about where to break lines and pages. The same applies to WYWIWYG publishing programs.

In addition to the metrics, is the font outline, or shape. The components of the fonts shape ( a stroke, an accent, etc ) are called ``glyphs''.


4. Making Fonts Available To X

There are a number of ways fonts can be added to X. Firstly, XFree86 has a font path which is just a list of several directories or font servers where it searches for fonts. A font server is just a background process that makes fonts available to XFree86. An advantage of font servers is that they can send fonts to remote displays.

Recently, xfs ( the ``X font server'' ) has been patched to support TrueType fonts, and run as a stand-alone program. The patched version ships with Redhat and Redhat-based distributions, and is included in XFree86 3.9.17 ( the latest version at the time of writing. It will also be a part of XFree86 4.0 ) xfs is actually just the standard font server that comes with XFree86. It's source code is part of the XFree86 source tree. However, distributions have recently been shipping a version that runs in stand alone mode. The standalone X font server, with the TrueType support patch ( the TrueType support takes place via a font server called xfsft ) is probably the nicest font management solution currently available. Its advantages include:

Because different distributions ship with different configurations, it is not true that one size fits all. We can split users up into three groups:

4.1 The font path

XFree86 finds your fonts by searching a font path, a list of directories ( or servers -- we'll explain this further later. ) containing fonts. When an application requests a font, it searches through the directories in your font path one at a time until the font is found. To make fonts available requires you to set your font path. You can add a directory to your font path with the command

        xset fp+ directory
        
Once you have done this, you need to ask the X server to re-scan for available fonts with the command
        xset fp rehash
        
Since you will want these commands to run automatically, you should put them in your .xinitrc file ( or possibly your .Xclients or .xsession file -- this depends on how you start X. It's convenient to make two of these files symlinks to the other to avoid confusion ). Another way to have the commands set automatically is edit XF86Config. For example, to add /usr/share/fonts/myfonts to the fontpath when X is started, edit XF86Config like this:
                ...
                Section "Files"
                ...
                
                FontPath /usr/share/fonts/myfonts
                ...
                EndSection
                ...
The advantage of editing XF86Config is that the resulting changes are system wide.

4.2 Installing Type1 Fonts

Run Type1inst

The easiest way to make Type1 fonts available to X is with the help of the Type1inst utility. This is a perlscript that automatically creates the fonts.dir and fonts.scale files that you need for X to use the fonts. Simply CD to the directory, and run type1inst.

        cd directory
        type1inst
        

If You Have the xfs Package

Now you need to add the fonts to your fontpath. If you already have the standalone xfs running, you do this by editing your xfs configuration file. Redhat users can just use chkfontpath. the format is chkfontpath --add directory

Your fonts should now be available to X. Now you just run

        xset fp rehash
        
and X will be able to find the new fonts.

If You Don't Have The xfs Package

In this case, you need to add the directory containing your new fonts to the font path, as described previously.

4.3 True Type Fonts

Adding TrueType fonts is a little more difficult, because you need to have a font server that is capable of serving TrueType fonts. Two font servers that do this are xfstt and xfs.

xfstt is a TrueType font server. While it's easy to configure, and quite useful, it appear that xfs is becoming more popular. The main advantage of xfs over xfstt is that it supports both Type1 and TrueType fonts.

xfstt

To set up xfstt, just download it and install it. If you have an rpm based distribution, there is a well packaged version of xfstt at http://independence.seul.org/. Once you install it, you need to do the following:

  1. install fonts into the appropriate directory ( read the documentation that comes with the package ).
  2. cd to that directory and run xfstt --sync. This causes it to look for the fonts and create the fonts.dir file.
  3. Now add unix/:7100 to your font path.
Your TrueType fonts should now display and be available to applications such as GIMP and Netscape. You may want to configure it to start every time your system starts up. Check to see if there's a startup file included ( if you are using RPM, you can use rpm -ql xfstt |grep init and look for the file with a name something like this: /etc/rc.d/init.d/xfstt ) If you don't have an init script, just put two lines in /etc/rc.local like this:
        /usr/X11R6/bin/xfstt --sync
        /usr/X11R6/bin/xfstt &
        

4.4 xfs

Some of the newer Linux distributions ship with the X font server xfs configured to run as a stand alone program. Notably, Redhat and all the redhat based distributions use this modularised xfs with TrueType compiled in. Debian also ship xfs, but the version they ship doesn't have built in true type support.

Running xfs as a stand alone server has several benefits, especially if it is compiled with TrueType support. The main advantage is that since the font server is no longer attached to the X server, it is possible to serve fonts to remote displays. Also, it makes it much easier to modify the font path.

The xfs Path

As a font server, xfs has it's own font path. One might wonder where this fits into the picture. It works like this: you can place the xfs font server in XFree86's font path, by adding unix/:port to the XFree86 font path. Once you do this, any font in the xfs font path automatically becomes available to XFree86.

The xfs font path is determined by the xfs configuration file, which is /etc/X11/fs/config on Redhat, and /etc/X11/xfs/config on Debian. Redhat users do not need to explicitly edit this file, they can use the chkfontpath utility. The syntax is simple:

        chkfontpath --add directory
        
Users of other distributions can edit the configuration file as follows:
        catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,
        ...
        /usr/share/fonts/my_new_fonts/,
        ...
        /usr/share/fonts/some_other_directory
        # in 12 points, decipoints
        default-point-size = 120
        ...
        
The above would add /usr/share/fonts/my_new_fonts/ to the xfs font path. Note that the last line of the list of directories doesn't have a comma at the end. For these modifications to the font path to become effective, xfs must be restarted. It's also a good idea to restart your X session after restarting xfs.

Installing a Font Into