4.12. Text and Fonts
Prev | 4.12. Text and Fonts | Next

### 4.12. Text and Fonts

Example of a text item, showing the boundary of the text layer. (Font: Utopia Bold)

One of the greatest improvements of GIMP 2.0 over GIMP 1.2 is in the handling of text. In GIMP 2.0 and 2.2, each text item goes in a separate Text layer, and you can come back later to the layer and edit the text in it. You can also move the text around in the image, or change the font, or the font size. You can use any font available on your system. You can control justification, indentation, and line spacing.

Actually, you can operate on a text layer in the same ways as any other layer, but doing so often means giving up the ability to edit the text without losing the results of your work.

To understand some of the idiosyncracies of text handling, it may help for you to realize that a text layer contains more information than the pixel data that you see: it also contains a representation of the text in a text-editor format. You can see this in the text-editor window that pops up while you are using the Text tool. Every time you alter the text, the image layer is redrawn to reflect your changes.

Now suppose you create a text layer, and then operate on it in some way that does not involve the Text tool: rotate it, for example. Suppose you then come back and try to edit it using the Text tool. As soon as you edit the text, the Text tool will redraw the layer, wiping out the results of the operations you performed in the meantime.

Because this danger is not obvious, the Text tool tries to protect you from it. If you operate on a text layer, and then later try to edit the text, a message pops up, warning you that your alterations will be undone, and giving you three options: (1) edit the text anyway; (2) cancel; (3) create a new text layer with the same text as the existing layer, leaving the existing layer unchanged.

#### Embellishing Text

Four fancy text items created using logo scripts: "alien neon", "bovination", "frosty", and "chalk". Default settings were used for everything except font size.

There are many things you can do to vary the appearance of text beyond just rendering it with different fonts or different colors. By converting a text item to a selection or a path, you can fill it, stroke the outlines, transform it, or generallly apply the whole panoply of GIMP tools to get interesting effects. As a demonstration of some of the possibilities, try out the "logo" scripts in the Toolbox menu, at Xtns->Script-Fu->Logos. Each of these scripts allows you to enter some text, and then creates a new image showing a logo constructed out of that text. If you would like to modify one of these scripts, or construct a logo script of your own, the Using Script-Fu and Script-Fu Tutorial sections should help you get started. Of course, you don't need Script-Fu to create these sorts of effects, only to automate them.

#### Adding Fonts

For the most authoritative and up-to-date information on fonts in GIMP, consult the Fonts in GIMP 2.0 page at the GIMP web site. This section attempts to give you a helpful overview.

GIMP uses the FreeType 2 font engine to render fonts, and a system called Fontconfig to manage them. GIMP will let you use any font in Fontconfig's font path; it will also let you use any font it finds in GIMP's font search path, which is set on the Font Folders page of the Preferences dialog. By default, the font search path includes a system GIMP-fonts folder (which you should not alter, even though it is actually empty), and a `fonts` folder inside your personal GIMP directory. You can add new folders to the font search path if it is more convenient for you.

FreeType 2 is a very powerful and flexible system. By default, it supports the following font file formats:

- TrueType fonts (and collections)

- Type 1 fonts

- CID-keyed Type 1 fonts

- CFF fonts

- OpenType fonts (both TrueType and CFF variants)

- SFNT-based bitmap fonts

- X11 PCF fonts

- Windows FNT fonts

- BDF fonts (including anti-aliased ones)

- PFR fonts

- Type42 fonts (limited support)

You can also add modules to support other types of font files. See FREETYPE 2 for more information.

Linux. On a Linux system, if the Fontconfig utility is set up as usual, all you need to do to add a new font is to place the file in the directory `~/.fonts`. This will make the font available not only to GIMP, but to any other program that uses Fontconfig. If for some reason you want the font to be available to GIMP only, you can place it in the `fonts` subdirectory of your personal GIMP directory, or some other location in your font search path. Doing either will cause the font to show up the next time you start GIMP. If you want to use it in an already running GIMP, press the Refresh button in the Fonts dialog.

Windows. The easiest way to install a font is to drag the file onto the Fonts directory and let the shell do its magic. Unless you've done something creative, it's probably in its default location of `C:\windows\fonts` or `C:\winnt\fonts`. Sometimes double-clicking on a font will install it as well as display it; sometimes it only displays it. This method will make the font available not only to GIMP, but also to other Windows applications.

To install a Type 1 file, you need both the `.pfb` and `.pfm` files. Drag the one that gets an icon into the fonts folder. The other one doesn't strictly need to be in the same directory when you drag the file, since it uses some kind of search algorithm to find it if it's not, but in any case putting it in the same directory does no harm.

In principle, GIMP can use any type of font on Windows that FreeType can handle; however, for fonts that Windows can't handle natively, you should install them by placing the font files in the `fonts` folder of your personal GIMP directory, or some other location in your font search path. The support Windows has varies by version. All that GIMP runs on support at least TrueType, Windows FON, and Windows FNT. Windows 2000 and later support Type 1 and OpenType. Windows ME supports OpenType and possibly Type 1 (but the most widely used Windows GIMP installer does not officially support Windows ME, although it may work anyway).

| Note
GIMP uses Fontconfig to manage fonts on Windows as well as Linux. The instructions above work because Fontconfig by default uses the Windows fonts directory, i. e., the same fonts that Windows uses itself. If for some reason your Fontconfig is set up differently, you will have to figure out where to put fonts so that GIMP can find them: in any case, the `fonts` folder of your personal GIMP directory should work.

#### Font Problems

Problems with fonts have probably been responsible for more GIMP 2 bug reports than any other single cause, although they have become much less frequent in the most recent releases in the 2.0 series. In most cases they have been caused by malformed font files giving trouble to Fontconfig. If you experience crashes at startup when GIMP scans your font directories, the best solution is to upgrade to a version of Fontconfig newer than 2.2.0. As a quick workaround you can start gimp with the `--no-fonts` command-line option, but then you will not be able to use the text tool.

Another known problem is that Pango 1.2 cannot load fonts that don't provide an Unicode character mapping. (Pango is the text layout library used by GIMP.) A lot of symbol fonts fall into this category. On some systems, using such a font can cause GIMP to crash. Updating to Pango 1.4 will fix this problem and makes symbol fonts available in GIMP.

A frequent source of confusion occurs on Windows systems, when GIMP encounters a malformed font file and generates an error message: this causes a console window to pop up so that you can see the message. Do not close that console window. It is harmless, and closing it will shut down GIMP. When this happens, it often seems to users that GIMP has crashed. It hasn't: closing the console window causes Windows to shut GIMP down. Unfortunately, this annoying situation is caused by an interaction between Windows and the libraries that GIMP links to: it cannot be fixed within GIMP. All you need to do, though, if this happens, is minimize the console window and ignore it.

Prev | Up | Next
4.11. Palettes | Home | 4.13. Stroking a Selection or Path