#ifndef _BITMAP_FONT_FILE_H #define _BITMAP_FONT_FILE_H #include #include #include #include "BitmapFont.h" class BitmapFontFile{ private: hash_map fonts; public: BitmapFontFile(const string& filename){ ifstream from(filename.c_str()); if(!from) { cerr << "Cannot open input file " << filename << '\n'; abort(); } long code; string hexdata; while(!from.eof()){ string line; getline(from,line); string::size_type pos=line.find(' '); string key; string rest; if(pos!=string::npos){ key=line.substr(0,pos); rest=line.substr(pos+1); } else key=line; if(key.compare("STARTCHAR")==0){ code=strtol(rest.c_str(),0,16); } else if(key.compare("BITMAP")==0){ hexdata=""; } else if(key.compare("ENDCHAR")==0){ fonts[code]=BitmapFont(24,24,hexdata); } else hexdata+=key; } } BitmapFont find(int code){ return fonts[code]; } }; #endif /* _BITMAP_FONT_FILE_H */