aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIFont.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CGUIFont.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CGUIFont.h118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIFont.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIFont.h
new file mode 100644
index 0000000..ada89c8
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIFont.h
@@ -0,0 +1,118 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_GUI_FONT_H_INCLUDED__
6#define __C_GUI_FONT_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_GUI_
10
11#include "IGUIFontBitmap.h"
12#include "irrString.h"
13#include "irrMap.h"
14#include "IXMLReader.h"
15#include "IReadFile.h"
16#include "irrArray.h"
17
18namespace irr
19{
20
21namespace video
22{
23 class IVideoDriver;
24 class IImage;
25}
26
27namespace gui
28{
29
30 class IGUIEnvironment;
31
32class CGUIFont : public IGUIFontBitmap
33{
34public:
35
36 //! constructor
37 CGUIFont(IGUIEnvironment* env, const io::path& filename);
38
39 //! destructor
40 virtual ~CGUIFont();
41
42 //! loads a font from a texture file
43 bool load(const io::path& filename);
44
45 //! loads a font from a texture file
46 bool load(io::IReadFile* file);
47
48 //! loads a font from an XML file
49 bool load(io::IXMLReader* xml);
50
51 //! draws an text and clips it to the specified rectangle if wanted
52 virtual void draw(const core::stringw& text, const core::rect<s32>& position,
53 video::SColor color, bool hcenter=false,
54 bool vcenter=false, const core::rect<s32>* clip=0);
55
56 //! returns the dimension of a text
57 virtual core::dimension2d<u32> getDimension(const wchar_t* text) const;
58
59 //! Calculates the index of the character in the text which is on a specific position.
60 virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const;
61
62 //! Returns the type of this font
63 virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; }
64
65 //! set an Pixel Offset on Drawing ( scale position on width )
66 virtual void setKerningWidth (s32 kerning);
67 virtual void setKerningHeight (s32 kerning);
68
69 //! set an Pixel Offset on Drawing ( scale position on width )
70 virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const;
71 virtual s32 getKerningHeight() const;
72
73 //! gets the sprite bank
74 virtual IGUISpriteBank* getSpriteBank() const;
75
76 //! returns the sprite number from a given character
77 virtual u32 getSpriteNoFromChar(const wchar_t *c) const;
78
79 virtual void setInvisibleCharacters( const wchar_t *s );
80
81private:
82
83 struct SFontArea
84 {
85 SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}
86 s32 underhang;
87 s32 overhang;
88 s32 width;
89 u32 spriteno;
90 };
91
92 //! load & prepare font from ITexture
93 bool loadTexture(video::IImage * image, const io::path& name);
94
95 void readPositions(video::IImage* texture, s32& lowerRightPositions);
96
97 s32 getAreaFromCharacter (const wchar_t c) const;
98 void setMaxHeight();
99
100 core::array<SFontArea> Areas;
101 core::map<wchar_t, s32> CharacterMap;
102 video::IVideoDriver* Driver;
103 IGUISpriteBank* SpriteBank;
104 IGUIEnvironment* Environment;
105 u32 WrongCharacter;
106 s32 MaxHeight;
107 s32 GlobalKerningWidth, GlobalKerningHeight;
108
109 core::stringw Invisible;
110};
111
112} // end namespace gui
113} // end namespace irr
114
115#endif // _IRR_COMPILE_WITH_GUI_
116
117#endif // __C_GUI_FONT_H_INCLUDED__
118