Note: Specific to sdl_ttf. More...
Classes | |
struct | char_block_map |
struct | error |
class | floating_label |
struct | floating_label_context |
structure which will hide all current floating labels, and cause floating labels instantiated after it is created to be displayed More... | |
struct | font_id |
struct | inverse_table |
struct | manager |
class | p_font |
Small helper class to make sure the pango font object is destroyed properly. More... | |
class | pango_text |
Text class. More... | |
struct | sdl_ttf |
struct | subset_descriptor |
class | text_cache |
struct | text_chunk |
class | text_surface |
struct | ttf_record |
Typedefs | |
typedef int | subset_id |
typedef std::map< std::string, SDL_Rect > | line_size_cache_map |
typedef std::map< std::pair< std::string, int >, TTF_Font * > | open_font_cache |
Enumerations | |
enum | ALIGN { LEFT_ALIGN, CENTER_ALIGN, RIGHT_ALIGN } |
enum | LABEL_SCROLL_MODE { ANCHOR_LABEL_SCREEN, ANCHOR_LABEL_MAP } |
enum | family_class { FONT_SANS_SERIF, FONT_MONOSPACE, FONT_LIGHT, FONT_SCRIPT } |
Font classes for get_font_families(). More... | |
enum | CACHE { CACHE_LOBBY, CACHE_GAME } |
Functions | |
int | add_floating_label (const floating_label &flabel) |
add a label floating on the screen above everything else. More... | |
void | move_floating_label (int handle, double xmove, double ymove) |
moves the floating label given by 'handle' by (xmove,ymove) More... | |
void | scroll_floating_labels (double xmove, double ymove) |
moves all floating labels that have 'scroll_mode' set to ANCHOR_LABEL_MAP More... | |
void | remove_floating_label (int handle) |
removes the floating label given by 'handle' from the screen More... | |
void | show_floating_label (int handle, bool show) |
hides or shows a floating label More... | |
SDL_Rect | get_floating_label_rect (int handle) |
void | draw_floating_labels (surface screen) |
void | undraw_floating_labels (surface screen) |
int | relative_size (int size) |
bool | check_font_file (std::string name) |
Test if a font file exists. More... | |
bool | load_font_config () |
const t_string & | get_font_families (family_class fclass=FONT_SANS_SERIF) |
Returns the currently defined fonts. More... | |
family_class | str_to_family_class (const std::string &str) |
std::string::const_iterator | parse_markup (std::string::const_iterator i1, std::string::const_iterator i2, int *font_size, color_t *color, int *style) |
Parses the markup-tags at the front of a string. More... | |
std::string | del_tags (const std::string &text) |
Copy string, but without tags at the beginning. More... | |
SDL_Rect | 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 | draw_text (surface &dst, const SDL_Rect &area, int size, const color_t &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 | draw_text (CVideo *gui, const SDL_Rect &area, int size, const color_t &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 | is_format_char (char c) |
Determine if char is one of the special chars used as markup. More... | |
bool | is_cjk_char (const char32_t ch) |
Determine if a char32_t is a CJK character. More... | |
static void | cut_word (std::string &line, std::string &word, int font_size, int style, int max_width) |
std::string | 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... | |
std::string | escape_text (const std::string &text) |
Escapes the pango markup characters in a text. More... | |
std::string | semi_escape_text (const std::string &text) |
bool | looks_like_url (utils::string_view str) |
std::string | format_as_link (const std::string &link, color_t color) |
std::ostream & | operator<< (std::ostream &s, const PangoRectangle &rect) |
static TTF_Font * | open_font_impl (const std::string &, int) |
static TTF_Font * | open_font (const std::string &fname, int size) |
static surface | render_text (const std::string &text, int fontsize, const color_t &color, int style, bool use_markup) |
surface | get_rendered_text (const std::string &str, int size, const color_t &color, int style) |
SDL_Rect | draw_text_line (surface &gui_surface, const SDL_Rect &area, int size, const color_t &color, const std::string &text, int x, int y, bool use_tooltips, int style) |
int | get_max_height (int size) |
int | line_width (const std::string &line, int font_size, int style=TTF_STYLE_NORMAL) |
Determine the width of a line of text given a certain font size. More... | |
SDL_Rect | line_size (const std::string &line, int font_size, int style=TTF_STYLE_NORMAL) |
Determine the size of a line of text given a certain font size. More... | |
std::string | make_text_ellipsis (const std::string &text, int font_size, int max_width, int style=TTF_STYLE_NORMAL) |
If the text exceeds the specified max width, end it with an ellipsis (...) More... | |
void | cache_mode (CACHE mode) |
static void | clear_fonts () |
static void | unpremultiply (uint8_t &value, const unsigned div) |
static void | from_cairo_format (uint32_t &c) |
Converts from cairo-format ARGB32 premultiplied alpha to plain alpha. More... | |
pango_text & | get_text_renderer () |
Returns a reference to a static pango_text object. More... | |
std::string | span_color (const color_t &color) |
Returns a Pango formatting string using the provided color_t object. More... | |
std::string | span_color (const color_t &color, const std::string &data) |
Like span_color(const color_t&), but append the data string and a "</span>" tag. More... | |
std::string | get_pango_color_from_id (const std::string &id) |
Returns a hex color string from a color range. More... | |
std::string | get_color_string_pango (const std::string &id) |
Returns the name of a color range, colored with its own color. More... | |
Variables | |
const int | SIZE_NORMAL = 14 |
const int | SIZE_TINY = 10 * SIZE_NORMAL / 14 |
const int | SIZE_SMALL = 12 * SIZE_NORMAL / 14 |
const int | SIZE_15 = 15 * SIZE_NORMAL / 14 |
const int | SIZE_PLUS = 16 * SIZE_NORMAL / 14 |
const int | SIZE_LARGE = 18 * SIZE_NORMAL / 14 |
const int | SIZE_TITLE = 20 * SIZE_NORMAL / 14 |
const int | SIZE_XLARGE = 24 * SIZE_NORMAL / 14 |
const std::size_t | max_text_line_width = 4096 |
const std::string | ellipsis = "..." |
const std::string | nbsp = " " |
const std::string | unicode_minus = "-" |
const std::string | unicode_en_dash = "–" |
const std::string | unicode_em_dash = "—" |
const std::string | unicode_figure_dash = "‒" |
const std::string | unicode_multiplication_sign = "×" |
const std::string | unicode_bullet = "•" |
const std::string | weapon_numbers_sep = "×" |
const std::string | weapon_details_sep = "–" |
const char | LARGE_TEXT ='*' |
Standard markups for color, size, font, images. More... | |
const char | SMALL_TEXT ='`' |
const char | BOLD_TEXT ='~' |
const char | NORMAL_TEXT ='{' |
const char | NULL_MARKUP ='^' |
const char | BLACK_TEXT ='}' |
const char | GRAY_TEXT ='|' |
const char | GOOD_TEXT ='@' |
const char | BAD_TEXT ='#' |
const char | GREEN_TEXT ='@' |
const char | RED_TEXT ='#' |
const char | COLOR_TEXT ='<' |
const char | IMAGE ='&' |
static std::map< font_id, ttf_record > | font_table |
static std::vector< std::string > | font_names |
static std::vector< std::string > | bold_names |
static std::vector< std::string > | italic_names |
static char_block_map | char_blocks |
static std::map< int, std::map< int, line_size_cache_map > > | line_size_cache |
open_font_cache | open_fonts |
const color_t | NORMAL_COLOR {221, 221, 221} |
const color_t | GRAY_COLOR {136, 136, 136} |
const color_t | LOBBY_COLOR {187, 187, 187} |
const color_t | GOOD_COLOR {0 , 181, 26 } |
const color_t | BAD_COLOR {255, 0 , 0 } |
const color_t | BLACK_COLOR {0 , 0 , 0 } |
const color_t | YELLOW_COLOR {255, 255, 0 } |
const color_t | BUTTON_COLOR {186, 172, 125} |
const color_t | PETRIFIED_COLOR {160, 160, 160} |
const color_t | TITLE_COLOR {186, 172, 125} |
const color_t | LABEL_COLOR {107, 140, 255} |
const color_t | BIGMAP_COLOR {255, 255, 255} |
const color_t | DISABLED_COLOR = PETRIFIED_COLOR.inverse() |
const color_t | weapon_color {245, 230, 193} |
const color_t | good_dmg_color {130, 240, 50 } |
const color_t | bad_dmg_color {250, 140, 80 } |
const color_t | weapon_details_color {196, 176, 147} |
const color_t | inactive_details_color { 86, 86, 86} |
const color_t | inactive_ability_color {146, 146, 146} |
const color_t | unit_type_color {245, 230, 193} |
const color_t | race_color {166, 146, 117} |
static const inverse_table | inverse_table_ |
Note: Specific to sdl_ttf.
Graphical text output.
Collection of helper functions relating to Pango formatting.
This module is used to display and measure text. Text can optionally contain special characters, which may change specified display properties such as colour or font size. If special characters are turned on, they can be escaped, C-style, using backslashes.
typedef std::map<std::string,SDL_Rect> font::line_size_cache_map |
Definition at line 135 of file sdl_ttf.cpp.
typedef std::map<std::pair<std::string, int>, TTF_Font*> font::open_font_cache |
Definition at line 140 of file sdl_ttf.cpp.
typedef int font::subset_id |
Definition at line 33 of file font_id.hpp.
enum font::ALIGN |
Enumerator | |
---|---|
LEFT_ALIGN | |
CENTER_ALIGN | |
RIGHT_ALIGN |
Definition at line 31 of file floating_label.hpp.
enum font::CACHE |
Enumerator | |
---|---|
CACHE_LOBBY | |
CACHE_GAME |
Definition at line 59 of file sdl_ttf.hpp.
enum font::family_class |
Font classes for get_font_families().
Enumerator | |
---|---|
FONT_SANS_SERIF | |
FONT_MONOSPACE | |
FONT_LIGHT | |
FONT_SCRIPT |
Definition at line 25 of file font_options.hpp.
Enumerator | |
---|---|
ANCHOR_LABEL_SCREEN | |
ANCHOR_LABEL_MAP |
Definition at line 33 of file floating_label.hpp.
int font::add_floating_label | ( | const floating_label & | flabel | ) |
add a label floating on the screen above everything else.
Definition at line 205 of file floating_label.cpp.
Referenced by display_chat_manager::add_chat_message(), display::announce(), terrain_label::draw(), game_display::float_label(), game_lua_kernel::intf_print(), playmp_controller::play_human_turn(), display::set_diagnostic(), CVideo::set_help_string(), show_tooltip(), display::update_display(), and gui::floating_textbox::update_location().
void font::cache_mode | ( | CACHE | mode | ) |
Definition at line 474 of file sdl_ttf.cpp.
References CACHE_LOBBY, and font::text_cache::resize().
bool font::check_font_file | ( | std::string | name | ) |
Test if a font file exists.
Definition at line 63 of file font_config.cpp.
References filesystem::ends_with(), filesystem::file_exists(), config::find_child(), game_config::path, and WRN_FT.
Referenced by font::sdl_ttf::set_font_list().
|
static |
Definition at line 497 of file sdl_ttf.cpp.
References font::char_block_map::cbmap, and i.
Referenced by font::sdl_ttf::set_font_list(), and font::sdl_ttf::~sdl_ttf().
|
static |
Definition at line 281 of file marked-up_text.cpp.
References ucs4::iterator_base< string_type, update_implementation >::end(), preferences::font_scaled(), is_cjk_char(), line_size(), ucs4::iterator_base< string_type, update_implementation >::substr(), and w.
Referenced by word_wrap_text().
std::string font::del_tags | ( | const std::string & | text | ) |
Copy string, but without tags at the beginning.
Definition at line 136 of file marked-up_text.cpp.
References utils::join(), parse_markup(), and utils::split().
Referenced by gui::menu::basic_sorter::less().
void font::draw_floating_labels | ( | surface | screen | ) |
Definition at line 284 of file floating_label.cpp.
References i.
Referenced by gui2::window::draw(), and display::flip().
SDL_Rect font::draw_text | ( | surface & | dst, |
const SDL_Rect & | area, | ||
int | size, | ||
const color_t & | color, | ||
const std::string & | text, | ||
int | x, | ||
int | y, | ||
bool | use_tooltips = false , |
||
int | style = 0 |
||
) |
Function to draw text on a surface.
The text will be clipped to area. If the text runs outside of area horizontally, an ellipsis will be displayed at the end of it.
If use_tooltips is true, then text with an ellipsis will have a tooltip set for it equivalent to the entire contents of the text.
Some very basic 'markup' will be done on the text:
The above special characters can be quoted using a C-style backslash.
A bounding rectangle of the text is returned. If dst is nullptr, then the text will not be drawn, and a bounding rectangle only will be returned.
Definition at line 153 of file marked-up_text.cpp.
References draw_text_line(), gui2::event::find(), parse_markup(), utf8::size(), and utils::unescape().
Referenced by gui::button::calculate_size(), location_palette_item::draw_contents(), gui::button::draw_contents(), draw_label(), gui::menu::draw_row(), draw_text(), gui::dialog_frame::draw_title(), gui::menu::style::item_size(), and text_area().
SDL_Rect font::draw_text | ( | CVideo * | gui, |
const SDL_Rect & | area, | ||
int | size, | ||
const color_t & | color, | ||
const std::string & | txt, | ||
int | x, | ||
int | y, | ||
bool | use_tooltips, | ||
int | style | ||
) |
wrapper of the previous function, gui can also be nullptr
Definition at line 200 of file marked-up_text.cpp.
References draw_text(), CVideo::getSurface(), and utf8::size().
SDL_Rect font::draw_text_line | ( | surface & | gui_surface, |
const SDL_Rect & | area, | ||
int | size, | ||
const color_t & | color, | ||
const std::string & | text, | ||
int | x, | ||
int | y, | ||
bool | use_tooltips, | ||
int | style | ||
) |
Definition at line 339 of file sdl_ttf.cpp.
References tooltips::add_tooltip(), sdl::create_rect(), font::text_cache::find(), preferences::font_scaled(), font::text_surface::height(), line_width(), make_text_ellipsis(), render_text(), sdl_blit(), and font::text_surface::width().
Referenced by draw_text().
|
inline |
Escapes the pango markup characters in a text.
The markups escaped are the ones used in the pango markup. The special characters are:
<>'"&
The escaping is the same as for HTML.
text | The text to escape. |
Definition at line 32 of file escape.hpp.
References c.
Referenced by gui2::chatbox::add_active_window_message(), gui2::chatbox::add_active_window_whisper(), gui2::chatbox::add_chat_message(), gui2::dialogs::lua_interpreter::lua_model::add_dialog_message(), gui2::chatbox::add_room_window_message(), gui2::chatbox::add_whisper_window_whisper(), addons_client::delete_remote_addon(), addon_info::display_title(), addons_client::do_check_before_overwriting_addon(), addons_client::download_addon(), addons_client::install_addon(), gui2::dialogs::lua_interpreter::lua_model::lua_model(), gui2::dialogs::formula_debugger::pre_show(), gui2::dialogs::chat_log::model::stream_log(), unit_name(), addons_client::update_last_error(), and addons_client::upload_addon().
|
inline |
Definition at line 31 of file hyperlink.hpp.
References color_t::to_hex_string().
Referenced by font::pango_text::format_links().
|
static |
Converts from cairo-format ARGB32 premultiplied alpha to plain alpha.
c | a uint32 representing the color |
Definition at line 602 of file text.cpp.
References a, b, g, and unpremultiply().
Referenced by font::pango_text::rerender().
std::string font::get_color_string_pango | ( | const std::string & | id | ) |
Returns the name of a color range, colored with its own color.
id | The id of the color range. |
Definition at line 45 of file text_formatting.cpp.
References _(), get_pango_color_from_id(), and game_config::team_rgb_name.
Referenced by gui2::dialogs::mp_staging::add_side_node().
SDL_Rect font::get_floating_label_rect | ( | int | handle | ) |
Definition at line 254 of file floating_label.cpp.
References sdl::empty_rect, and i.
Referenced by display_chat_manager::add_chat_message(), display_chat_manager::prune_chat_messages(), CVideo::set_help_string(), show_tooltip(), and gui::floating_textbox::update_location().
const t_string & font::get_font_families | ( | family_class | fclass = FONT_SANS_SERIF | ) |
Returns the currently defined fonts.
Definition at line 201 of file font_config.cpp.
References FONT_LIGHT, FONT_MONOSPACE, and FONT_SCRIPT.
Referenced by font::pango_text::calculate_size().
int font::get_max_height | ( | int | size | ) |
Definition at line 407 of file sdl_ttf.cpp.
References font::sdl_ttf::get_font().
Referenced by gui::textbox::add_text_line(), gui::textbox::textbox(), gui::dialog_frame::top_padding(), and gui2::text_box::update_offsets().
std::string font::get_pango_color_from_id | ( | const std::string & | id | ) |
Returns a hex color string from a color range.
id | The id of the color range. |
Definition at line 35 of file text_formatting.cpp.
References game_config::team_rgb_colors.
Referenced by gui2::dialogs::mp_join_game::generate_side_list(), and get_color_string_pango().
surface font::get_rendered_text | ( | const std::string & | str, |
int | size, | ||
const color_t & | color, | ||
int | style | ||
) |
Definition at line 333 of file sdl_ttf.cpp.
References render_text().
Referenced by help::help_text_area::add_text_item(), gui::textbox::add_text_line(), display::draw_hex(), display::draw_text_in_hex(), and help::help_text_area::set_items().
pango_text & font::get_text_renderer | ( | ) |
Returns a reference to a static pango_text object.
Since the class is essentially a render pipeline, there's no need for individual areas of the game to own their own renderers. Not to mention it isn't a trivial class; constructing one is likely to be expensive.
Definition at line 858 of file text.cpp.
Referenced by gui2::text_shape::draw().
bool font::is_cjk_char | ( | const char32_t | ch | ) |
Determine if a char32_t is a CJK character.
true | Input-char is a CJK char |
false | Input-char is a not CJK char. |
You can check these range at http://unicode.org/charts/ see the "East Asian Scripts" part. Notice that not all characters in that part is still in use today, so don't list them all here. Below are characters that I guess may be used in wesnoth translations.
Definition at line 227 of file marked-up_text.cpp.
Referenced by cut_word(), and help::get_first_word().
bool font::is_format_char | ( | char | c | ) |
Determine if char is one of the special chars used as markup.
true | Input-char is a markup-char. |
false | Input-char is a normal char. |
Definition at line 209 of file marked-up_text.cpp.
References BAD_TEXT, BLACK_TEXT, BOLD_TEXT, GOOD_TEXT, GRAY_TEXT, LARGE_TEXT, NORMAL_TEXT, NULL_MARKUP, and SMALL_TEXT.
Referenced by word_wrap_text().
SDL_Rect font::line_size | ( | const std::string & | line, |
int | font_size, | ||
int | style = TTF_STYLE_NORMAL |
||
) |
Determine the size of a line of text given a certain font size.
Similar to line_width, but for both coordinates.
Definition at line 421 of file sdl_ttf.cpp.
References gui2::cache, gui::font_size, font::text_surface::height(), i, s, font::ttf_record::style, and font::text_surface::width().
Referenced by cut_word(), line_width(), and word_wrap_text().
int font::line_width | ( | const std::string & | line, |
int | font_size, | ||
int | style = TTF_STYLE_NORMAL |
||
) |
Determine the width of a line of text given a certain font size.
The font type used is the default wesnoth font type.
Definition at line 416 of file sdl_ttf.cpp.
References line_size().
Referenced by help::help_text_area::add_text_item(), gui::textbox::add_text_line(), draw_text_line(), make_text_ellipsis(), help::unit_topic_generator::operator()(), help::unit_topic_generator::push_header(), help::push_tab_pair(), CVideo::set_help_string(), and word_wrap_text().
bool font::load_font_config | ( | ) |
Definition at line 128 of file font_config.cpp.
References config::child(), config::child_range(), e, ERR_FT, filesystem::get_wml_location(), game::error::message, preprocess_file(), read(), font::sdl_ttf::set_font_list(), and utils::split().
Referenced by do_gameloop(), and test_utils::game_config_manager::game_config_manager().
|
inline |
Definition at line 26 of file hyperlink.hpp.
References utils::basic_string_view< charT, traits >::size(), and utils::basic_string_view< charT, traits >::substr().
Referenced by font::pango_text::find_links(), and font::pango_text::get_link().
std::string font::make_text_ellipsis | ( | const std::string & | text, |
int | font_size, | ||
int | max_width, | ||
int | style | ||
) |
If the text exceeds the specified max width, end it with an ellipsis (...)
Definition at line 443 of file sdl_ttf.cpp.
References ellipsis, ucs4::iterator_base< string_type, update_implementation >::end(), line_width(), ucs4::iterator_base< string_type, update_implementation >::substr(), and WRN_FT.
Referenced by gui::button::calculate_size(), gui::menu::draw_row(), draw_text_line(), and help::help_text_area::set_items().
void font::move_floating_label | ( | int | handle, |
double | xmove, | ||
double | ymove | ||
) |
moves the floating label given by 'handle' by (xmove,ymove)
Definition at line 217 of file floating_label.cpp.
References i.
Referenced by display_chat_manager::prune_chat_messages(), CVideo::set_help_string(), and show_tooltip().
|
static |
Definition at line 148 of file sdl_ttf.cpp.
References open_font_impl().
Referenced by font::sdl_ttf::get_font().
|
static |
Definition at line 161 of file sdl_ttf.cpp.
References DBG_FT, ERR_FT, filesystem::file_exists(), font::ttf_record::font, filesystem::make_read_RWops(), game_config::path, and utf8::size().
Referenced by open_font().
|
inline |
Definition at line 22 of file stream_ops.hpp.
References s.
std::string::const_iterator font::parse_markup | ( | std::string::const_iterator | i1, |
std::string::const_iterator | i2, | ||
int * | font_size, | ||
color_t * | color, | ||
int * | style | ||
) |
Parses the markup-tags at the front of a string.
Definition at line 48 of file marked-up_text.cpp.
References BAD_COLOR, BAD_TEXT, BLACK_COLOR, BLACK_TEXT, BOLD_TEXT, COLOR_TEXT, GOOD_COLOR, GOOD_TEXT, GRAY_COLOR, GRAY_TEXT, LARGE_TEXT, lexical_cast(), NORMAL_COLOR, NORMAL_TEXT, NULL_MARKUP, SMALL_TEXT, and editor::start().
Referenced by gui::button::calculate_size(), del_tags(), gui::menu::draw_row(), draw_text(), render_text(), and word_wrap_text().
|
inline |
Definition at line 29 of file constants.hpp.
References ellipsis, max_text_line_width, nbsp, unicode_bullet, unicode_em_dash, unicode_en_dash, unicode_figure_dash, unicode_minus, unicode_multiplication_sign, weapon_details_sep, and weapon_numbers_sep.
Referenced by help::help_browser::adjust_layout(), help::help_browser::help_browser(), and help::show_help().
void font::remove_floating_label | ( | int | handle | ) |
removes the floating label given by 'handle' from the screen
Definition at line 234 of file floating_label.cpp.
References i.
Referenced by display::announce(), terrain_label::clear(), CVideo::clear_help_string(), clear_tooltip(), gui::floating_textbox::close(), game_lua_kernel::intf_print(), display_chat_manager::prune_chat_messages(), display::set_diagnostic(), CVideo::set_help_string(), display::update_display(), gui::floating_textbox::update_location(), and font::floating_label_context::~floating_label_context().
|
static |
Definition at line 263 of file sdl_ttf.cpp.
References blit_surface(), sdl::create_rect(), font::text_cache::find(), font::text_surface::get_surfaces(), font::text_surface::height(), i, parse_markup(), font::text_surface::set_text(), utils::split(), font::ttf_record::style, and font::text_surface::width().
Referenced by draw_text_line(), and get_rendered_text().
void font::scroll_floating_labels | ( | double | xmove, |
double | ymove | ||
) |
moves all floating labels that have 'scroll_mode' set to ANCHOR_LABEL_MAP
Definition at line 225 of file floating_label.cpp.
References ANCHOR_LABEL_MAP, and i.
Referenced by display::scroll().
|
inline |
Definition at line 51 of file escape.hpp.
References c.
Referenced by font::pango_text::validate_markup().
void font::show_floating_label | ( | int | handle, |
bool | value | ||
) |
hides or shows a floating label
Definition at line 246 of file floating_label.cpp.
References i.
Referenced by terrain_label::calculate_shroud().
std::string font::span_color | ( | const color_t & | color | ) |
Returns a Pango formatting string using the provided color_t object.
The string returned will be in format: <span foreground=#color> Callers will need to manually append the closing </span>' tag.
color | The color_t object from which to retrieve the color. |
Definition at line 25 of file text_formatting.cpp.
References color_t::to_hex_string().
Referenced by gui2::dialogs::add_unit_entry(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), attack_info(), gui2::addon_list::colorize_addon_state_string(), editor::editor_palette< overlay >::draw_contents(), gui2::dialogs::format_level_string(), gui2::dialogs::gray_if_unrecruitable(), gray_inactive(), image_report(), gui2::dialogs::maybe_inactive(), gui2::dialogs::mp_lobby::post_build(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::label_settings::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::unit_list::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::unit_preview_pane::print_attack_details(), REPORT_GENERATOR(), gui2::addon_list::set_addons(), gui2::dialogs::attack_predictions::set_data(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), span_color(), gui2::dialogs::tally(), unit_abilities(), unit_alignment(), unit_defense(), unit_hp(), unit_moves(), unit_weapons(), unit_xp(), and attack_type::weapon_specials().
std::string font::span_color | ( | const color_t & | color, |
const std::string & | data | ||
) |
Like span_color(const color_t&), but append the data string and a "</span>" tag.
Definition at line 30 of file text_formatting.cpp.
References span_color().
|
inline |
Definition at line 33 of file font_options.hpp.
References FONT_LIGHT, FONT_MONOSPACE, FONT_SANS_SERIF, and FONT_SCRIPT.
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.
Definition at line 147 of file marked-up_text.cpp.
References draw_text(), and NORMAL_COLOR.
Referenced by gui::menu::draw_row().
void font::undraw_floating_labels | ( | surface | screen | ) |
Definition at line 301 of file floating_label.cpp.
References i.
Referenced by display::flip(), and gui2::window::show().
|
static |
Definition at line 586 of file text.cpp.
Referenced by from_cairo_format().
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.
Definition at line 399 of file marked-up_text.cpp.
References _(), cut_word(), ucs4::iterator_base< string_type, update_implementation >::end(), preferences::font_scaled(), gui::font_size, is_format_char(), line_size(), line_width(), ucs4::iterator_base< string_type, update_implementation >::next_is_end(), parse_markup(), utf8::size(), ucs4::iterator_base< string_type, update_implementation >::substr(), and VALIDATE.
Referenced by display_chat_manager::add_chat_message(), and help::split_in_width().
const color_t font::BAD_COLOR {255, 0 , 0 } |
Definition at line 24 of file standard_colors.cpp.
Referenced by help::help_text_area::add_text_item(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), attack_info_percent_color(), gui2::addon_list::colorize_addon_state_string(), editor::editor_palette< overlay >::draw_contents(), game_display::draw_hex(), parse_markup(), REPORT_GENERATOR(), help::string_to_color(), display::update_display(), and gui2::dialogs::mp_lobby::update_playerlist().
const color_t font::bad_dmg_color {250, 140, 80 } |
Definition at line 38 of file standard_colors.cpp.
Referenced by attack_info(), gui2::dialogs::attack_predictions::set_data(), unit_alignment(), and unit_weapons().
const char font::BAD_TEXT ='#' |
Definition at line 44 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
const color_t font::BIGMAP_COLOR {255, 255, 255} |
Definition at line 31 of file standard_colors.cpp.
Referenced by help::string_to_color().
const color_t font::BLACK_COLOR {0 , 0 , 0 } |
Definition at line 25 of file standard_colors.cpp.
Referenced by display::draw_text_in_hex(), parse_markup(), and help::string_to_color().
const char font::BLACK_TEXT ='}' |
Definition at line 43 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
|
static |
Definition at line 64 of file sdl_ttf.cpp.
const char font::BOLD_TEXT ='~' |
Definition at line 41 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
const color_t font::BUTTON_COLOR {186, 172, 125} |
Definition at line 27 of file standard_colors.cpp.
Referenced by gui::button::calculate_size(), and gui::button::draw_contents().
|
static |
Definition at line 132 of file sdl_ttf.cpp.
const char font::COLOR_TEXT ='<' |
Definition at line 46 of file marked-up_text.cpp.
Referenced by parse_markup().
const color_t font::DISABLED_COLOR = PETRIFIED_COLOR.inverse() |
Definition at line 33 of file standard_colors.cpp.
const std::string font::ellipsis = "..." |
Definition at line 35 of file constants.cpp.
Referenced by utils::ellipsis_truncate(), make_text_ellipsis(), and relative_size().
|
static |
Definition at line 63 of file sdl_ttf.cpp.
|
static |
Definition at line 62 of file sdl_ttf.cpp.
const color_t font::GOOD_COLOR {0 , 181, 26 } |
Definition at line 23 of file standard_colors.cpp.
Referenced by display::announce_options::announce_options(), attack_info_percent_color(), gui2::addon_list::colorize_addon_state_string(), gui2::dialogs::mp_lobby::make_game_row_data(), parse_markup(), gui2::addon_list::set_addons(), and help::string_to_color().
const color_t font::good_dmg_color {130, 240, 50 } |
Definition at line 37 of file standard_colors.cpp.
Referenced by attack_info(), gui2::dialogs::attack_predictions::set_data(), unit_alignment(), and unit_weapons().
const char font::GOOD_TEXT ='@' |
Definition at line 44 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
const color_t font::GRAY_COLOR {136, 136, 136} |
Definition at line 21 of file standard_colors.cpp.
Referenced by gui2::addon_list::colorize_addon_state_string(), gui::button::draw_contents(), gray_inactive(), gui2::dialogs::mp_lobby::make_game_row_data(), parse_markup(), gui2::dialogs::campaign_difficulty::pre_show(), and REPORT_GENERATOR().
const char font::GRAY_TEXT ='|' |
Definition at line 43 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
const char font::GREEN_TEXT ='@' |
Definition at line 45 of file marked-up_text.cpp.
const char font::IMAGE ='&' |
Definition at line 46 of file marked-up_text.cpp.
const color_t font::inactive_ability_color {146, 146, 146} |
Definition at line 41 of file standard_colors.cpp.
Referenced by unit_abilities().
const color_t font::inactive_details_color { 86, 86, 86} |
Definition at line 40 of file standard_colors.cpp.
Referenced by attack_info(), and attack_type::weapon_specials().
|
static |
|
static |
Definition at line 65 of file sdl_ttf.cpp.
const color_t font::LABEL_COLOR {107, 140, 255} |
Definition at line 30 of file standard_colors.cpp.
Referenced by terrain_label::draw(), game_lua_kernel::intf_float_label(), game_lua_kernel::intf_print(), events::menu_handler::label_terrain(), and terrain_label::read().
const char font::LARGE_TEXT ='*' |
Standard markups for color, size, font, images.
Definition at line 40 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
|
static |
Definition at line 138 of file sdl_ttf.cpp.
const color_t font::LOBBY_COLOR {187, 187, 187} |
Definition at line 22 of file standard_colors.cpp.
const std::size_t font::max_text_line_width = 4096 |
Definition at line 32 of file constants.cpp.
Referenced by font::text_surface::get_surfaces(), and relative_size().
const std::string font::nbsp = " " |
Definition at line 36 of file constants.cpp.
Referenced by help::unit_topic_generator::operator()(), and relative_size().
const color_t font::NORMAL_COLOR {221, 221, 221} |
Definition at line 20 of file standard_colors.cpp.
Referenced by gui2::addon_list::colorize_addon_state_string(), location_palette_item::draw_contents(), wb::move::draw_hex(), display::draw_hex(), draw_label(), game_display::draw_movement_info(), gui::menu::draw_row(), map_labels::get_label(), gui::menu::style::item_size(), parse_markup(), help::help_text_area::set_items(), show_tooltip(), help::string_to_color(), SYNCED_COMMAND_HANDLER_FUNCTION(), text_area(), play_controller::hotkey_handler::toggle_accelerated_speed(), editor::mouse_action_map_label::up_left(), display::update_display(), and playsingle_controller::hotkey_handler::whiteboard_toggle().
const char font::NORMAL_TEXT ='{' |
Definition at line 41 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
const char font::NULL_MARKUP ='^' |
Definition at line 42 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
open_font_cache font::open_fonts |
Definition at line 141 of file sdl_ttf.cpp.
const color_t font::PETRIFIED_COLOR {160, 160, 160} |
Definition at line 28 of file standard_colors.cpp.
const color_t font::race_color {166, 146, 117} |
Definition at line 43 of file standard_colors.cpp.
const char font::RED_TEXT ='#' |
Definition at line 45 of file marked-up_text.cpp.
const int font::SIZE_15 = 15 * SIZE_NORMAL / 14 |
Definition at line 25 of file constants.cpp.
Referenced by display_chat_manager::add_chat_message().
const int font::SIZE_LARGE = 18 * SIZE_NORMAL / 14 |
Definition at line 27 of file constants.cpp.
Referenced by CVideo::set_help_string().
const int font::SIZE_NORMAL = 14 |
Definition at line 19 of file constants.cpp.
Referenced by terrain_label::draw().
const int font::SIZE_PLUS = 16 * SIZE_NORMAL / 14 |
Definition at line 26 of file constants.cpp.
Referenced by display::set_diagnostic(), and gui::floating_textbox::show().
const int font::SIZE_SMALL = 12 * SIZE_NORMAL / 14 |
Definition at line 23 of file constants.cpp.
Referenced by display::draw_hex(), gui2::dialogs::attack_predictions::draw_hp_graph(), and game_lua_kernel::intf_print().
const int font::SIZE_TINY = 10 * SIZE_NORMAL / 14 |
Definition at line 22 of file constants.cpp.
const int font::SIZE_TITLE = 20 * SIZE_NORMAL / 14 |
Definition at line 28 of file constants.cpp.
Referenced by gui::dialog_frame::draw_title(), and gui::dialog_frame::top_padding().
const int font::SIZE_XLARGE = 24 * SIZE_NORMAL / 14 |
Definition at line 29 of file constants.cpp.
Referenced by display::announce(), and game_display::float_label().
const char font::SMALL_TEXT ='`' |
Definition at line 40 of file marked-up_text.cpp.
Referenced by is_format_char(), and parse_markup().
const color_t font::TITLE_COLOR {186, 172, 125} |
Definition at line 29 of file standard_colors.cpp.
Referenced by gui2::dialogs::mp_lobby::adjust_game_row_contents(), and gui::dialog_frame::draw_title().
const std::string font::unicode_bullet = "•" |
Definition at line 43 of file constants.cpp.
Referenced by attack_info(), addons_client::do_resolve_addon_dependencies(), gui2::dialogs::game_load::evaluate_summary_string(), help::generate_ability_topics(), help::generate_contents_links(), help::generate_era_topics(), help::generate_faction_topics(), help::generate_unit_topics(), help::generate_weapon_special_topics(), gui2::get_hp_tooltip(), editor::get_menu_marker(), gui2::get_mp_tooltip(), mp::initial_level_config(), gui2::password_box::insert_char(), editor::context_manager::modified_maps(), gui2::dialogs::faction_select::on_faction_select(), gui2::dialogs::mp_lobby::post_build(), gui2::dialogs::terrain_layers::pre_show(), relative_size(), and gui2::password_box::set_value().
const std::string font::unicode_em_dash = "—" |
Definition at line 40 of file constants.cpp.
Referenced by gui2::dialogs::statistics_dialog::add_stat_row(), editor::terrain_palette::draw_item(), gui2::dialogs::format_addon_time(), mp::game_info::game_info(), gui2::dialogs::faction_select::on_faction_select(), mp::user_info::operator<(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::mp_join_game::pre_show(), gui2::dialogs::mp_staging::pre_show(), gui2::dialogs::screenshot_notification::pre_show(), relative_size(), gui2::dialogs::tally(), gui2::dialogs::mp_create_game::update_details(), and gui2::dialogs::mp_staging::update_leader_display().
const std::string font::unicode_en_dash = "–" |
Definition at line 39 of file constants.cpp.
Referenced by gui2::dialogs::unit_list::pre_show(), gui2::dialogs::unit_recall::pre_show(), relative_size(), gui2::unit_preview_pane::set_displayed_unit(), unit_weapons(), and unit_xp().
const std::string font::unicode_figure_dash = "‒" |
Definition at line 41 of file constants.cpp.
Referenced by gui2::get_mp_tooltip(), help::unit_topic_generator::operator()(), relative_size(), and unit_moves().
const std::string font::unicode_minus = "-" |
Definition at line 38 of file constants.cpp.
Referenced by wb::recall::draw_hex(), wb::recruit::draw_hex(), utils::half_signed_value(), help::unit_topic_generator::operator()(), utils::print_modifier(), relative_size(), REPORT_GENERATOR(), utils::si_string(), and utils::signed_value().
const std::string font::unicode_multiplication_sign = "×" |
Definition at line 42 of file constants.cpp.
Referenced by mp::game_info::game_info(), ng::scenario::map_size(), relative_size(), gui2::dialogs::attack_predictions::set_data(), and gui2::dialogs::preferences_dialog::set_resolution_list().
const color_t font::unit_type_color {245, 230, 193} |
Definition at line 42 of file standard_colors.cpp.
Referenced by gui2::unit_preview_pane::print_attack_details(), gui2::unit_preview_pane::set_displayed_type(), and gui2::unit_preview_pane::set_displayed_unit().
const color_t font::weapon_color {245, 230, 193} |
Definition at line 36 of file standard_colors.cpp.
Referenced by attack_info(), gui2::dialogs::attack_predictions::set_data(), unit_alignment(), and unit_weapons().
const color_t font::weapon_details_color {196, 176, 147} |
Definition at line 39 of file standard_colors.cpp.
Referenced by attack_info(), gui2::addon_list::colorize_addon_state_string(), gui2::unit_preview_pane::print_attack_details(), and unit_weapons().
const std::string font::weapon_details_sep = "–" |
Definition at line 46 of file constants.cpp.
Referenced by attack_info(), gui2::unit_preview_pane::print_attack_details(), and relative_size().
const std::string font::weapon_numbers_sep = "×" |
Definition at line 45 of file constants.cpp.
Referenced by attack_info(), help::unit_topic_generator::operator()(), gui2::dialogs::unit_attack::pre_show(), gui2::unit_preview_pane::print_attack_details(), relative_size(), gui2::dialogs::attack_predictions::set_data(), and unit_weapons().
const color_t font::YELLOW_COLOR {255, 255, 0 } |
Definition at line 26 of file standard_colors.cpp.
Referenced by help::help_text_area::add_text_item(), attack_info_percent_color(), gui2::addon_list::colorize_addon_state_string(), game_display::draw_movement_info(), gui2::dialogs::mp_lobby::make_game_row_data(), display::set_diagnostic(), help::string_to_color(), and gui::floating_textbox::update_location().