The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespaces | Macros | Functions | Variables
marked-up_text.cpp File Reference

Support for simple markup in text (fonts, colors, images). More...

#include "global.hpp"
#include "font.hpp"
#include "gettext.hpp"
#include "marked-up_text.hpp"
#include "serialization/string_utils.hpp"
#include "serialization/unicode.hpp"
#include "video.hpp"
#include "wml_exception.hpp"
#include "preferences.hpp"
Include dependency graph for marked-up_text.cpp:

Go to the source code of this file.

Namespaces

 font
 Graphical text output.
 

Macros

#define GETTEXT_DOMAIN   "wesnoth-lib"
 

Functions

std::string::const_iterator font::parse_markup (std::string::const_iterator i1, std::string::const_iterator i2, int *font_size, SDL_Color *color, int *style)
 Parses the markup-tags at the front of a string. More...
 
std::string font::del_tags (const std::string &text)
 Copy string, but without tags at the beginning. More...
 
std::string font::color2markup (const SDL_Color &color)
 Create string of color-markup, such as "<255,255,0>" for yellow. More...
 
std::string font::color2hexa (const SDL_Color &color)
 Creates the hexadecimal string of a color, such as "#ffff00" for yellow. More...
 
std::string font::span_color (const SDL_Color &color)
 Creates pango markup of a color. More...
 
SDL_Rect font::text_area (const std::string &text, int size, int style=0)
 Calculate the size of a text (in pixels) if it were to be drawn. More...
 
SDL_Rect font::draw_text (surface &dst, const SDL_Rect &area, int size, const SDL_Color &color, const std::string &text, int x, int y, bool use_tooltips=false, int style=0)
 Function to draw text on a surface. More...
 
SDL_Rect font::draw_text (CVideo *gui, const SDL_Rect &area, int size, const SDL_Color &color, const std::string &text, int x, int y, bool use_tooltips=false, int style=0)
 wrapper of the previous function, gui can also be nullptr More...
 
bool font::is_format_char (char c)
 Determine if char is one of the special chars used as markup. More...
 
bool font::is_cjk_char (const ucs4::char_t ch)
 Determine if a ucs4::char_t is a CJK character. More...
 
static void font::cut_word (std::string &line, std::string &word, int font_size, int style, int max_width)
 
std::string font::word_wrap_text (const std::string &unwrapped_text, int font_size, int max_width, int max_height=-1, int max_lines=-1, bool partial_line=false)
 Wrap text. More...
 
SDL_Rect font::draw_wrapped_text (CVideo *gui, const SDL_Rect &area, int font_size, const SDL_Color &color, const std::string &text, int x, int y, int max_width)
 Draw text on the screen, fit text to maximum width, no markup, no tooltips. More...
 

Variables

const char font::LARGE_TEXT ='*'
 Standard markups for color, size, font, images. More...
 
const char font::SMALL_TEXT ='`'
 
const char font::BOLD_TEXT ='~'
 
const char font::NORMAL_TEXT ='{'
 
const char font::NULL_MARKUP ='^'
 
const char font::BLACK_TEXT ='}'
 
const char font::GRAY_TEXT ='|'
 
const char font::GOOD_TEXT ='@'
 
const char font::BAD_TEXT ='#'
 
const char font::GREEN_TEXT ='@'
 
const char font::RED_TEXT ='#'
 
const char font::COLOR_TEXT ='<'
 
const char font::IMAGE ='&'
 
const std::string font::weapon = "<245,230,193>"
 
const std::string font::weapon_details = "<166,146,117>"
 
const std::string font::unit_type = "<245,230,193>"
 
const std::string font::race = "<166,146,117>"
 
const SDL_Color font::weapon_color = { 245, 230, 193, SDL_ALPHA_OPAQUE }
 
const SDL_Color font::good_dmg_color = { 130, 240, 50, SDL_ALPHA_OPAQUE }
 
const SDL_Color font::bad_dmg_color = { 250, 140, 80, SDL_ALPHA_OPAQUE }
 
const SDL_Color font::weapon_details_color = { 166, 146, 117, SDL_ALPHA_OPAQUE }
 
const SDL_Color font::inactive_details_color = { 146, 146, 146, SDL_ALPHA_OPAQUE }
 
const SDL_Color font::inactive_ability_color = { 146, 146, 146, SDL_ALPHA_OPAQUE }
 
const SDL_Color font::unit_type_color = { 245, 230, 193, SDL_ALPHA_OPAQUE }
 
const SDL_Color font::race_color = { 166, 146, 117, SDL_ALPHA_OPAQUE }
 
const std::string font::weapon_numbers_sep = "×"
 
const std::string font::weapon_details_sep = "–"
 

Detailed Description

Support for simple markup in text (fonts, colors, images).

E.g. "@Victory" will be shown in green.

Definition in file marked-up_text.cpp.

Macro Definition Documentation

#define GETTEXT_DOMAIN   "wesnoth-lib"

Definition at line 21 of file marked-up_text.cpp.