#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(TGfx0&, 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(); // 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