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 #ifdef _IRR_COMPILE_WITH_GUI_
\r
11 #include "IGUIFontBitmap.h"
\r
12 #include "irrString.h"
\r
13 #include "IReadFile.h"
\r
14 #include "irrArray.h"
\r
29 class IGUIEnvironment;
\r
31 class CGUIFont : public IGUIFontBitmap
\r
36 CGUIFont(IGUIEnvironment* env, const io::path& filename);
\r
39 virtual ~CGUIFont();
\r
41 //! loads a font from a texture file
\r
42 bool load(const io::path& filename);
\r
44 //! loads a font from a texture file
\r
45 bool load(io::IReadFile* file);
\r
47 //! draws an text and clips it to the specified rectangle if wanted
\r
48 virtual void draw(const core::stringw& text, const core::rect<s32>& position,
\r
49 video::SColor color, bool hcenter=false,
\r
50 bool vcenter=false, const core::rect<s32>* clip=0) override;
\r
52 //! returns the dimension of a text
\r
53 core::dimension2d<u32> getDimension(const wchar_t* text) const override;
\r
55 //! Calculates the index of the character in the text which is on a specific position.
\r
56 s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const override;
\r
58 //! Returns the type of this font
\r
59 EGUI_FONT_TYPE getType() const override { return EGFT_BITMAP; }
\r
61 //! set an Pixel Offset on Drawing ( scale position on width )
\r
62 void setKerningWidth (s32 kerning) override;
\r
63 void setKerningHeight (s32 kerning) override;
\r
65 //! set an Pixel Offset on Drawing ( scale position on width )
\r
66 s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const override;
\r
67 s32 getKerningHeight() const override;
\r
69 //! gets the sprite bank
\r
70 IGUISpriteBank* getSpriteBank() const override;
\r
72 //! returns the sprite number from a given character
\r
73 u32 getSpriteNoFromChar(const wchar_t *c) const override;
\r
75 void setInvisibleCharacters( const wchar_t *s ) override;
\r
81 SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}
\r
88 //! load & prepare font from ITexture
\r
89 bool loadTexture(video::IImage * image, const io::path& name);
\r
91 void readPositions(video::IImage* texture, s32& lowerRightPositions);
\r
93 s32 getAreaFromCharacter (const wchar_t c) const;
\r
94 void setMaxHeight();
\r
96 void pushTextureCreationFlags(bool(&flags)[3]);
\r
97 void popTextureCreationFlags(const bool(&flags)[3]);
\r
99 core::array<SFontArea> Areas;
\r
100 std::map<wchar_t, s32> CharacterMap;
\r
101 video::IVideoDriver* Driver;
\r
102 IGUISpriteBank* SpriteBank;
\r
103 IGUIEnvironment* Environment;
\r
104 u32 WrongCharacter;
\r
106 s32 GlobalKerningWidth, GlobalKerningHeight;
\r
108 core::stringw Invisible;
\r
111 } // end namespace gui
\r
112 } // end namespace irr
\r
114 #endif // _IRR_COMPILE_WITH_GUI_
\r
116 #endif // __C_GUI_FONT_H_INCLUDED__
\r