1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_GUI_FONT_H_INCLUDED__
\r
6 #define __C_GUI_FONT_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
9 #include "IGUIFontBitmap.h"
\r
10 #include "irrString.h"
\r
11 #include "IReadFile.h"
\r
12 #include "irrArray.h"
\r
27 class IGUIEnvironment;
\r
29 class CGUIFont : public IGUIFontBitmap
\r
34 CGUIFont(IGUIEnvironment* env, const io::path& filename);
\r
37 virtual ~CGUIFont();
\r
39 //! loads a font from a texture file
\r
40 bool load(const io::path& filename);
\r
42 //! loads a font from a texture file
\r
43 bool load(io::IReadFile* file);
\r
45 //! draws an text and clips it to the specified rectangle if wanted
\r
46 virtual void draw(const core::stringw& text, const core::rect<s32>& position,
\r
47 video::SColor color, bool hcenter=false,
\r
48 bool vcenter=false, const core::rect<s32>* clip=0) override;
\r
50 //! returns the dimension of a text
\r
51 core::dimension2d<u32> getDimension(const wchar_t* text) const override;
\r
53 //! Calculates the index of the character in the text which is on a specific position.
\r
54 s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const override;
\r
56 //! Returns the type of this font
\r
57 EGUI_FONT_TYPE getType() const override { return EGFT_BITMAP; }
\r
59 //! set an Pixel Offset on Drawing ( scale position on width )
\r
60 void setKerningWidth (s32 kerning) override;
\r
61 void setKerningHeight (s32 kerning) override;
\r
63 //! set an Pixel Offset on Drawing ( scale position on width )
\r
64 s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const override;
\r
65 s32 getKerningHeight() const override;
\r
67 //! gets the sprite bank
\r
68 IGUISpriteBank* getSpriteBank() const override;
\r
70 //! returns the sprite number from a given character
\r
71 u32 getSpriteNoFromChar(const wchar_t *c) const override;
\r
73 void setInvisibleCharacters( const wchar_t *s ) override;
\r
79 SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}
\r
86 //! load & prepare font from ITexture
\r
87 bool loadTexture(video::IImage * image, const io::path& name);
\r
89 void readPositions(video::IImage* texture, s32& lowerRightPositions);
\r
91 s32 getAreaFromCharacter (const wchar_t c) const;
\r
92 void setMaxHeight();
\r
94 void pushTextureCreationFlags(bool(&flags)[3]);
\r
95 void popTextureCreationFlags(const bool(&flags)[3]);
\r
97 core::array<SFontArea> Areas;
\r
98 std::map<wchar_t, s32> CharacterMap;
\r
99 video::IVideoDriver* Driver;
\r
100 IGUISpriteBank* SpriteBank;
\r
101 IGUIEnvironment* Environment;
\r
102 u32 WrongCharacter;
\r
104 s32 GlobalKerningWidth, GlobalKerningHeight;
\r
106 core::stringw Invisible;
\r
109 } // end namespace gui
\r
110 } // end namespace irr
\r
112 #endif // __C_GUI_FONT_H_INCLUDED__
\r