XBfe (X Bitmap Font Editor) allows you to hand-edit a bitmap font--both the shapes (i.e., the pixels) and the metric information (set widths, side bearings, and kerning tables).
The input is both a bitmap (GF or PK) font and a corresponding TFM file. If you have only a bitmap font for some reason, you can make a TFM file with Fontconvert (see section Fontconvert output options). XBfe outputs (at your command) the edited files in the current directory with the same name, thus possibly replacing the input file.
XBfe is intended to edit existing fonts, not create new ones. For example, it does not provide a way to create new characters in a font. (you can add characters to a font using Fontconvert, though; see section Character selection options). In terms of its interaction with the other font utilities, it is most useful for making character shapes more amenable to Limn's outline fitting (see section Limn).
XBfe attempts to follow established user interface conventions for X programs:
AsciiText
widget, which is Emacs-like bindings.
.../mit/doc/tutorials/resources.txtin the X distribution if you aren't familiar with X resources. The class name is
XBfe
. The font utilities distribution comes with
an application resource file `XBfe' (which must be installed for
the program to function properly); see that file for possibilities of
what you might change.
The sections below describe the specific operations XBfe provides.
This section describes a few operations which do not directly involve editing, but rather managing of the editing session itself.
To exit XBfe, click on the `Exit' button. Any changes made since the last save are lost.
To save changes, click on the `Save' button. The new files are
written in the current directory--unless that would overwrite the input
files, in which case they are written to the directory `/tmp' (or
the value of the environment variable TMPDIR
, if it's set). When
you exit XBfe normally, the files are moved from the temporary directory
to your current directory, thus possibly overwriting the input.
To go back to the last saved version of a character you are editing, click on the `Revert' button. This is useful when you've made changes you didn't intend. If you exit without saving first, all changes (since the last save) will be lost, as mentioned above.
You can move to the previous character in the font, i.e., the one with the character code next smallest to the current one, by clicking on the `Prev' button. Similarly, you can move to the next character by clicking on the `Next' button. You can move to a specified character by typing its character code in the `Char' item and hitting RET. See section Specifying character codes, for the various possibilities for character codes.
The most basic operation for editing character bitmaps is to change black pixels to white or the reverse; put another way, inverting the pixel the mouse is on. You do this by clicking the third mouse button.
Technically, this is just a special case of changing more than one pixel: when you press the third button, the current pixel inverts; then, as you move the mouse, the pixels it touches change to the color the first pixel changed to. Thus, if you press the third button on a white pixel, the mouse effectively becomes a "black pen" (until you release the button).
XBfe supports selection, pasting, and filling operations on a rectangle of pixels, as follows.
To select an arbitrary rectangle, press the left mouse button to determine the first corner; then move the mouse (with the button still down) to update the other corner of the rectangle; and release the button to define the rectangle. (If you release the button when the mouse is off the character bitmap, the selection rectangle remains unchanged.)
Once a rectangle has been selected, you can paste it, either within the same character from which it was selected, or in a different character. To do this, press the middle button; this outlines the region that will be changed; as you move the mouse (with the button still down), the outline moves accordingly; when you release the middle button, the selected rectangle is pasted onto the current bitmap, erasing whatever was in the affected area.
Pasting has several variations: if you have the Alt (a.k.a. Meta) key down when you release the middle button, the selection is flipped vertically; if the Control key is down, the selection is flipped horizontally; and if both are down, the selection is flipped in both directions. Here is a minimal example:
original vertical horizontal both ** * ** * * ** * **
This is useful when pasting serifs, since serifs are attached to the main stems in different orientations. (Incidentally, making the serif shapes consist of exactly the same pixels may actually make the serifs look different, because of surrounding character features or the difference in orientation. But it is still a good place to start.)
You can also fill the selected rectangle, i.e., change it to entirely black or white, by holding the Alt key down and pressing the right mouse button. The selection is filled with the color of the pixel the mouse is on. This is how you entirely erase a portion of the bitmap.
You can enlarge the bitmap on all four sides by clicking on the `Expand' button; i.e., this adds one blank row at the top and bottom, and one blank column at the left and right. This is useful when you need to fill out a truncated curve, lengthen a stem or serif, etc.
XBfe correspondingly changes the side bearings and baseline position so that the origin of the character does not change. In other words, the new row at the bottom is below the baseline, and the new columns are in what was the side bearing space. You can change the baselines with Fontconvert (see section Character manipulation options, and the side bearings with Charspace (see section Charspace).
You can change the left side bearing for the current character by typing the new value in the `lsb' item (and hitting RET, as always for information you type). Likewise for the right side bearing and the `rsb' item. The side bearing values must be integers.
XBfe shows a box with any kerns for the current character. Each item in the kern box looks like `code: kern', where code is the character code (in decimal) of the character kerned with, and kern is the kern distance (in pixels). You can edit the kern distances just as with the side bearings; the values here are real numbers.
You can add new kerns by typing the character code of the new kerned-with character in the `Add kern' item; then a kern item with that code is added to the kern box, with a distance of zero (which you can then change to whatever you want). Similarly, you can delete a kern by typing the character code in the `Del kern' item.
This section describes the options that XBfe accepts. See section Command-line options, for general option syntax.
In addition to the above options, XBfe also accepts the standard X toolkit options (and resources), such as `-display' to specify the X server to use. See the documentation for any X program for a description of these options. Unlike the options above, you cannot use `--' to start X toolkit options, nor can you use `=' to separate option names and values; for example, neither `--display host:0' nor `-display=host:0' are recognized.