Newer
Older
Scratch / lockwasher / src / sys / include / objgfx / ogFont.h
#ifndef OGFONT_H
#define OGFONT_H

#include "objgfx30.h"

#define LeftText   0
#define CenterText 1
#define RightText  2
#define BottomText 0
#define TopText    2

typedef
  struct {
    char  ID[3];
    uInt8 version;
    uInt8 width, height;
    uInt8 numOfChars;
    uInt8 startingChar;
    uInt8 colourType;
    uInt8 paddington[7];
  } ogDPFHeader;

class ogBitFont  {
       protected:
        uInt32 fontDataIdx[256];
        uInt32 charWidthTable[256];
        uInt32 charHeightTable[256];
        void * fontData;
        uInt32 fontDataSize;
        ogRGB  BGColour;
        ogRGB  FGColour;
        uInt8  width, height;
        uInt16 numOfChars;
        uInt8  startingChar;
        
       public:
        ogBitFont();
        void putChar(ogSurface&, int32, int32, const char);
        void putString(ogSurface&, int32, int32, const char *);
        void setBGColor(uInt8, uInt8, uInt8);
        void setFGColor(uInt8, uInt8, uInt8);
        uInt32 getWidth(void) const { return width; };
        uInt32 getHeight(void) const { return height; };
        bool loadFrom(const char *, uInt32);
        bool saveTo(const char *, int32);
        void centerTextX(ogSurface&, int32, const char *);
        void justifyText(ogSurface&, uInt8, uInt8, const char *);
        bool load(const char *);
        bool save(const char *);
        uInt32 textHeight(const char *) const { return height; };
        uInt32 textWidth(const char *);
        ~ogBitFont(void);
}; // ogBitFont

#endif