#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 {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 TAbstractFont { public: virtual void putText(TGfx0&, Int32, Int32, const char *)=0; virtual bool loadFrom(const char *, uInt32)=0; virtual bool saveTo(const char *, Int32)=0; }; class TFont : public TAbstractFont { protected: uInt32 FontDataIdx[256]; uInt16 CharWidthTable[256]; uInt16 CharHeightTable[256]; TGfx0* Buf; uInt32 FontDataSize; void * FontData; public: TFont(); // virtual void PutText(Int32, Int32,const char *); void centerTextX(TGfx0&, Int32, const char *); void justifyText(TGfx0&, 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: TRGB ColourTable[32]; public: TBMFont(void): TFont() { for (uInt32 tmp=0; tmp<=31; tmp++) { ColourTable[tmp].red = 255; ColourTable[tmp].green = 255; ColourTable[tmp].blue = 255; } // for } void setColor(uInt8, uInt8, uInt8); void setIdxColor(uInt8, uInt8, uInt8, uInt8); virtual void putText(TGfx0&, Int32, Int32, const char *); }; class TDPFont : public TBMFont { protected: uInt8 Width, Height; uInt16 NumOfChars; uInt8 StartingChar; public: TDPFont(void) : TBMFont() { Width = 0; Height = 0; NumOfChars = 0; StartingChar = 0; } virtual void putText(TGfx0&, Int32, Int32, const char *); virtual bool loadFrom(const char *, uInt32); virtual bool saveTo(const char *, Int32); }; #endif