struct font_header {
  UH mincode;
  UH maxcode;
  UH height;
  H  ascender, descender;
  UH numchars;
} __attribute__((packed));

struct char_desc {
  UB width, height, pitch;
  B top, left, advance;
  int offset;
} __attribute__((packed));

struct font_desc {
  UH mincode;
  UH maxcode;
  UH height;
  H  ascender, descender;
  UH maxwidth;
  UH mono;
  UH startpage;
  const UB *baseaddr;
  struct char_desc *chartab;
  struct font_desc *efont;
};

typedef struct font_desc FONT;

struct region {
  UH xpos, ypos;
  UH width, height;
};

#define	AL_LEFT		0
#define	AL_CENTER	1
#define	AL_RIGHT	2

void font_open(struct font_desc *fdesc, const UB *fdata);
void font_string_put(struct font_desc *fdesc, UH *str, struct region *regionp, int fgcolor, int bgcolor, int align);
void font_string(struct font_desc *fdesc, UH *str, int xpos, int ypos, int fgcolor, int bgcolor);
void cfont_string(struct font_desc *fdesc, UH *str, int xpos, int ypos, int fgcolor, const UH *bgimage);
int font_max_width(struct font_desc *fdesc);
