00001
00002
00003
#ifndef MOD_SFONTLOADER_H
00004
#define MOD_SFONTLOADER_H
00005
00006
00007
00008
00009
#include <string>
00010
00011
using namespace std;
00012
00013 class SFontLoader
00014 {
00015
public:
00016
00017 enum AlphaLoadingType{
00018
00019
NONE,
00020
00021
BLACK_MASK,
00022
00023
GREY_COLOUR
00024 };
00025
00026
SFontLoader();
00027 ~
SFontLoader();
00028
00029
00030
void loadFont(
const string &name);
00031
00032
00033
00034 void setAlphaLoadingType(AlphaLoadingType type){alphaType_ = type;}
00035
00036
void setAlpha(
unsigned char r,
unsigned char g,
unsigned char b);
00037
00038
00039
void setSeperatorColour(
unsigned char r,
unsigned char g,
unsigned char b);
00040
00041
00042
00043
00044 void setFontDefinition(
const string &definition)
00045 {fontDefinition_ = definition;}
00046
00047
00048
00049
00050
unsigned char *getDataForCharacter(
char character);
00051
00052
00053
int getCharacterWidth(
char character);
00054
00055 int getCharacterHeight(){
return fontDataHeight_-1;}
00056
00057 int getFontHeight(){
return fontCellHeight_;}
00058
00059 int getFontWidth(){
return fontCellWidth_;}
00060
00061
private:
00062
void findCharWidths(
unsigned char *result);
00063
void unloadGfx();
00064
void loadCharacter(
unsigned char number,
unsigned char *inputData,
00065
unsigned char *outputData);
00066
void readNumber(ifstream &file,
int &number);
00067
unsigned char *loadPpm(
const string &fileName,
int &width,
int &height);
00068
void findCellSizes();
00069
inline bool isSpaceColour(
unsigned char* data);
00070
00071
unsigned char alphaR_, alphaG_, alphaB_;
00072
unsigned char seperatorR_, seperatorG_, seperatorB_;
00073 AlphaLoadingType alphaType_;
00074 string fontDefinition_;
00075
00076
unsigned char *fontData_;
00077
int fontCellHeight_;
00078
int fontDataHeight_;
00079
int fontCellWidth_;
00080
int fontDataWidth_;
00081
00082
unsigned char * fontGfxTiles[256];
00083
int charWidth_[256];
00084
int definitionFontWidths_[256];
00085
int numberOfCharsInFont_;
00086 };
00087
00088
bool SFontLoader::isSpaceColour(
unsigned char* data)
00089 {
00090
return (seperatorR_ == data[0] && seperatorG_ == data[1] &&
00091 seperatorB_ == data[2]);
00092 }
00093
00094
00095
00096
#endif