/*
 *	Two interfaces to HBF files -- take your pick.
 *
 *	Ross Paterson <rap@doc.ic.ac.uk>
 */
#ifndef _HBF_
#define _HBF_

#ifndef __STDC__
#	ifndef const
#		define const
#	endif
#endif

/*@*/

/*
 *	#1: a lightweight C interface.
 */

typedef	unsigned int	HBF_CHAR;

typedef struct {
	unsigned short	hbf_width;
	unsigned short	hbf_height;
	short		hbf_xDisplacement;
	short		hbf_yDisplacement;
} HBF_BBOX;

typedef struct {
	/* fields corresponding to the definition */
	HBF_BBOX	hbf_bitmap_bbox;	/* HBF_BITMAP_BOUNDING_BOX */
	HBF_BBOX	hbf_font_bbox;		/* FONTBOUNDINGBOX */
} HBF;


/* but defined here as a macro */
#define	hbfBitmapBBox(hbf)	(&((hbf)->hbf_bitmap_bbox))

/* but defined here as a macro */
#define	hbfFontBBox(hbf)	(&((hbf)->hbf_font_bbox))

#define	HBF_RowSize(hbf)\
	((hbfBitmapBBox(hbf)->hbf_width + 7)/8)

#define	HBF_BitmapSize(hbf)\
	(HBF_RowSize(hbf) * hbfBitmapBBox(hbf)->hbf_height)

#define	HBF_GetBit(hbf,bitmap,x,y)\
	(((bitmap)[(y)*HBF_RowSize(hbf) + (x)/8]>>(7 - (x)%8))&01)


/*@*/

/*
 *	#2: taken from Appendix 2 of the HBF draft.
 */

typedef	unsigned int	HBF_HzCode;
typedef unsigned char	HBF_Byte ;
typedef HBF_Byte *	HBF_BytePtr ;
typedef HBF *	        HBF_Handle ;
typedef HBF_Handle *    HBF_HandlePtr ;
typedef char *	        String ;

extern void hbfClose (HBF *hbfFile);

#endif
