diff --git a/src/sys/graphics/main.cpp b/src/sys/graphics/main.cpp index fd04d74..519a4c9 100755 --- a/src/sys/graphics/main.cpp +++ b/src/sys/graphics/main.cpp @@ -16,8 +16,10 @@ b=0; TGfx0* buf=0; TGfx0* buf2=0; + TDPFont* font=0; buf = new TGfx0(); buf2 = new TGfx0(); + font = new TDPFont(buf); buf->create(400,400,(TPixelFmt *)&def_pixfmt_32bpp); buf2->create(400,400,(TPixelFmt *)&def_pixfmt_15bpp); buf->putpixel(11,10,10169); @@ -25,5 +27,6 @@ printf("%d\n",(int)foo); if (buf) delete buf; if (buf2) delete buf2; + if (font) delete font; return(0); } diff --git a/src/sys/graphics/objfont.cpp b/src/sys/graphics/objfont.cpp index e0d0041..a84dca9 100755 --- a/src/sys/graphics/objfont.cpp +++ b/src/sys/graphics/objfont.cpp @@ -52,7 +52,7 @@ PutText(x,y,TextString); return; } // TFont::JustifyText - +/* bool TFont::Load(const char* FontFile) { return LoadFrom(FontFile,0); } // TFont::Load @@ -60,7 +60,7 @@ bool TFont::Save(const char* FontFile) { return SaveTo(FontFile,0); } // TFont::Save - +*/ UInt32 TFont::TextHeight(const char * TextString) { UInt32 size, tmpsize; size = 0; @@ -97,7 +97,7 @@ return; } // TBMFont::SetIdxColor -void TBMFont::PutText(UInt32 x, UInt32 y, const char * TextString) { +void TBMFont::PutText(Int32 x, Int32 y, const char * TextString) { UInt32 xx, yy; UInt8 * offset; UInt8 pix; @@ -121,7 +121,11 @@ /* TDPFont methods */ -void TDPFont::PutText(UInt32 x, UInt32 y, const char * TextString) { +bool TDPFont::SaveTo(const char * FontFile, Int32 Offset) { + return TRUE; +} + +void TDPFont::PutText(Int32 x, Int32 y, const char * TextString) { UInt32 xx, xcount, ycount; UInt8 * offset; UInt8 bits; @@ -148,11 +152,17 @@ bool TDPFont::LoadFrom(const char * FontFile, UInt32 Offset) { FILE * infile; -// TDPFHeader header; -// UInt32 lresult; + TDPFHeader header; + UInt32 lresult; if (FontData) free(FontData); infile = fopen(FontFile,"r"); -// fseek(infile,Offset,SEEK_SET); + fseek(infile,Offset,SEEK_SET); + lresult = fread(&header,sizeof(header),1,infile); + Width = header.Width; + Height = header.Height; + NumOfChars = header.NumOfChars; + if (!NumOfChars) NumOfChars = 256; + StartingChar = header.StartingChar; fclose(infile); return TRUE; diff --git a/src/sys/graphics/objfont.h b/src/sys/graphics/objfont.h index 3eb4ccc..e7265ed 100755 --- a/src/sys/graphics/objfont.h +++ b/src/sys/graphics/objfont.h @@ -27,7 +27,14 @@ UInt8 paddington[7]; } TDPFHeader; -class TFont { +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: void * FontDataIdx[256]; UInt16 CharWidthTable[256]; @@ -37,13 +44,13 @@ void * FontData; public: TFont(TGfx0 *); - virtual void PutText(Int32, Int32,const char *)=0; - void CenterTextX(Int32 Y, const char *); + // 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)=0; + // virtual bool LoadFrom(const char *, UInt32); bool Save(const char *); - virtual bool SaveTo(const char *, Int32)=0; + // virtual bool SaveTo(const char *, Int32) = 0; UInt32 TextHeight(const char *); UInt32 TextWidth(const char *); virtual ~TFont(void); @@ -58,22 +65,25 @@ } void SetColor(UInt32); void SetIdxColor(UInt8, UInt32); - void PutText(UInt32, UInt32, const char *); + 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; } - void PutText(UInt32, UInt32, const char *); + void PutText(Int32, Int32, const char *); bool LoadFrom(const char *, UInt32); + bool SaveTo(const char *, Int32); }; diff --git a/src/sys/graphics/objgfx30.h b/src/sys/graphics/objgfx30.h index 0296a3b..891352c 100755 --- a/src/sys/graphics/objgfx30.h +++ b/src/sys/graphics/objgfx30.h @@ -39,11 +39,11 @@ typedef signed char Int8; typedef signed short int Int16; -typedef signed long Int32; +typedef signed long int Int32; typedef unsigned char UInt8; typedef unsigned short int UInt16; -typedef unsigned long UInt32; +typedef unsigned long int UInt32; enum og_DataState { og_None, og_Owner, og_Aliasing };