SuperTuxKart
Loading...
Searching...
No Matches
scalable_font.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2016 SuperTuxKart-Team
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_SCALABLE_FONT_HPP
20#define HEADER_SCALABLE_FONT_HPP
21
22#include "utils/leak_check.hpp"
23
24#include <IGUIFontBitmap.h>
25
26class FontSettings;
27class FontWithFace;
28
29namespace irr
30{
31namespace gui
32{
33
34class ScalableFont : public IGUIFontBitmap
35{
36private:
37 FontWithFace* m_face;
38
39 FontSettings* m_font_settings;
40
41public:
42 LEAK_CHECK()
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
46 virtual ~ScalableFont();
47 // ------------------------------------------------------------------------
48 FontSettings* getFontSettings() { return m_font_settings; }
49 // ------------------------------------------------------------------------
50 const FontSettings* getFontSettings() const { return m_font_settings; }
51 // ------------------------------------------------------------------------
52 virtual void setScale(float scale);
53 // ------------------------------------------------------------------------
54 virtual float getScale() const;
55 // ------------------------------------------------------------------------
56 void setShadow(const irr::video::SColor &col);
57 // ------------------------------------------------------------------------
58 void disableShadow();
59 // ------------------------------------------------------------------------
60 void setBlackBorder(bool enabled);
61 // ------------------------------------------------------------------------
62 void setColoredBorder(const irr::video::SColor &col);
63 // ------------------------------------------------------------------------
64 void setThinBorder(bool thin);
65 // ------------------------------------------------------------------------
66 void disableColoredBorder();
67 // ------------------------------------------------------------------------
68 void draw(const core::stringw& text, const core::rect<s32>& position,
69 const video::SColor& color, bool hcenter,
70 bool vcenter, const core::rect<s32>* clip,
71 bool ignoreRTL);
72 // ------------------------------------------------------------------------
74 virtual void draw(const core::stringw& text,
75 const core::rect<s32>& position,
76 video::SColor color, bool hcenter = false,
77 bool vcenter = false, const core::rect<s32>* clip = 0);
78 // ------------------------------------------------------------------------
79 virtual void drawQuick(const core::stringw& text,
80 const core::rect<s32>& position,
81 video::SColor color, bool hcenter = false,
82 bool vcenter = false,
83 const core::rect<s32>* clip = 0);
84 // ------------------------------------------------------------------------
85 virtual void draw(const std::vector<GlyphLayout>& gls,
86 const core::rect<s32>& position,
87 video::SColor color, bool hcenter = false,
88 bool vcenter = false, const core::rect<s32>* clip = 0);
89 // ------------------------------------------------------------------------
90 virtual void initGlyphLayouts(const core::stringw& text,
91 std::vector<GlyphLayout>& gls,
92 u32 shape_flag = 0);
93 // ------------------------------------------------------------------------
95 virtual core::dimension2d<u32> getDimension(const wchar_t* text) const;
96 // ------------------------------------------------------------------------
97 virtual s32 getHeightPerLine() const;
98 // ------------------------------------------------------------------------
101 virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const;
102 // ------------------------------------------------------------------------
104 virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; }
105 // ------------------------------------------------------------------------
107 virtual IGUISpriteBank* getSpriteBank() const;
108 // ------------------------------------------------------------------------
110 virtual u32 getSpriteNoFromChar(const wchar_t *c) const { return 0; }
111 // ------------------------------------------------------------------------
112 // Below is not used:
114 virtual void setKerningWidth (s32 kerning) {}
115 // ------------------------------------------------------------------------
116 virtual void setKerningHeight (s32 kerning) {}
117 // ------------------------------------------------------------------------
119 virtual s32 getKerningWidth(const wchar_t* thisLetter=0,
120 const wchar_t* previousLetter=0) const
121 { return 0; }
122 // ------------------------------------------------------------------------
123 virtual s32 getKerningHeight() const { return 0; }
124 // ------------------------------------------------------------------------
125 virtual void setInvisibleCharacters( const wchar_t *s ) {}
126 // ------------------------------------------------------------------------
127 virtual f32 getInverseShaping() const;
128 // ------------------------------------------------------------------------
129 virtual s32 getFaceFontMaxHeight() const;
130 // ------------------------------------------------------------------------
131 virtual s32 getFaceGlyphMaxHeight() const;
132};
133
134} // end namespace gui
135} // end namespace irr
136
137#endif // HEADER_SCALABLE_FONT_HPP
This class stores settings when rendering fonts, used when instantiating irr::gui::ScalableFont.
Definition: font_settings.hpp:33
An abstract class which contains functions which convert vector fonts into bitmap and render them in ...
Definition: font_with_face.hpp:72
Definition: scalable_font.hpp:35
virtual void setKerningWidth(s32 kerning)
set an Pixel Offset on Drawing ( scale position on width )
Definition: scalable_font.hpp:114
virtual core::dimension2d< u32 > getDimension(const wchar_t *text) const
returns the dimension of a text
Definition: scalable_font.cpp:93
virtual u32 getSpriteNoFromChar(const wchar_t *c) const
returns the sprite number from a given character, unused in STK
Definition: scalable_font.hpp:110
virtual s32 getCharacterFromPos(const wchar_t *text, s32 pixel_x) const
Calculates the index of the character in the text which is on a specific position.
Definition: scalable_font.cpp:139
virtual s32 getKerningWidth(const wchar_t *thisLetter=0, const wchar_t *previousLetter=0) const
set an Pixel Offset on Drawing ( scale position on width )
Definition: scalable_font.hpp:119
virtual void initGlyphLayouts(const core::stringw &text, std::vector< GlyphLayout > &gls, u32 shape_flag=0)
Convert text to glyph layouts for fast rendering with optional caching enabled.
Definition: scalable_font.cpp:160
virtual EGUI_FONT_TYPE getType() const
Returns the type of this font.
Definition: scalable_font.hpp:104
virtual IGUISpriteBank * getSpriteBank() const
gets the sprite bank
Definition: scalable_font.cpp:145