< Previous | Contents | Next >

16. FONTS

image


This chapter explains font s and font descriptors, what they are and how to use them, so that you can use functions requiring font descriptors

You have already been exposed to many font s in Medley. For example, when you use the structure editor, DEdit (see the Using the List Structure Editor section of Chapter 7), you noticed that the comments were printed in a smaller font than the code, and

that CLlSP words (see the CLISP section of Chapter 9) were printed in a darker font

than the other words in the function. These are only some of the font s that are available in Medley.

In addition to the font s that appear on your screen, Medley uses font s for printers that are different than the ones used for the screen. The font s used to print to the screen are called DlSPLAYFONTS. The font s used for prining are called INTERPRESSFONTS , or PRESSFONTS, depending on the type of printer.


What Makes Up a Font


Fonts are described by family, weight, slope, width, and size. This section discusses each of these, and describes how they affect the font you see on the screen.

Family is one way that font s can differ. Here are some examples of how "family" affect s the look of a font:

CLASSIC This family makes the word "Able" look like this: Able MODERN This family makes the word "Able" look like this: Able TITAN This family makes the word "Able" look like this: Able

Weight also determines the look of a font. Once again, "Able" will be used as an example, this time only with the Classic family. A font’s weight can be:

BOLD And look like this: Able

MEDIUM

or REGULAR And look like this: Able

The slope of a font is italic or regular. Using the Classic family font again, in a regular weight, the slope affect s the font like this:

ITALIC Looks like this: Able

REGULAR Looks like this: Able

The width of a font is called its "expansion". It can be COMPRESSED , REGULAR, or

EXPANDED.

Together, the weight, slope, and expansion of a font specifies the font’s "face". Specifically, the face of a font is a three element list:

(weight slope expansion)

To make it easier to type, when a function requires a font face as an argument, it can be abbreviated with a three-character atom. The first specifies the weight, the second the


slope, and the third character the expansion. For example, some common font faces are abbreviated:

MRR This is the usual face, MEDIUM, REGULAR, REGULAR

MIR Makes an italic font. It stands for: MEDIUM , ITALIC, REGULAR

BRR Makes a bold font. The abbreviation means: BOLD, REGULAR , REGULAR BIR Means that the font should be both bold and italic. BIR stands for BOLD,

ITALIC, REGULAR

The above examples are used so oflen, that there are also more mnemonic abbreviations for them. They can also be used to specify a font face for a function that requires a face as an argument. They are:


STANDARD This is the usual face: MEDIUM, REGULAR, REGULAR; it was abbreviated above, MRR

ITALIC This was abbreviated above as MIR, and specifies an italic font

BOLD Makes a bold font; it was abbreviated above, BRR

BOLDITALIC Makes a font both bold and italic: BOLD, ITALIC , REGULAR; it was abbreviated above, BIR

A font also has a size. It is a positive integer that specifies the height of the font in

printers points. A point is, on an 1108 screen, about 1/72 of an inch. On the screen of an 1186, a point is 1/80 of an inch. The size of the font used in this chapter is 10. For

comparison, here is an example of a TITAN, MRR, size 12 font: Able.


Fontdescriptors and FONTCREATE

For Medley to use a font, it must have a font descriptor. A font descriptor is a data type in Interlisp-D that that holds all the information needed in order to use a particular font. When you print out a font descriptor, it looks like this:

{FONTDESCRIPTOR}#74,45540

Fontdescriptors are created by the function FONTCREATE . For example,

(FONTCREATE ’HELVETICA 12 ’BOLD)

creates a font descriptor that, when used by other functions, prints in HELVETICA BOLD size 12. Interlisp-D functions that work with font s expect a font descriptor produced

with the FONTCREATE function. The syntax of FONTCREATE is:

(FONTCREATE family size face)

Remember from the previous section, face is either a three element list (weight slope expansion), a three character atom abbreviation, e.g. MRR, or one of the mnemonic

abbreviations, e.g. STANDARD .

If FONTCREATE is asked to create a font descriptor that a J ready exists, the existing font descriptor is simply returned.


Display Fonts

Display font s require files that contain the bitmaps used to print each character on the screen. All of these files have the extension .DlSPLAYFONT . The file name itself

describes the font style and size that uses its bitmaps. For example:

MODERN12.DISPLAYFONT

contains bitmaps for the font family MODERN in size 12 points. Wherever you put your

.DISPLAYFONT files, you should make this one of the values of the variable DISPLAYFONTDIRECTORIES. Its value is a list of directories to search for the bitmap files for display font s. Usually, it contains the "FONT" directory where you copied the bitmap files, and the current connected directory. The current connected directory is

specified by the atom NIL. When looking for a .DISPLAYFONT file, the system checks the FONT directory on the hard disk, then the current connected directory.

Figure 16-1 shows an example value of DISPLAYFONTDIRECTORIES :


image


Figure 16-1. Value for the Atom DISFLAYFONTDIRECTORIES


InterPress Fonts

InterPress is the format that is used by Xerox laser printers. These printers normally have a resolution that is much higher than that of the screen: 300 points per inch.

To format files appropriately for output on such a printer, Interlisp must know the

actual size for each character that is to be printed. This is done through the use of width files that contain font width information for font s in InterPress format. For InterPress font s, you should make the location of these files one of the values of the variable INTERPRESSFONTDIRECTORIES. Its value is a list of directories to search for the font widths files for InterPress font s. Figure 16-2 is an example value of INTERPRESSFONTDIRECTORIES:



image


Figure 16-2. Value for Atom INTERPRESSFONTDIRECTORIES


Functions for Using Fonts


FONTPR0P Looking at Font Properties

It is possible to see the properties of a font descriptor. This s done with the function FONTPROP. For the following examples, the font descriptor used will be the one returned by the function (DEFAULTFONT ’DISPLAY) . In other words, the font descriptor

examined will be the default display font for the system.

There are many properties of a font that might be useful for you. Some of these are:


FAMILY To see the family of a font descriptor, type:

(FONTPROP (DEFAULTFONT ’DISPLAY) ’FAMILY)

SIZE As above, this is a positive integer that determines the height of the font in printer’s points. As an example, the SIZE of the current default font is:

image


Figure 16-3. Value of Font Property SIZE of Default Font

ASCENT The value of this property is a positive integer, the maximum height of

any character in the specified font from the baseline (bottom). The top of


the tallest character in the font, then, will be at (BASELINE + ASCENT

- l). For example, the ASCENT of the default font is:


image

Figure 16-4. Value Font Property ASCENT of Default Font

DESCENT The DESCENT is an integer that specifies the maximum number of points that a character in the font descends below the baseline (e.g.,

letters such as "p" and "g" have tails that descend below the baseline.). The bottom of the lowest character in the font will be at (BASELINE - DESCENT). To see the DESCENT of the default font, type:

(FONTPROP (DEFAULTFONT ’DISPLAY) ’DESCENT) HEIGHT HEIGHT is equal to (DESCENT - ASCENT).

FACE The value of this property is a list of the form (weight slope expansion). These are the weight, slope, and expansion described above. You can see each one separately, also. Use the property that you are interested in, WEIGHT, SLOPE, or EXPANSION, instead of FACE as the second argument to FONTPROP.

For other font properties, see Chapter 27 of the IRM.


STRlNGWlDTH

It is often useful to see how much space is required to print an expression in a particular font. The function STRINGWIDTH does this. For example, type:

(STRINGWIDTH "Hi there!" (FONTCREATE ’GACHA 10 ’STANDARD))

The number returned is how many left to right pixels would be needed if the string

were printed in this font. (Note that this doesn’t just work for pixels on the screen, but for all kinds of streams. For more information about streams, see Chapter 15.) Compare the number returned from the example call with the number returned when you change GACHA to TIMESROMAN.


DSPFONT - Changing the Font in One Window

The function DSPFONT changes the font in a single window. As an example of its use, first create a window to write in. Type:

(SETQ MY.FONT.WINDOW (CREATEW))

in the Executive Window. Sweep out the window. To print something in the default font, type:

(PRINT ’HELLO MY.FONT.WINDOW)

in the Executive Window. Your window, MY.FONT.WINDOW , will look something like Figure 16-5:


image

Figure 16-5. HELLO, Printed with the Default Font in MY.FONT.WINDOW

Now change the font in the window. Type:

(DSPFONT (FONTCREATE ’HELVETICA 12 ’BOLD) MY.FONT.WINDOW)

in the Executive Window. The arguments to FONTCREATE can be changed to create any desired font. Now retype the PRINT statement, and your window will look something

like Figure 16-6:


image

Flgure 16-6. Font in MY.FONT.WINDOW Changed Notice the font has been changed.


Personalizing Your Font Profile

Medley keeps a list of default font specifications. This list is used to set the font in all windows where the font is not specifically set by the user (see the DSPFONT section

above). The value of the atom FONTPROFILE is this list (see Figure 16-7).

A FONTPROFILE is a list of font descriptions that certain system functions access when printing output. It contains specifications for big font s (used when pretty printing a

function to type the function name), small font s (used for printing comments in the editor), and various other font s.


image


Figure 16-7. Value of the Atom FONTPROFILE


The list is in the form of an association list. The font class names (e.g., DEFAULTFONT , or BOLDFONT) are the keywords of the association list. When a number follows the

keyword, it is the font number for that font class.

The lists following the font class name or number are the font specifications, in a form that the function FONTCREATE can use. The first font specification list affer a keyword

is the specification for printing to windows. The list(GACHA 10) in the figure above is an example of the default specification for the printing to windows. The last two font

specification lists are for Press and InterPress file printing, respectively. For more information, see Chapter 27 in the IRM.

Now, to change your default font settings, change the value of the variable FONTPROFILE. Medley has a list of profiles stored as the value of the atom FONTDEFS . Choose the profile to use, then install it as the default FONTPROFILE .

Evaluate the atom FONTDEFS and notice that each profile list begins with a keyword (see Figure 16-8). This keyword corresponds to the size of the font s included. BIG, SMALL, and STANDARD are some of the keywords for profiles on this list—SMALL and STANDARD appear in Figure 16-8.



image


Figure 16-8. Part of Value of the Atom FONTDEFS

To install a new profile from this list, follow the following example, but insert any keyword for BIG.

To use the profile with the keyword BIG instead of the standard one, evaluate the following expression:

(FONTSET ’BIG))

Now the font s are permanently replaced. (That is, until another profile is installed.)