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 26 class FontSettings; 27 class FontWithFace; 28 29 namespace irr 30 { 31 namespace gui 32 { 33 34 class ScalableFont : public IGUIFontBitmap 35 { 36 private: 37 FontWithFace* m_face; 38 39 FontSettings* m_font_settings; 40 41 public: 42 LEAK_CHECK() 43 // ------------------------------------------------------------------------ 44 ScalableFont(FontWithFace* face); 45 // ------------------------------------------------------------------------ 46 virtual ~ScalableFont(); 47 // ------------------------------------------------------------------------ getFontSettings()48 FontSettings* getFontSettings() { return m_font_settings; } 49 // ------------------------------------------------------------------------ getFontSettings() const50 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 // ------------------------------------------------------------------------ 73 /** draws an text and clips it to the specified rectangle if wanted */ 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 std::vector<std::u32string>* line_data = NULL); 93 // ------------------------------------------------------------------------ 94 /** returns the dimension of a text */ 95 virtual core::dimension2d<u32> getDimension(const wchar_t* text) const; 96 // ------------------------------------------------------------------------ 97 virtual s32 getHeightPerLine() const; 98 // ------------------------------------------------------------------------ 99 /** Calculates the index of the character in the text which is on a 100 * specific position. */ 101 virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const; 102 // ------------------------------------------------------------------------ 103 /** Returns the type of this font */ getType() const104 virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; } 105 // ------------------------------------------------------------------------ 106 /** gets the sprite bank */ 107 virtual IGUISpriteBank* getSpriteBank() const; 108 // ------------------------------------------------------------------------ 109 /** returns the sprite number from a given character, unused in STK */ getSpriteNoFromChar(const wchar_t * c) const110 virtual u32 getSpriteNoFromChar(const wchar_t *c) const { return 0; } 111 // ------------------------------------------------------------------------ 112 // Below is not used: 113 /** set an Pixel Offset on Drawing ( scale position on width ) */ setKerningWidth(s32 kerning)114 virtual void setKerningWidth (s32 kerning) {} 115 // ------------------------------------------------------------------------ setKerningHeight(s32 kerning)116 virtual void setKerningHeight (s32 kerning) {} 117 // ------------------------------------------------------------------------ 118 /** set an Pixel Offset on Drawing ( scale position on width ) */ getKerningWidth(const wchar_t * thisLetter=0,const wchar_t * previousLetter=0) const119 virtual s32 getKerningWidth(const wchar_t* thisLetter=0, 120 const wchar_t* previousLetter=0) const 121 { return 0; } 122 // ------------------------------------------------------------------------ getKerningHeight() const123 virtual s32 getKerningHeight() const { return 0; } 124 // ------------------------------------------------------------------------ setInvisibleCharacters(const wchar_t * s)125 virtual void setInvisibleCharacters( const wchar_t *s ) {} 126 // ------------------------------------------------------------------------ 127 virtual f32 getInverseShaping() const; 128 129 }; 130 131 } // end namespace gui 132 } // end namespace irr 133 134 #endif // HEADER_SCALABLE_FONT_HPP 135