C o n f i g u r a t i o n

Fonts

Introduction

Fonts are a somewhat complex matter in Linux and X. Sketch's main output format for printing is PostScript. Because of that, Sketch identifies fonts with their PostScript names and must know how to get the appropriate metrics (these tell Sketch how to place the individual letters for instance) and it must know X's name for the font (to be able to show the text on the screen appropriately).

The information Sketch needs to map the PostScript names to metric-filenames (.afm-files) and X font names is stored in .sfd-files.

sfd-Files

An sfd-file maps font names to the filenames of the afm-files and to various font attributes like weight and width and to two strings that are used to build the font name for X.

For example, the line concerning the Courier font in Resources/Fontmetrics/std.sfd is:
Courier, ... ,-adobe-Courier-medium-r-normal,iso8859-1,pcrr8a

This tells Sketch that the metrics file is pcrr8a.afm and that the first part of the font name is -adobe-Courier-medium-r-normal and its last part is iso8859-1. The parts missing from the font name describe the size and transformation and are automatically filled in by Sketch. Sketch assumes that fonts can be arbitrarily scaled and transformed. (The XFree servers often used on Linux have this capability; other servers on other platforms may not)

If the font is not installed in the server (either the X-server or the font server), or if it is installed under a different name, Sketch will not be able to display the text.

On start-up, Sketch reads all sfd-files it finds in the directories listed in its font-path.

The font-path

Sketch maintains a list of directories where it searches for font-related files like sfd-files and metrics. Note that this is a sketch-specific font-path and has nothing to do with X's font-path.

By default (as of version 0.6.2) the font-path consists of the directories Resources/Fontmetrics (relative to where Sketch is installed), /usr/X11R6/lib/X11/fonts/Type1 and /usr/share/ghostscript/fonts.

If you need to add directories or otherwise modify the font-path, you can do so in Sketch's start-up file, ~/.sketch/userhooks.py, which is executed by Sketch if it exists. E.g. to add a directory to the font-path you could put this code into userhooks.py:
from Sketch import config

config.font_path.append('/usr/local/share/fonts/bitstream')

The next step explains you how to add fonts to Sketch.
 
S u m m a r y
N e x t   p a g e