2. Helper Macros

This interface expects the entire font to be loaded into a chunk memory somehow. From there, the interface will read the block.

The font record interface is mostly stored as a series of words, or 16-bit values that take up two bytes, stored in big-endian. To convert these big-endian values to native, a macro called BIG2INT is used.

<<macro_utils>>=
#define BIGINT(n) (((n & 0xFF) << 8) | n >> 8)

To read integers, a macro called MKINT is used. Does the same thing, only it expects to read from a buffer of bytes.

<<macro_utils>>=
#define MKINT(d, pos) ((d[pos] << 8) + d[pos + 1])

Most of the other macros are just "getters" for particular values in the font record that use the MKINT macro.

<<macro_getters>>=
#define FONTTYPE(d) (MKINT(d, 0))
#define FIRSTCHAR(d) (MKINT(d, 2))
#define LASTCHAR(d) (MKINT(d, 4))
#define WIDTHMAX(d) ((int16_t)MKINT(d, 6))
#define KERNMAX(d) ((int16_t)MKINT(d, 8))
#define NDESCENT(d) ((int16_t)MKINT(d, 10))
#define RECTWIDTH(d) ((int16_t)MKINT(d, 12))
#define RECTHEIGHT(d) ((int16_t)MKINT(d, 14))
#define OWTLOC(d) ((int16_t)MKINT(d, 16))
#define ASCENT(d) ((int16_t)MKINT(d, 18))
#define DESCENT(d) ((int16_t)MKINT(d, 20))
#define LEADING(d) ((int16_t)MKINT(d, 22))
#define ROWWORDS(d) ((int16_t)MKINT(d, 24))
#define BITMAPS(d) (&d[26])
<<macros>>=
<<macro_utils>>
<<macro_getters>>



prev | home | next