defrasterfont() — Silicon Graphics
NAME
defrasterfont - defines a raster font
SPECIFICATION
C
defrasterfont(n, ht, nc, chars, nr, raster)
short n, ht, nc, nr;
Fontchar chars[nc];
Ushort raster[nr];
FORTRAN
subroutine defras(n, ht, nc, chars, nr, raster)
integer*4 n, ht, nc, nr
integer*2 raster(nr), chars(4*nc)
Pascal
procedure defrasterfont(n, ht, nc: Short; var nr: Fontchar; chars: Short;
var raster: Short);
DESCRIPTION
defrasterfont defines a raster font and has six arguments. The first two are n, an index into the font table, and ht, an integer specifying the maximum height, in pixels, of characters in the font. The index n becomes the font’s internal name. nc gives the number of characters in the font and thus the number of elements in the chars array. Index 0 in the chars array corresponds to ASCII 0; index 1 to ASCII 1, and so on. Most fonts that are used to print ASCII data will therefore have the first 31 entries in the chars array unused. (The first 31 ASCII characters are non-printing.) chars contains a description of each character in the font. The description includes the height and width of the character in pixels, the offsets from the character origin to the lower left corner of this character’s bounding box, an offset into the array of rasters, and the amount to add to the current character position x after drawing the character. raster is an array of nr shorts of bitmap information. It is a one-dimensional array of mask shorts, ordered left to right and then bottom to top. Mask bits are left-justified in the character’s bounding box.
To replace a raster font, define the new one to have the same index as the old one. To delete a raster font, define a font with no characters. The default font, 0, is a fixed pitch font of height 16 and width 9. Font 0 cannot be redefined.
EXAMPLE
This example is a program that defines a font with three characters and displays them on the screen:
/* Define a font with three characters -- a lower-case j, an arrow,
* and a greek sigma. Use ascii values 1 and 2 (\001 and \002) for the
* arrow and sigma. Use the ascii value of j (= \152) for the j
* character. */
#include <gl.h>
#define EXAMPLEFONT 1
#define efont_ht16
#define efont_nc107
#define efont_nr38
unsigned short efont_bits[] = {
/* lower-case j */
0x7000, 0xd800, 0x8c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00,
0x0c00, 0x1c00, 0x0000, 0x0000, 0x0c00, 0x0c00,
/* arrow */
0x0200, 0x0300, 0x0380, 0xafc0, 0xafe0, 0xaff0, 0xafe0, 0xafc0,
0x0380, 0x0300, 0x0200,
/* sigma */
0xffc0, 0xc0c0, 0x6000, 0x3000, 0x1800, 0x0c00, 0x0600, 0x0c00,
0x1800, 0x3000, 0x6000, 0xc180, 0xff80,
};
#define ASSIGN(fontch, of, wi, he, xof, yof, wid) \
fontch.offset = of; \
fontch.w = wi; \
fontch.h = he; \
fontch.xoff = xof; \
fontch.yoff = yof; \
fontch.width = wid
Fontchar efont_chars[127];
main () {
ASSIGN(efont_chars[’j’], 0, 6, 14, 0, -2, 8);
ASSIGN(efont_chars[’\001’], 14, 12, 11, 0, 0, 14);
ASSIGN(efont_chars[’\002’], 25, 10, 13, 0, 0, 12);
gbegin();
defrasterfont (EXAMPLEFONT, efont_ht, efont_nc, efont_chars,
efont_nr, efont_bits);
font (EXAMPLEFONT);
cursoff();/* clear screen*/
color(BLACK);
clear();
color(WHITE);/* select text color*/
cmovi (10, 10);
charstr ("j\001\002\001jj\002");
sleep(5);
curson();
gexit ();
}
SEE ALSO
charstr, font
Figure 5.2 in the IRIS User’s Guide
NOTE
This command can be used only in immediate mode.
Version 2.4 — May 08, 1986