#ifndef __ABSTRACT_FONT_H
#define __ABSTRACT_FONT_H

#include "device.h"
#include "nintl.h"

#define DEFAULT_FONT_PATH "/rom/fonts"
#define MAX_PATH_LEN      256
#define MAX_LINE_LEN      256

#define INVALID_FONT_ID       -1

typedef struct _FontDescription FontDescription;
typedef struct _FontDir FontDir;
typedef struct _FontMap FontMap;
typedef struct _FontObject FontObject;
typedef int FontID;

#define STR_MATCH(_s1, _s2) \
	((_s1)[0] == '*' || (_s2)[0] == '*' || !strcasecmp((_s1), (_s2)))
#define INT_COMPARE(_i1, _i2) \
	(((_i1) == 0 || (_i2) == 0) ? 0 : abs((_i1) - (_i2)))

#define FONT_GOODNESS_BAD_FOUNDRY      2000
#define FONT_GOODNESS_BAD_FACE         2000
#define FONT_GOODNESS_BAD_WEIGHT       1000
#define FONT_GOODNESS_BAD_SLANT        1000
#define FONT_GOODNESS_BAD_SET_WIDTH    1000
#define FONT_GOODNESS_BAD_VARIANT      1
#define FONT_GOODNESS_BAD_PIXEL_SIZE   100
#define FONT_GOODNESS_BAD_POINT_SIZE   5
#define FONT_GOODNESS_BAD_RES_X        1
#define FONT_GOODNESS_BAD_RES_Y        1
#define FONT_GOODNESS_BAD_SPACING      100
#define FONT_GOODNESS_BAD_AVG_WIDTH    1
#define FONT_GOODNESS_BAD_CHARSET      5000

struct _FontDescription {
	char *foundry;
	char *face;
	char *weight;
	char *slant;
	char *set_width;
	char *variant;
	int  pixel_size;
	int  point_size;
	int  res_x;
	int  res_y;
	char *spacing;
	int  avg_width;
	char *charset;
};

struct _FontDir {
	char            *fontname;
	FontDescription *fontdesc;
};

struct _FontMap {
	LanguageEncoding encoding;
	FontID           western_fid;
	FontID           asian_fid;
};

struct _FontObject {
	FontID     fid;
	int        height;
	int        attr;
	PMWFONT    pfont;
	int        ref_count;
	FontObject *next;
};

typedef struct {
	PMWFONTPROCS fontprocs;      /* Common Header */
	MWCOORD      fontsize;
	int          fontrotation;
	int          fontattr;

	FontID       western_fid;    /* Internal Data */
	int          western_height;
	PMWFONT      western_font;

	FontID       asian_fid;
	int          asian_height;
	PMWFONT      asian_font;

	LanguageEncoding encoding;
} MWABSTRACTFONT, *PMWABSTRACTFONT;

MWBOOL abstract_init		(PSD psd);
PMWFONT abstract_createfont	(const char *name,
				 MWCOORD height,
				 int fontattr);

#endif /* !__ABSTRACT_FONT_H */
