Font management and creation is a subject which has long been shrouded in mystery. This chapter hammers out the truth about typefaces and guides us into our first foray with fontforge

Fontology for the lazy existentialist

Tabitha sits back from the screen and screws her face up again. "I don't like any of these fonts!". She has been wrestling with the design of Pengwyn Parc's new home page all morning.

Baz looks over her shoulder, "We could download some new ones off the Internet, there are loads of free fonts out there."

Tabitha tuts, "Yeah but most of them are reverse-engineered rip-offs of someone else's design."

"So what?" Baz retorts "Fonts should be free."

"Yeah, but we don't want to be using the same typeface as everyone else. Why don't we design our own? Then it would always be unique."

"Can you make your own fonts using Linux?" asks Ashlee, suddenly interested in the conversation. "Having our own designer typeface for our promo graphics would be really cool!"

"Yeah sure," sighs Baz, "Using FontForge, it's not that hard to actually do, but it is very time-consuming. And then you have to install the flipping things. Why don't you just use Tahoma or Verdana or something?"

"I'm already using Bitstream Vera Sans for the text, that's fine, and there's always Nimbus or Luxi, so there's no need to use awful fonts like Helvetica or Arial ever again!"

Ashlee makes sicky noises at the mention of Arial while Tabi continues enthusiastically; "I want something new for the headlines and titles and I just don't like any of the fonts we've got installed. I bet we can get our heads around it if we take it step by step"

Baz shakes his head in disbelief.

"What's a typeface?" asks Kenny.

Inspector Vector decodes the magic glyphs

A typeface is a collection of fonts with a similar or compatible visual style. A font is a collection of renderable glyphs organised into characters and a glyph is made up of the contours and shapes that represent a character, the same character can be represented by several different glyphs. Computer fonts must also contain information on how to map an input string of bytes into an output display of visual glyphs. This mapping is called an encoding. A font may also contain information on how to compose ligatures and accents.

The study of fonts and typefaces can become quite complex and esoteric, but fortunately it is not necessary to get involved in too much detail in order to get started. In this article we will be taking it nice and easy. That said, in order to produce results that look professional, clean, beautiful and comfortable, it is worth learning a little more about how fonts are displayed. The documentation that comes with FontForge is pretty extensive and comprehensive, so we'll just deal with the basics here.

Fonts are stored using various different File types:

  • PCF is a Binary bitmap font compiled from BDF, with a platform and endian independent representation. Bitmap fonts are occasionally used for screen display, they do not resize well;
  • PostScript fonts are vector fonts designed primarily for printing, developed by Adobe. PFA files refer to Type 1 PostScript font in text format and PFB is a Type 1 PostScript font in binary format. These outline vectors require an accompanying AFM or PFM file, which contains the font metrics;
  • TTF files are TrueType fonts - single file vector fonts for screen display, developed by Apple and supported on Linux by the FreeType library. TrueType fonts usually print well too and it is the most universal format nowadays, although a few applications still do not support it;
  • There are many other font formats, which can mostly be ignored for now, apart from mentioning MetaFont, which is useful for TeX users.

The size of a font is usually measured in points, which are print dots, there are exactly 72 points to an inch. Ordinary text is usually between 9 and 12 points, headline fonts can be up to 72 points and larger. Pixels are screen dots, screens can vary in resolution from 72 to 96 dpi and beyond. Printing is usually done at upwards of 300 dpi. It is important to understand the differences between the available mediums.

The team spend the rest of the afternoon drawing alphabets in their creative diaries with a variety of black felt-tips.

"Make sure you leave enough space between the lines and keep the letters well separate, because we will need to be able to cut them out individually." Ashlee points out.

Tabitha scrumples up a page of her diary and starts again. By the end of the afternoon after several false starts, they each have a potential alphabet designed. They all agree that Kenny's is the neatest, so they put it in the scanner and import it into GIMP using the File > Acquire > XSane > Device dialog and following the instructions. If you don't have a scanner set up there are many ways of creating your letters, including directly in FontForge using your mouse and bézier tools, so don't despair!

Forging ahead

FontForge is George Williams' free Open Source UNIX-based font editor for type 1 and TrueType fonts, previously called Pfaedit. It also does TrueType collections (TTC) and opentype fonts. When we open up FontForge from the desktop applications menu we are presented with an Open Font dialog. Click on New and you will be presented with an empty font view window. Double-clicking on a glyph will bring up an outline glyph window. This is where you edit the bézier splines that make up the individual contours. We can give our new font a name by clicking on Element > Font Info... We can also set a copyright notice here and rather a lot of other information which affects the whole font. The defaults are suitable for PostScript fonts, so we will accept them for now. TrueType fonts may benefit from different settings, but fortunately FontForge usually manages to do the right thing. You may also wish to use Encoding > Reencode to change what characters are available in your font. FontForge generally creates new fonts with an ISO-8859-1, which contains (most of) the characters needed for Western Europe.

Tabitha found that simply copy-pasting the letter shapes from GIMP into FontForge didn't really work the way she had hoped, so she had to split them up into separate files using the GIMP and then import them individually into FontForge using the File > Import... function. The internal text format for fonts is called SFD. It is a format that is acceptable for communicating and storing fonts. Now would be a really good time to save your work in that format (File -> Save).

Editing the font images

Now we need to resize the bitmaps to fit. Double-click on one of the glyphs again and select Back from the Layers palette, this will enable the background to be edited. You can then drag the image around so that it sits on the baseline and fits inside the 1000x1000 box in an appropriate manner. If you are working from scratch it is recommended to create a base glyph with all the lines your letters will need using the bitmap editor, a circled cross is often a good starting point, and then edit that to create all the letters you require, starting with A, R. O. H & T. You will notice that many of the letter shapes are related to one another, so new glyphs can be created by flipping shapes on the horizontal or vertical axes. This technique can be used to fill in glyphs that are missing from the original design and will produce consistency in the final look of the font.

If you have the autotrace program installed you can generate an outline from the image using the menu entry; Element > AutoTrace. Otherwise you will have to add the points yourself. Make the Foreground layer active and select the curve point tool from the Tools palette (The round circle on a line). Click around the shape on the corners and straight lines, preferably in a clockwise fashion, making sure you close the path by adding a new point on top of the old start point. It is then possible to fine tune the contours using a combination of the Points menu and dragging the control points around with the mouse. Remember to select the Pointer tool for this bit. The representation of the glyph will change in the font view window as you edit, so you can easily check your progress.

Note that the glyph for 'O' has two contours: the inner and outer circles. If all you see is a big black dot it is most likely to be because the inner contour is going in the wrong direction in relation to the outer contour. This is easily solved by flipping the direction of the inner contour. Within FontForge all outer boundaries must be drawn clockwise, while all inner boundaries must be drawn counter-clockwise. This condition applies to any glyphs involving enclosed spaces. The command Element > Correct Direction can be used to automatically correct this kind of error.

Spacing and Kerning - Font Metrics

Once you have created the glyph shapes, the next task is to specify the spacing between the glyphs. The metrics window can be brought up from Window > New Metrics Window. From here you can adjust the spacings of each letter relative to the others either by typing values into the text fields below or dragging the shapes and lines into the desired positions. The widths of the glyphs and the kernings can be set automatically from the Metrics menu, but this can produce some alarming effects. Kerning is the process of setting the spacing between specific pairs of letters. This can take quite a bit of fiddling around and it is best to get the individual glyphs the right width before attempting to set any kernings.

FontForge also has facilities to create hints to help the font renderer find horizontals and verticals, and produce consistent serifs and stem widths at small point sizes. It is possible to create ligatures, accents and alternative glyphs as well. It can also deal with right-to-left and vertical alignments and most conceivable encodings. It can handle Chinese, Japanese and Korean fonts as well as Arabic type styles.

In order to make your font usable, you first need to save it in a standard font format (File > Generate Fonts...). Although it seems like there are a bewildering array of choices, in fact you want to Choose PS Type1 or TrueType in most circumstances. The default setting will serve us perfectly well for now.

Installing your new fonts

Create a new directory for your fonts. Fonts appear to be stored in an alarming array of places, these can vary from distro to distro, so it's best to check your documentation for this. Be aware that some of these instructions may have to be carried out as root.

Don't touch the usual directories under /usr/share/fonts/, which contain the base X11 fonts and instead create two new directories for selected TrueType and Type 1 fonts, for example /usr/local/share/fonts/type1/ and /usr/local/share/fonts/truetype/. You can also put private fonts in ~/.fonts/ if you want.

Now, either copy all the TrueType fonts (*.ttf) that you need into the truetype/ directory or copy the Postscript fonts (*.afm and *.pfb) into the type1 directory. Next, we need to tell X about your fonts. The process is slightly different for each format.

The old way of installing TrueType fonts involved entering the following commands in sequence from a terminal window:

cd /usr/local/share/fonts/truetype/
ttmkfdir > fonts.scale

PostScript fonts used the type1inst command instead of ttmkfdir.

If you view the directory you should now see two new files among the truetype fonts - "fonts.scale" and "fonts.dir". These files simply contain a list with the full font names for each TrueType font.

Now we need to add these new directories to the font server path - the list of locations which XWindows will search for fonts. Edit the X configuration file (/etc/X11/xorg.conf) and find the "Files" Section; in most standard versions of this file it will be near the top. In this Section is a list of FontPath entries. All we need to do is add our new directory to this list, by adding a couple of lines like this:

FontPath "/usr/local/share/fonts/truetype"
FontPath "/usr/local/share/fonts/type1"

64 Studio users can regenerate all the necessary files simply using fc-cache with the -f option. Should that fail you may have to edit the file /etc/X11/xfs/config, find the line which starts with "catalog=", and add your directory at the end of the list, separated by a comma. There may be other files that you need to edit in order to make the fonts fully available to all applications. The fonts for usually need to be configured separately. You really must check your documentation for this part.

You will probably need to restart the font server for it to register the new fonts. The easiest way to do this is to log out and back in to your desktop. You may need to run xset fp rehash as well. You can also easily add the new font paths to the running instance of the X server with the xset utility, like this:

$ xset fp+ /usr/local/share/fonts/truetype
$ xset fp+ /usr/local/share/fonts/type1

Once you've done this you can use xset q to verify that the new path exists in the running server's font list. You can test it now by running the xfontsel program from the terminal, or run the Font Selector program from the Utilities menu in GNOME. You should immediately see the name of your new font in the list. Your work is done and your new font is now ready to use.


FontForge - An Outline Font Editor
Frequently Asked Questions

Frequently asked questions about fonts
Fonts FAQ