#ifndef OBJFONT_H
#define OBJFONT_H
#include "objgfx30.h"
#define LeftText 0
#define CenterText 1
#define RightText 2
#define BottomText 0
#define TopText 2
enum TFontType {BLF, BMF, DPF};
typedef struct {
char ID[4];
UInt8 BPP;
UInt8 paddington[10];
} TFontHeader;
typedef struct {
char ID[3];
UInt8 Version;
UInt8 Width, Height;
UInt8 NumOfChars;
UInt8 StartingChar;
UInt8 ColourType;
UInt8 paddington[7];
} TDPFHeader;
class TFont_abstract {
public:
virtual void PutText(Int32, Int32, const char *)=0;
virtual bool LoadFrom(const char *, UInt32)=0;
virtual bool SaveTo(const char *, Int32)=0;
};
class TFont : public TFont_abstract {
protected:
UInt32 FontDataIdx[256];
UInt16 CharWidthTable[256];
UInt16 CharHeightTable[256];
TGfx0* Buf;
UInt32 FontDataSize;
void * FontData;
public:
TFont(TGfx0 *);
// virtual void PutText(Int32, Int32,const char *);
void CenterTextX(Int32, const char *);
void JustifyText(UInt8, UInt8, const char *);
bool Load(const char *);
virtual bool LoadFrom(const char *, UInt32);
bool Save(const char *);
// virtual bool SaveTo(const char *, Int32) = 0;
UInt32 TextHeight(const char *);
UInt32 TextWidth(const char *);
virtual ~TFont(void);
}; // TFont
class TBMFont : public TFont {
protected:
UInt32 ColourTable[256];
public:
TBMFont(TGfx0 *Buffer): TFont(Buffer) {
for (UInt32 tmp=0; tmp<=255; tmp++) ColourTable[tmp]=tmp;
}
void SetColor(UInt32);
void SetIdxColor(UInt8, UInt32);
virtual void PutText(Int32, Int32, const char *);
};
class TDPFont : public TBMFont {
protected:
UInt8 Width, Height;
UInt16 NumOfChars;
UInt8 StartingChar;
public:
TDPFont(TGfx0 * Buffer) : TBMFont(Buffer) {
Width = 0;
Height = 0;
NumOfChars = 0;
StartingChar = 0;
}
virtual void PutText(Int32, Int32, const char *);
virtual bool LoadFrom(const char *, UInt32);
virtual bool SaveTo(const char *, Int32);
};
#endif