font.cpp File Reference

#include "global.hpp"
#include "config.hpp"
#include "filesystem.hpp"
#include "font.hpp"
#include "game_config.hpp"
#include "log.hpp"
#include "sdl_utils.hpp"
#include "tooltips.hpp"
#include "util.hpp"
#include "video.hpp"
#include "serialization/parser.hpp"
#include "serialization/preprocessor.hpp"
#include "serialization/string_utils.hpp"
#include "marked-up_text.hpp"
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <string>

Include dependency graph for font.cpp:

Go to the source code of this file.

Namespaces

namespace  font

Classes

struct  font::subset_descriptor

Defines

#define DBG_FT   LOG_STREAM(debug, display)
#define LOG_FT   LOG_STREAM(info, display)
#define WRN_FT   LOG_STREAM(warn, display)
#define ERR_FT   LOG_STREAM(err, display)

Typedefs

typedef int subset_id
typedef std::map< std::string,
SDL_Rect > 
line_size_cache_map
typedef std::map< int,
floating_label
label_map

Functions

static std::vector< text_chunk > split_text (std::string const &utf8_text)
static TTF_Font * open_font (const std::string &fname, int size)
static TTF_Font * get_font (font_id id)
static void clear_fonts ()
static void font::set_font_list (const std::vector< subset_descriptor > &fontlist)
static surface font::render_text (const std::string &text, int fontsize, const SDL_Color &colour, int style)
surface font::get_rendered_text (const std::string &str, int size, const SDL_Color &colour, int style)
SDL_Rect font::draw_text_line (surface gui_surface, const SDL_Rect &area, int size, const SDL_Color &colour, const std::string &text, int x, int y, bool use_tooltips, int style)
SDL_Rect font::draw_text_line (CVideo *gui, const SDL_Rect &area, int size, const SDL_Color &colour, const std::string &text, int x, int y, bool use_tooltips, int style)
int font::get_max_height (int size)
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.
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.
std::string font::make_text_ellipsis (const std::string &text, int font_size, int max_width, bool with_tags=true)
 If the text excedes the specified max width, end it with an ellipsis (.
int font::add_floating_label (const std::string &text, int font_size, const SDL_Color &colour, double xpos, double ypos, double xmove, double ymove, int lifetime, const SDL_Rect &clip_rect, ALIGN alignment=CENTER_ALIGN, const SDL_Color *bg_colour=NULL, int border_size=0, LABEL_SCROLL_MODE scroll_mode=ANCHOR_LABEL_SCREEN)
 add a label floating on the screen above everything else.
void font::move_floating_label (int handle, double xmove, double ymove)
 moves the floating label given by 'handle' by (xmove,ymove)
void font::scroll_floating_labels (double xmove, double ymove)
 moves all floating labels that have 'scroll_mode' set to ANCHOR_LABEL_MAP
void font::remove_floating_label (int handle)
 removes the floating label given by 'handle' from the screen
void font::show_floating_label (int handle, bool show)
 hides or shows a floating label
SDL_Rect font::get_floating_label_rect (int handle)
void font::draw_floating_labels (surface screen)
void font::undraw_floating_labels (surface screen)
static bool add_font_to_fontlist (config *fonts_config, std::vector< font::subset_descriptor > &fontlist, const std::string &name)
bool font::load_font_config ()
void font::cache_mode (CACHE mode)

Variables

std::map< font_id, TTF_Font * > font_table
std::vector< std::string > font_names
std::vector< subset_idfont_map
std::map< int, std::map< int,
line_size_cache_map > > 
line_size_cache
const SDL_Color font::NORMAL_COLOUR = {0xDD,0xDD,0xDD,0}
const SDL_Color font::GRAY_COLOUR = {0x77,0x77,0x77,0}
const SDL_Color font::LOBBY_COLOUR = {0xBB,0xBB,0xBB,0}
const SDL_Color font::GOOD_COLOUR = {0x00,0xFF,0x00,0}
const SDL_Color font::BAD_COLOUR = {0xFF,0x00,0x00,0}
const SDL_Color font::BLACK_COLOUR = {0x00,0x00,0x00,0}
const SDL_Color font::YELLOW_COLOUR = {0xFF,0xFF,0x00,0}
const SDL_Color font::BUTTON_COLOUR = {0xBC,0xB0,0x88,0}
const SDL_Color font::STONED_COLOUR = {0xA0,0xA0,0xA0,0}
const SDL_Color font::TITLE_COLOUR = {0xBC,0xB0,0x88,0}
const SDL_Color font::LABEL_COLOUR = {0x6B,0x8C,0xFF,0}
const SDL_Color font::BIGMAP_COLOUR = {0xFF,0xFF,0xFF,0}
const SDL_Color font::DISABLED_COLOUR = inverse(STONED_COLOUR)
static const size_t font::max_text_line_width = 4096
label_map labels
int label_id = 1
std::stack< std::set< int > > label_contexts


Define Documentation

#define DBG_FT   LOG_STREAM(debug, display)

Definition at line 42 of file font.cpp.

#define ERR_FT   LOG_STREAM(err, display)

Definition at line 45 of file font.cpp.

Referenced by font::load_font_config(), font::manager::manager(), and open_font().

#define LOG_FT   LOG_STREAM(info, display)

Definition at line 43 of file font.cpp.

Referenced by get_font(), and font::manager::manager().

#define WRN_FT   LOG_STREAM(warn, display)

Definition at line 44 of file font.cpp.

Referenced by font::set_font_list(), and split_text().


Typedef Documentation

typedef std::map<int,floating_label> label_map [static]

Definition at line 817 of file font.cpp.

typedef std::map<std::string,SDL_Rect> line_size_cache_map [static]

Definition at line 97 of file font.cpp.

typedef int subset_id [static]

Definition at line 57 of file font.cpp.


Function Documentation

static bool add_font_to_fontlist ( config fonts_config,
std::vector< font::subset_descriptor > &  fontlist,
const std::string &  name 
) [static]

Definition at line 1084 of file font.cpp.

References config::find_child(), r, and utils::split().

Referenced by font::load_font_config().

static void clear_fonts (  )  [static]

Definition at line 198 of file font.cpp.

References font_map, font_names, font_table, and line_size_cache.

Referenced by font::set_font_list(), and font::manager::~manager().

static TTF_Font* get_font ( font_id  id  )  [static]

Definition at line 177 of file font.cpp.

References font_names, font_table, LOG_FT, open_font(), size, and subset.

Referenced by font::get_max_height().

static TTF_Font* open_font ( const std::string &  fname,
int  size 
) [static]

Definition at line 141 of file font.cpp.

References ERR_FT, file_exists(), name, and game_config::path.

Referenced by get_font().

static std::vector<text_chunk> split_text ( std::string const &  utf8_text  )  [static]


Variable Documentation

Definition at line 812 of file font.cpp.

Definition at line 810 of file font.cpp.

int bgalpha_

Definition at line 806 of file font.cpp.

SDL_Color bgcolour_

Definition at line 805 of file font.cpp.

int border_

Definition at line 813 of file font.cpp.

Definition at line 802 of file font.cpp.

text_list cache_ [static]

Definition at line 522 of file font.cpp.

std::vector<text_chunk> chunks_

Definition at line 374 of file font.cpp.

SDL_Rect clip_rect_

Definition at line 809 of file font.cpp.

SDL_Color color_

Definition at line 369 of file font.cpp.

SDL_Color colour_

Definition at line 805 of file font.cpp.

TTF_Font* font_

Definition at line 250 of file font.cpp.

std::vector<subset_id> font_map [static]

Definition at line 94 of file font.cpp.

Referenced by clear_fonts(), font::set_font_list(), and split_text().

std::vector<std::string> font_names [static]

Definition at line 76 of file font.cpp.

Referenced by clear_fonts(), get_font(), and font::set_font_list().

Definition at line 368 of file font.cpp.

std::map<font_id, TTF_Font*> font_table [static]

Definition at line 75 of file font.cpp.

Referenced by clear_fonts(), and get_font().

Definition at line 802 of file font.cpp.

int h_

Definition at line 371 of file font.cpp.

int hash_

Definition at line 367 of file font.cpp.

Definition at line 373 of file font.cpp.

std::stack<std::set<int> > label_contexts [static]

Definition at line 821 of file font.cpp.

int label_id = 1 [static]

Definition at line 819 of file font.cpp.

label_map labels [static]

Definition at line 818 of file font.cpp.

Referenced by default_map_generator::create_scenario().

int lifetime_

Definition at line 808 of file font.cpp.

Definition at line 100 of file font.cpp.

Referenced by clear_fonts(), and font::line_size().

unsigned int max_size_ [static]

Definition at line 523 of file font.cpp.

Definition at line 251 of file font.cpp.

bool scroll_

Definition at line 814 of file font.cpp.

int size

Definition at line 72 of file font.cpp.

Referenced by editormap::add_tiles_left(), editormap::add_tiles_right(), combatant::adjust_hitchance(), dialogs::advance_unit(), team::shroud_map::clear(), preferences::clock_format(), cut_surface(), gui2::twindow::do_show_help_popup(), gui2::twindow::do_show_tooltip(), hotkey::execute_command(), combatant::fight(), editormap::flip(), format_file_size(), game_logic::formula_function_expression::formula_function_expression(), cave_map_generator::generate_chambers(), gui2::tcontainer_::get_best_size(), get_font(), game_logic::get_functions_map(), gui2::tcontainer_::get_minimum_size(), replay::get_next_action(), team::get_side_colour_index(), gui2::tcontrol::get_single_line_best_size(), gui2::tgrid::get_size(), unit_type::has_random_traits(), theme::label::label(), gui2::tgrid::layout(), gui2::tcontrol::load_config(), gamemap::location::matches_range(), terrain_builder::parse_config(), dfool::arithmetic_evaluator::parse_tokens(), place_village(), replay::pre_replay(), process_queue(), t_translation::read_builder_map(), t_translation::read_game_map(), gui2::twindow::recalculate_size(), editormap::remove_tiles_bottom(), editormap::remove_tiles_top(), display::screenshot(), send_buffer(), CVideo::set_help_string(), map_editor::set_mouseover_overlay(), gui2::tgrid::set_size(), help::show_help(), theme::status_item::status_item(), utils::utf8_iterator::update(), map_editor::update_mouse_over_hexes(), team::shroud_map::value(), dfool::evaluator::value(), variable_info::variable_info(), font::word_wrap_text(), and unit::xp_color().

std::string str_

int style_

Definition at line 370 of file font.cpp.

Definition at line 69 of file font.cpp.

Referenced by get_font(), and font::set_font_list().

Definition at line 802 of file font.cpp.

std::vector<surface> surfs_

Definition at line 375 of file font.cpp.

std::string text

std::string text_

Definition at line 803 of file font.cpp.

Referenced by help::text_topic_generator::operator()().

Definition at line 91 of file font.cpp.

bool visible_

Definition at line 811 of file font.cpp.

int w_

Definition at line 371 of file font.cpp.

double xmove_

Definition at line 807 of file font.cpp.

double xpos_

Definition at line 807 of file font.cpp.

double ymove_

Definition at line 807 of file font.cpp.

double ypos_

Definition at line 807 of file font.cpp.


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs