diff --git a/src/sys/graphics/objfont.cpp b/src/sys/graphics/objfont.cpp index 051b7de..f3f9db0 100755 --- a/src/sys/graphics/objfont.cpp +++ b/src/sys/graphics/objfont.cpp @@ -52,6 +52,14 @@ return; } // TFont::JustifyText +bool TFont::Load(const char* FontFile) { + return LoadFrom(FontFile,0); +} // TFont::Load + +bool TFont::Save(const char* FontFile) { + return SaveTo(FontFile,0); +} // TFont::Save + UInt32 TFont::TextHeight(const char * TextString) { UInt32 size, tmpsize; size = 0; @@ -75,3 +83,36 @@ if (FontDataSize) free(FontData); return; } // TFont::~TFont + +/* TBMFont methods */ + +void TBMFont::SetColor(UInt32 colour) { + ColourTable[1] = colour; + return; +} // TBMFont::SetColor + +void TBMFont::SetIdxColor(UInt8 idx, UInt32 colour) { + ColourTable[idx] = colour; + return; +} // TBMFont::SetIdxColor + +void TBMFont::PutText(UInt32 x, UInt32 y, const char * TextString) { + UInt32 xx, yy; + char * offset; + UInt8 pix; + char ch; + if (!FontData) return; + while (*TextString) { + ch = *TextString; + if ((CharWidthTable[ch]) && (ch!=' ')) { + offset=FontData+FontDataIdx[ch]; + for (yy=0; yy<=CharHeightTable[ch]-1; yy++) + for (xx=0; xx<=CharWidthTable[ch]-1; xx++) { + pix = (UInt8)*offset; + if (pix) Buf->putpixel(x+xx,y+yy,ColourTable[pix]); + } // for xx + x+=CharWidthTable[ch]; + } // if charwidthtable + } // while + return; +} // TBMFont::PutText diff --git a/src/sys/graphics/objfont.h b/src/sys/graphics/objfont.h index 580b42d..f3a65bd 100755 --- a/src/sys/graphics/objfont.h +++ b/src/sys/graphics/objfont.h @@ -29,21 +29,37 @@ class TFont { protected: - UInt32 FontDataIdx[256]; + char * FontDataIdx[256]; UInt16 CharWidthTable[256]; UInt16 CharHeightTable[256]; TGfx0* Buf; UInt32 FontDataSize; - void * FontData; + char * FontData; public: TFont(TGfx0 *); virtual void PutText(Int32, Int32,const char *)=0; void CenterTextX(Int32 Y, const char *); void JustifyText(UInt8, UInt8, const char *); + bool Load(const char *); + virtual bool LoadFrom(const char *, UInt32)=0; + 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); + void PutText(UInt32, UInt32, const char *); + +}; #endif diff --git a/src/sys/graphics/objgfx30.h b/src/sys/graphics/objgfx30.h index 59b21a4..4f1b7f7 100755 --- a/src/sys/graphics/objgfx30.h +++ b/src/sys/graphics/objgfx30.h @@ -5,8 +5,13 @@ #ifndef OBJGFX30_H #define OBJGFX30_H -#define TRUE 1 -#define FALSE 0 +#ifndef TRUE + #define TRUE 1 +#endif +#ifndef FALSE + #define FALSE 0 +#endif + #define gm320x200x256 0x13 #define gm640x480x256 0x101 #define gm800x600x256 0x103