| How To Get Fonts To Gimp In this chapter, you'll find some basic information about how to make fonts available to Gimp in X-window.

## How Fonts Work In Gimp

All of the fonts you use in Gimp come from the X-Server. There is no internal font render in Gimp, so Gimp needs X to render the fonts. This is also why the text tool dialog looks a bit like the xfontsel program in X.

### Scalable Fonts

First of all, use scalable fonts (Type 1 or Speedo) in Gimp. As you can tell from the name, these fonts can be scaled up and down without losing quality. There are also bitmapped fonts in X. When you scale a bitmap font, it will lose its shape and get very jaggy and ugly.

### Where Are The Fonts And Font Path

To find out where X keeps its fonts, type `xset -q <enter>` in a shell. The last line in the output indicates your font path. If you are an XFree86 user and use the default XF86 configuration, you have to perform some editing to make sure that the Type 1 and Speedo fonts, are the first to come up when X is looking for a certain font. To do so, place the Speedo and Type 1 directories first in your `Fontpath`.

Another way is to add the string `:unscaled` after your bitmap fonts. If you add this string, the scalable (i.e., the Type 1 fonts) will be used if you need to scale your fonts up or down. The font path in the `XF86Config` file may look like the following (this may only work with XFree 86):

This fragment of the XF86Config file will set up all scalable Type 1 fonts before the bitmap fonts, thus ensuring that Xwindow will (if available) use a nice, smooth T1 Helvetica instead of the jaggy bitmap version of the same font.

To find out what kind of Type 1 fonts you have, change the directory to the Type 1 dir, and read the `fonts.dir` file (e.g., `cd /usr/X11/lib/X11/fonts/Type1 && more fonts.dir`) in a terminal window. All of your available Type 1 fonts will be displayed. One of the most common reasons for a Script-Fu to fail is that the specified Script-Fu font isn't available. This makes the script bug, and there will be no output.

## Installing Fonts

### Type 1 Fonts Installation And The
type1inst Program

We will only cover Type 1 fonts (postscript fonts), other font types are beyond the scope of this chapter.

Download a program called type1inst (written by James Macnicol) from `ftp://sunsite.unc.edu/pub/Linux/X11/xutils` or one of its mirrors.

#### Preparing For Installation

At the time of this writing, the file is called `type1inst-0.6.tar.gz.` Unpack the program like you did with the Gimp archive (see "Obtaining And Installing Gimp" starting on page 43). Copy the files `type1inst` and `t1embed` to a directory in your PATH (for example, `/usr/local/bin)`.

To see your PATH, execute `echo $PATH` in a shell. If you aren't the system administrator, then you probably can't install files in system directories. To overcome this problem, create a bin directory in your home directory and install the `type1inst` program there. To include the program in your PATH, do the following if you run Bash, Sh or Ksh as your shell:

`export PATH=$PATH:$HOME/bin`

#### Copying The Fonts To The Fonts dir

Copy the Type 1 fonts that you want to install in a directory of your own choice. If you have a large font collection and you want easy font management in Gimp, install an xfontserver or install the fonts in different directories with 20 fonts in each.

#### Font Management

Here's how we manage fonts at Frozenriver: Karin needs a lot of fonts, but if you load all fonts into X and Gimp, it becomes hard to choose and find the right font. We have solved this by making different directories for each type of font, e.g we have one directory for artistic fonts, one for strictly business fonts, and so on. This makes it easy for Karin to load and unload the fonts depending on what she wants to do.

#### Running type1inst

When you have copied the fonts, `cd` to the directory where you installed the fonts.Run `type1inst`, and then `mkfontdir`. This will create the necessary `font.dir`, `font.scale` and `font.alias` files in this directory, respectively.

#### Loading The Fonts Into X

Load the fonts into X by applying xset +fp full path to the font directory. The fonts are now installed, and you can use them in Gimp. If you installed the fonts while you had Gimp running, you must restart Gimp.

Notice that the `+` is placed in front of `fp`. If you put the plus sign in the wrong place, all of the default font directories will be queried for the font name first. If there is a font with the same name as yours, this font will be used instead of your own.

The Helvetica font is a good example. The standard Helvetica font that comes with X is of poor quality, but if you download Acrobat Reader from Adobe, a very nice Helvetica font is included.

If you install these fonts with `xset fp+`, you will never see them because the standard Helvetica font that comes with X is placed in front of the font you installed when X is looking for its font directories.

### Installing Type 1 Fonts By Hand

It's not always possible to use the `type1inst` program. If you can't, you'll have to install the `fonts.*` files manually.

#### The Font File

Generally, you have to load the font file in a text editor and look in the file header for name, type and so forth. The header of the file ends with the `eexec` command. Everything after that is binary font data and of little interest. You can only do this with PS font files. Such files normally end with `.pfb` and have `%!PS-AdobeFont` typed in the first line of the file.

### The Font Field In The Font File

The first thing you need to understand is how to code the font field in the `font.scale` file. Here is an example line:

#### Extracting Data

Load the `pfb` in a file editor (like `vi file.pfb`) in a terminal such as xterm, and search for data. Here's what to look for:

· Foundry: The registered name of the font foundry, usually a company name. This was written in the PS font file: `usage: 24954 31846%% ITC Avant Garde Gothic is a registered trademark of International Typeface`. This means that the font will use ITC as Foundry.

· Family: The font family to which the font belongs. There are usually a lot of font files in a font family, all with different characteristics (such as bold, thin, condensed and so forth). Contents of the font file's read-only is `def/FamilyName (ITC Avant Garde Gothic)`, which will display as itc avant garde gothic in the family field.

· Weight: The weight of the font (for example, medium, bold, thin and so forth). This is the information in the PS file `readonly def/Weight (Demi)`, which will put demibold in the weight field.

· Slant: The posture of the font. If there is no slant information for the font, it will display as Roman or upright posture, and there will be an r in the slant field. If there is slant information (such as Gothic Demi Oblique) the slant is Oblique, and there will be an o in the slant field.

· Set Width: This is the horizontal width. Here, you have to search the font name. Condensed is an example of a width type.

· Additional Style: This is a rarely used option for additional styles; it's hardly ever used in PS fonts.

· Encoding: This is what type of languages the font supports. This example from the PS file `def/Encoding StandardEncoding` will end up as iso8859-1; for example, isolatin1 in the encoding field

· The rest is the same as in the example line. It's the standard PS font line.

The following section provides some tables that can help you with your decoding. They are taken from the source of the `type1inst` program.

Generally, `type1inst` will make the job for you. If the Foundry information isn't right, then you can look in the font file or the log file which `type1inst` creates. Most of the time, it's quite easy to figure out what's missing.

## Tables

Table 46.1 The Foundry table

Company | Foundry
--- | ---
Adobe | adobe
Publishers Paradise | paradise
Bigelow & Holmes | b&h
Bitstream | bitstream
International Typeface Corporation | itc
IBM | ibm
LETRASET | letraset
Monotype Corporation | monotype
SoftMaker | softmaker
URW | urw
Jonathan Brecher | brecher
Brendel Informatik | brendel
A. Carr | carr
FontBank | fontbank
Hershey | hershey
A.S.Meit | meit
Andrew s. Meit | meit
S.G. Moye | moye
D. Rakowski | rakowski
David Rakowski | rakowski
Reasonable Solutions | reasonable
Southern Software | southern
Title Wave | titlewave
ZSoft | zsoft

####

Table 46.2 The Weight table

Weights | Weight
--- | ---
book | book
demibold | demibold
semibold | demibold
demi | demibold
semi | demibold
extrabold | extrabold
boldface | bold
bold | bold
heavyface | heavyface
heavy | heavy
ultrablack | ultrablack
extrablack | extrablack
ultra | ultra
black | black
extralight | extralight
light | light
thin | thin
super | super
normal | medium
regular | regular
roman | regular

####

Table 46.3 The Slant table

Slants | Slant
--- | ---
italic | i
roman | r
regular | r
cursive | i
kursiv | i
oblique | o
obl | o
slanted | o
upright | r
inclined | i

####

Table 46.4 The Set Width table

Widths | Set Width
--- | ---
extracondensed | extracondensed
condensed | condensed
cond | condensed
sans | sans
wide | wide
cn | condensed
narrow | narrow
extracompresse | extracompresse
compressed | compressed
extraextended | extraextended
extended | extended
expanded | expanded
normal | normal

####

Table 46.5 The Additional style table

Styles | Style
--- | ---
alt | alternate
beginning | beginning
display | display
dfr | dfr
ending | ending
ep | expert
exp | expert
ornaments | ornaments
osf | oldstylefigures
outline | outline
sc | smallcaps
shaded | shaded
shadowed | shadowed
stencil | stencil
swash | swash
sw | swash
one | one
two | two
three | three
four | four
a | alternate

Frozenriver Digital Design http://www.frozenriver.nu Voice: +46 (0)31 474356 Fax: +46 (0)31 493833 support@frozenriver.com | Publisher Coriolis http://www.coriolis.com