| 1 | //  SuperTux | 
|---|
| 2 | //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>, | 
|---|
| 3 | //                     Ingo Ruhnke <grumbel@gmail.com> | 
|---|
| 4 | // | 
|---|
| 5 | //  This program is free software: you can redistribute it and/or modify | 
|---|
| 6 | //  it under the terms of the GNU General Public License as published by | 
|---|
| 7 | //  the Free Software Foundation, either version 3 of the License, or | 
|---|
| 8 | //  (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, see <http://www.gnu.org/licenses/>. | 
|---|
| 17 |  | 
|---|
| 18 | #ifndef HEADER_SUPERTUX_VIDEO_FONT_HPP | 
|---|
| 19 | #define | 
|---|
| 20 |  | 
|---|
| 21 | #include <string> | 
|---|
| 22 |  | 
|---|
| 23 | #include "math/rectf.hpp" | 
|---|
| 24 | #include "math/vector.hpp" | 
|---|
| 25 | #include "video/color.hpp" | 
|---|
| 26 | #include "video/surface_ptr.hpp" | 
|---|
| 27 | #include "video/texture.hpp" | 
|---|
| 28 |  | 
|---|
| 29 | class Canvas; | 
|---|
| 30 |  | 
|---|
| 31 | enum FontAlignment { | 
|---|
| 32 | ALIGN_LEFT, | 
|---|
| 33 | ALIGN_CENTER, | 
|---|
| 34 | ALIGN_RIGHT | 
|---|
| 35 | }; | 
|---|
| 36 |  | 
|---|
| 37 | class Font | 
|---|
| 38 | { | 
|---|
| 39 | public: | 
|---|
| 40 | /** | 
|---|
| 41 | * returns the given string, truncated (preferably at whitespace) to be at most max_chars characters long | 
|---|
| 42 | */ | 
|---|
| 43 | static std::string wrap_to_chars(const std::string& text, int max_chars, std::string* overflow); | 
|---|
| 44 |  | 
|---|
| 45 | public: | 
|---|
| 46 | virtual ~Font() {} | 
|---|
| 47 |  | 
|---|
| 48 | virtual float get_height() const = 0; | 
|---|
| 49 |  | 
|---|
| 50 | virtual float get_text_width(const std::string& text) const = 0; | 
|---|
| 51 | virtual float get_text_height(const std::string& text) const = 0; | 
|---|
| 52 |  | 
|---|
| 53 | virtual std::string wrap_to_width(const std::string& text, float width, std::string* overflow) = 0; | 
|---|
| 54 |  | 
|---|
| 55 | virtual void draw_text(Canvas& canvas, const std::string& text, | 
|---|
| 56 | const Vector& pos, FontAlignment alignment, int layer, const Color& color) = 0; | 
|---|
| 57 | }; | 
|---|
| 58 |  | 
|---|
| 59 | #endif | 
|---|
| 60 |  | 
|---|
| 61 | /* EOF */ | 
|---|
| 62 |  | 
|---|