The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
text_formatting.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2017 by the Battle for Wesnoth Project http://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include "color.hpp"
17 
18 // This file isn't needed by any of these functions, but this allows any
19 // standard color to be passed to span_color without an extra include.
20 #include "font/standard_colors.hpp"
21 
22 #include <string>
23 
24 /**
25  * Collection of helper functions relating to Pango formatting.
26  */
27 
28 namespace font {
29 
30 /**
31  * Retuns a Pango formatting string using the provided color_t object.
32  *
33  * The string returned will be in format: &lt;span foreground=#color>
34  * Callers will need to manually append the closing &lt;/span>' tag.
35  *
36  * @param color The color_t object from which to retrieve the color.
37  */
38 std::string span_color(const color_t& color);
39 
40 /**
41  * Returns a hex color string from a color range.
42  *
43  * @param id The id of the color range.
44  */
46 
47 /**
48  * Returns the name of a color range, colored with its own color.
49  *
50  * @param id The id of the color range.
51  */
53 
54 }
std::vector< char_t > string
Note: Specific to sdl_ttf.
std::string span_color(const color_t &color)
Retuns a Pango formatting string using the provided color_t object.
std::string get_pango_color_from_id(const std::string &id)
Returns a hex color string from a color range.
std::string get_color_string_pango(const std::string &id)
Returns the name of a color range, colored with its own color.