The Battle for Wesnoth  1.15.7+dev
Public Member Functions | Static Public Member Functions | List of all members
font::sdl_ttf Struct Reference

#include <sdl_ttf.hpp>

Public Member Functions

 sdl_ttf ()
 
 ~sdl_ttf ()
 
 sdl_ttf (const sdl_ttf &)=delete
 
sdl_ttfoperator= (const sdl_ttf &)=delete
 

Static Public Member Functions

static std::shared_ptr< TTF_Font > get_font (font_id)
 
static void set_font_list (const std::vector< subset_descriptor > &fontlist)
 Set the list of fonts. More...
 
static std::vector< text_chunksplit_text (const std::string &utf8_text)
 Splits the UTF-8 text into text_chunks using the same font. More...
 

Detailed Description

Definition at line 66 of file sdl_ttf.hpp.

Constructor & Destructor Documentation

◆ sdl_ttf() [1/2]

font::sdl_ttf::sdl_ttf ( )

Definition at line 440 of file sdl_ttf.cpp.

References ERR_FT, error(), and LOG_FT.

◆ ~sdl_ttf()

font::sdl_ttf::~sdl_ttf ( )

Definition at line 464 of file sdl_ttf.cpp.

References font::clear_fonts().

◆ sdl_ttf() [2/2]

font::sdl_ttf::sdl_ttf ( const sdl_ttf )
delete

Member Function Documentation

◆ get_font()

std::shared_ptr< TTF_Font > font::sdl_ttf::get_font ( font_id  id)
static

◆ operator=()

sdl_ttf& font::sdl_ttf::operator= ( const sdl_ttf )
delete

◆ set_font_list()

void font::sdl_ttf::set_font_list ( const std::vector< subset_descriptor > &  fontlist)
static

Set the list of fonts.

The order denotes the priority - if text could be rendered with more than one of these fonts, the one given earlier will be used.

Definition at line 471 of file sdl_ttf.cpp.

References font::check_font_file(), font::clear_fonts(), DBG_FT, f, preferences::font_scaled(), get_font(), i, font::SIZE_NORMAL, subset, and swap().

Referenced by font::load_font_config().

◆ split_text()

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

Splits the UTF-8 text into text_chunks using the same font.

This uses a greedy-match - once we've found the start of a chunk, include as many characters as we can in the same chunk.

If we've got a fallback font that contains all characters, and a preferred font that will only contains some of them, this means that we minimize the number of times that we switch from one font to the other - once we've had to use the fallback, keep using it.

This also means that combining characters such as U+308 or U+FE00 are kept with the character that they should be modifying.

Definition at line 557 of file sdl_ttf.cpp.

References ucs4::iterator_base< string_type, update_implementation >::end(), mariadb::value::string, and WRN_FT.

Referenced by font::text_surface::height(), and font::text_surface::width().


The documentation for this struct was generated from the following files: