MKICONFONT(1) — USER COMMANDS
NAME
mkiconfont — make an ASCII cursor or icon font from a list of ASCII bitmap files
SYNOPSIS
mkiconfont [ listfilename ] [ fontname > filename.afb ]
DESCRIPTION
mkiconfont makes an ASCII version of the font fontname from the ASCII bitmap files that are listed in listfilename and puts the output in the file filename.afb. The convention is to use the suffix .afb for the output file. The ASCII bitmap files must conform to a specific format.
mkiconfont is used to create cursor fonts and icon fonts. Each cursor has a cursor image and a mask image that are superimposed to create the complete cursor. To create a cursor font, first make a bitmap file for the cursor image and another bitmap file for the mask image. Then make a list of your cursor image and mask image bitmap files, and save your list as listfilename. Next run mkiconfont, and then run the output filename.afb through the convertfont(1) and bldfamily(1) utilities. Follow the same procedure to make an icon font, but omit the mask image files.
EXAMPLE
The font utility mkiconfont expects input in the format illustrated by the examples below. Here is an example of an ASCII bitmap file for a cursor image named pointer. Its image is that of a narrow arrow that points up and to the left.
/∗ Format_version=1, Width=16, Height=16, Depth=1
∗ Valid_bits_per_item=16, XOrigin=0, YOrigin=15
∗/
0x0000,0x4000,0x6000,0x7000,0x7800,0x7C00,0x7E00,0x7800,
0x4C00,0x0C00,0x0600,0x0600,0x0300,0x0300,0x0180,0x0000
XOrigin and YOrigin indicate the origin of the character, which is the hot-spot of the cursor. The values for XOrigin and YOrigin originate in the bitmap’s lower left corner with positive values extending up and to the right. Note that YOrigin starts from the last non-zero row of pixels rather than from the bottom of the bitmap.
Here is the ASCII bitmap file for the mask image of the pointer cursor. It is called pointer_mask.
/∗ Format_version=1, Width=16, Height=16, Depth=1
∗ Valid_bits_per_item=16, XOrigin=0, YOrigin=16
∗/
0xC000,0xE000,0xF000,0xF800,0xFC00,0xFE00,0xFF00,0xFF80,
0xFE00,0xDF00,0x9F00,0x0F80,0x0F80,0x07C0,0x07C0,0x03C0
Note that the mask image is used to outline the primary image, and therefore its origin is offset by one from the primary image, so as to superimpose the images correctly. This arrangement is typical of cursor masks. Here is the process for generating a simple cursor font (the process is the same for generating an icon font, except that no mask images are needed):
1)Generate a collection of ASCII bitmap file pairs with the format described above. The convention is to call each cursor image name.cursor and its mask image name_mask.cursor. Create a file containing these filenames, with each name on a separate line. The pair order should be the cursor image filename on one line followed by the mask image filename on the next line. You can give your list any filename. In this example, the file is called myfont.list.
2)Make an ASCII version of the font from the list of ASCII bitmap files using the program mkiconfont. The first argument to mkiconfont is the name of the file that contains the list of filenames. The second argument to mkiconfont is the name of the output file prepended by a > and the intended name of the font family.
example% mkiconfont myfont.list MyFont>MyFont12.afb
3)Convert the ASCII version of the font to a binary version using the program convertfont(1). The first argument should be a -d flag followed by the directory in which you want to put the resulting binary font file. You will want to put your output font file in your font directory; in this example, the font directory is $OPENWINHOME/lib/fonts. The next argument is the name of the file that contains the ASCII version of the font. convertfont names the output file like the ASCII version, but it uses a .fb suffix instead of a .afb suffix. In this example, the ASCII version is in the file called MyFont12.afb, and the output file that convertfont produces is called MyFont12.fb. example% convertfont -d$OPENWINHOME/lib/fonts MyFont12.afb
4)Build a font family file for the font, using the program bldfamily(1). The only argument to bldfamily is the name of the directory in which the font files are located. bldfamily looks in the specified directory for files with extensions .fb and .fm and constructs a NeWS font family file for each group of fonts with the same family name.
example% bldfamily -d$OPENWINHOME/lib/fonts
5)Create a .ps file that contains a dictionary of character names for the font. The .afb and .fb files associate a number with each character in the font; it is more convenient to associate the name of each bitmap file with the character that it represents. The following example shows one way to build such a .ps file.
#! /bin/sh
egrep "^(STARTCHAR|ENCODING)" MyFont12.afb>myfont.ps
ed - myfont.ps<<’EOFt’
g/STARTCHAR/j
1,$s’STARTCHAR ∗\(.∗)ENCODING ∗\(.∗\)’/\1 /\2 def’
1i
/myfontdict 300 dict def
myfontdict begin
.
$a
end
/showmyfont {
currentfont ( ) dup 0 myfontdict 5 index get put
myfontfont setfont show setfont pop } def
/myfont (MyFont) findfont 12 scalefont def
.
w
q
EOT
Another way to implement the name association is to have mkiconfont build the .ps file; this method is also a valid implementation.
6)Copy the .ps file to a well-known place.
example% cp myfont.ps $OPENWINHOME/lib/NeWS
7)Use the .ps file before you use the font in your POSTSCRIPT program.
(NeWS/myfont.ps) run
myfontdict begin
name name_mask myfont newcursor
end
Note that your .ps file created the dictionary myfontdict for you. You can then push the dictionary on the stack and use it in the normal way.
SEE ALSO
FUTURE DIRECTIONS
In the future, mkiconfont will be replaced with a more sophisticated font editing tool. The new tool will be useful for creating any new font, rather than just being useful for fonts with a limited number of characters such as icons and cursors.
Sun Release 4.0 — Last change: 15 June 1989