//! FIGlet font loader (c) 2009 Gaz Davidson #ifndef __IRR_C_GUI_FIGLET_FONT_H_INCLUDED__ #define __IRR_C_GUI_FIGLET_FONT_H_INCLUDED__ #include "IGUIFont.h" #include "IReadFile.h" #include "irrArray.h" #include "irrMap.h" namespace irr { namespace gui { class CGUIFIGletFont : public IGUIFont { public: //! Constructor CGUIFIGletFont(IGUIFont *baseFont); //! Destructor virtual ~CGUIFIGletFont(); //! Loads the font from the given file bool load(io::IReadFile* input); //! Draws some text and clips it to the specified rectangle if wanted. virtual void draw(const wchar_t* text, const core::rect& position, video::SColor color, bool hcenter=false, bool vcenter=false, const core::rect* clip=0); //! Calculates the width and height of a given string of text. virtual core::dimension2d getDimension(const wchar_t* text) const; //! Calculates the index of the character in the text which is on a specific position. virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const; virtual void setKerningWidth (s32 kerning) { } virtual void setKerningHeight (s32 kerning) { } virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const; virtual s32 getKerningHeight() const { return 0; } virtual void setInvisibleCharacters( const wchar_t *s ) { } private: struct SFIGChar { // The width of this letter s32 Width; // The X start position of this letter s32 Start; }; core::map CharMap; core::array Characters; // for loading void markLine(c8* &startPos); s32 getInt (c8* &startPos); // text lookup s32 getAreaFromCharacter(wchar_t c) const; // fill output buffer5 void generateText(const wchar_t* text) const; // kerning/smushing s32 getFIGKerning(const wchar_t *thisLetter, const wchar_t *previousLetter) const; IGUIFont *RealFont; c8 HardBlank; u32 Height, MissingChar, MaxLength; core::array FontData; // a place for the output characters to be saved, can be accessed from const methods core::array OutputBuffer; mutable core::stringw OutputBufferText; }; } // namespace gui } // namespace irr #endif // __IRR_C_GUI_FIGLET_FONT_H_INCLUDED__