#ifndef __C_GUI_FONT_H_INCLUDED__
#define __C_GUI_FONT_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIFontBitmap.h"
#include "irrString.h"
#include "irrMap.h"
#include "IXMLReader.h"
#include "IReadFile.h"
#include "irrArray.h"
namespace irr
{
namespace video
{
class IVideoDriver;
class IImage;
}
namespace gui
{
class IGUIEnvironment;
class CGUIFont : public IGUIFontBitmap
{
public:
CGUIFont(IGUIEnvironment* env, const io::path& filename);
virtual ~CGUIFont();
bool load(const io::path& filename);
bool load(io::IReadFile* file);
bool load(io::IXMLReader* xml);
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
video::SColor color, bool hcenter=false,
bool vcenter=false, const core::rect<s32>* clip=0);
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const;
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const;
virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; }
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;
virtual IGUISpriteBank* getSpriteBank() const;
virtual u32 getSpriteNoFromChar(const wchar_t *c) const;
virtual void setInvisibleCharacters( const wchar_t *s );
private:
struct SFontArea
{
SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}
s32 underhang;
s32 overhang;
s32 width;
u32 spriteno;
};
bool loadTexture(video::IImage * image, const io::path& name);
void readPositions(video::IImage* texture, s32& lowerRightPositions);
s32 getAreaFromCharacter (const wchar_t c) const;
void setMaxHeight();
core::array<SFontArea> Areas;
core::map<wchar_t, s32> CharacterMap;
video::IVideoDriver* Driver;
IGUISpriteBank* SpriteBank;
IGUIEnvironment* Environment;
u32 WrongCharacter;
s32 MaxHeight;
s32 GlobalKerningWidth, GlobalKerningHeight;
core::stringw Invisible;
};
}
}
#endif
#endif