The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Namespaces | Macros | Typedefs | Functions | Variables
font.cpp File Reference
#include "global.hpp"
#include "config.hpp"
#include "filesystem.hpp"
#include "font.hpp"
#include "game_config.hpp"
#include "log.hpp"
#include "marked-up_text.hpp"
#include "text.hpp"
#include "tooltips.hpp"
#include "sdl/alpha.hpp"
#include "sdl/rect.hpp"
#include "serialization/parser.hpp"
#include "serialization/preprocessor.hpp"
#include "serialization/string_utils.hpp"
#include "serialization/unicode.hpp"
#include "preferences.hpp"
#include <boost/optional.hpp>
#include <list>
#include <set>
#include <stack>
#include <sstream>
#include <cairo-features.h>
Include dependency graph for font.cpp:

Go to the source code of this file.

Classes

struct  font_id
 
struct  ttf_record
 
struct  text_chunk
 
struct  char_block_map
 
struct  font::subset_descriptor
 

Namespaces

 font
 Graphical text output.
 

Macros

#define GETTEXT_DOMAIN   "wesnoth-lib"
 
#define DBG_FT   LOG_STREAM(debug, log_font)
 
#define LOG_FT   LOG_STREAM(info, log_font)
 
#define WRN_FT   LOG_STREAM(warn, log_font)
 
#define ERR_FT   LOG_STREAM(err, log_font)
 

Typedefs

typedef int subset_id
 
typedef std::map< font_id,
ttf_record
tfont_table
 
typedef std::map< std::string,
SDL_Rect > 
line_size_cache_map
 
typedef std::map< std::pair
< std::string, int >, TTF_Font * > 
topen_font_cache
 

Functions

static std::vector< text_chunksplit_text (std::string const &utf8_text)
 
static TTF_Font * open_font_impl (const std::string &, int)
 
static TTF_Font * open_font (const std::string &fname, int size)
 
static TTF_Font * get_font (font_id id)
 
static void clear_fonts ()
 
static bool font::check_font_file (std::string name)
 
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 &color, int style, bool use_markup)
 
surface font::get_rendered_text (const std::string &str, int size, const SDL_Color &color, int style)
 
SDL_Rect font::draw_text_line (surface &gui_surface, const SDL_Rect &area, int size, const SDL_Color &color, 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. More...
 
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. More...
 
std::string font::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...
 
static bool add_font_to_fontlist (const config &fonts_config, std::vector< font::subset_descriptor > &fontlist, const std::string &name)
 
bool font::load_font_config ()
 
const t_stringfont::get_font_families (family_class fclass=FONT_SANS_SERIF)
 Returns the currently defined fonts. More...
 
void font::cache_mode (CACHE mode)
 

Variables

static lg::log_domain log_font ("font")
 
static tfont_table font_table
 
static std::vector< std::stringfont_names
 
static std::vector< std::stringbold_names
 
static std::vector< std::stringitalic_names
 
static char_block_map char_blocks
 
static std::map< int, std::map
< int, line_size_cache_map > > 
line_size_cache
 
topen_font_cache open_fonts
 
const SDL_Color font::NORMAL_COLOR = {0xDD,0xDD,0xDD,0}
 
const SDL_Color font::GRAY_COLOR = {0x77,0x77,0x77,0}
 
const SDL_Color font::LOBBY_COLOR = {0xBB,0xBB,0xBB,0}
 
const SDL_Color font::GOOD_COLOR = {0x00,0xFF,0x00,0}
 
const SDL_Color font::BAD_COLOR = {0xFF,0x00,0x00,0}
 
const SDL_Color font::BLACK_COLOR = {0x00,0x00,0x00,0}
 
const SDL_Color font::YELLOW_COLOR = {0xFF,0xFF,0x00,0}
 
const SDL_Color font::BUTTON_COLOR = {0xBC,0xB0,0x88,0}
 
const SDL_Color font::PETRIFIED_COLOR = {0xA0,0xA0,0xA0,0}
 
const SDL_Color font::TITLE_COLOR = {0xBC,0xB0,0x88,0}
 
const SDL_Color font::LABEL_COLOR = {0x6B,0x8C,0xFF,0}
 
const SDL_Color font::BIGMAP_COLOR = {0xFF,0xFF,0xFF,0}
 
const SDL_Color font::DISABLED_COLOR = inverse(PETRIFIED_COLOR)
 

Macro Definition Documentation

#define DBG_FT   LOG_STREAM(debug, log_font)

Definition at line 60 of file font.cpp.

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

#define ERR_FT   LOG_STREAM(err, log_font)
#define GETTEXT_DOMAIN   "wesnoth-lib"

Definition at line 16 of file font.cpp.

#define LOG_FT   LOG_STREAM(info, log_font)

Definition at line 61 of file font.cpp.

Referenced by char_block_map::compress(), font::manager::init(), and font::manager::manager().

#define WRN_FT   LOG_STREAM(warn, log_font)

Definition at line 62 of file font.cpp.

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

Typedef Documentation

typedef std::map<std::string,SDL_Rect> line_size_cache_map

Definition at line 191 of file font.cpp.

typedef int subset_id

Definition at line 70 of file font.cpp.

typedef std::map<font_id, ttf_record> tfont_table

Definition at line 101 of file font.cpp.

typedef std::map<std::pair<std::string, int>, TTF_Font*> topen_font_cache

Definition at line 228 of file font.cpp.

Function Documentation

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

Definition at line 1027 of file font.cpp.

References config::find_child().

Referenced by font::load_font_config().

static void clear_fonts ( )
static

Definition at line 346 of file font.cpp.

References char_block_map::cbmap, font_table, i, and open_fonts.

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

static TTF_Font* get_font ( font_id  id)
static

Definition at line 295 of file font.cpp.

References font_table, and open_font().

Referenced by font::get_max_height().

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

Definition at line 236 of file font.cpp.

References open_font_impl(), and open_fonts.

Referenced by get_font().

static TTF_Font * open_font_impl ( const std::string fname,
int  size 
)
static

Definition at line 249 of file font.cpp.

References DBG_FT, ERR_FT, filesystem::file_exists(), filesystem::load_RWops(), and game_config::path.

Referenced by open_font().

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

Variable Documentation

std::vector<std::string> bold_names
static

Definition at line 105 of file font.cpp.

text_list cache_
static

Definition at line 772 of file font.cpp.

Referenced by test_config_cache::instance(), and movetype::terrain_info::data::value().

char_block_map char_blocks
static

Definition at line 188 of file font.cpp.

std::vector<text_chunk> chunks_
mutable

Definition at line 610 of file font.cpp.

SDL_Color color_
std::vector<std::string> font_names
static

Definition at line 104 of file font.cpp.

int font_size_

Definition at line 604 of file font.cpp.

Referenced by gui::menu::style::get_font_size().

tfont_table font_table
static

Definition at line 103 of file font.cpp.

Referenced by clear_fonts(), and get_font().

int h_
mutable

Definition at line 607 of file font.cpp.

Referenced by image::scale_modification::get_h(), and editor::start().

int hash_

Definition at line 603 of file font.cpp.

Referenced by terrain_builder::building_rule::get_hash().

bool initialized_
mutable

Definition at line 609 of file font.cpp.

Referenced by gui2::init(), and gui::menu::imgsel_style::load_images().

std::vector<std::string> italic_names
static

Definition at line 106 of file font.cpp.

std::map<int,std::map<int,line_size_cache_map> > line_size_cache
static

Definition at line 194 of file font.cpp.

lg::log_domain log_font("font")
static
unsigned int max_size_
static

Definition at line 773 of file font.cpp.

topen_font_cache open_fonts

Definition at line 229 of file font.cpp.

Referenced by clear_fonts(), and open_font().

Definition at line 608 of file font.cpp.

int style_

Definition at line 606 of file font.cpp.

std::vector<surface> surfs_
mutable

Definition at line 611 of file font.cpp.

int w_
mutable

Definition at line 607 of file font.cpp.

Referenced by image::scale_modification::get_w().