Fixed the font loading.
When the data directory is overridden the font path was initialized to the initial value and never updated.
This commit is contained in:
parent
805cc70f84
commit
1d51a60292
4 changed files with 37 additions and 5 deletions
|
@ -4,6 +4,7 @@ Version 1.5.6+svn:
|
|||
* updated translations:
|
||||
* User interface:
|
||||
* Rewrote the layout algorithm for the new widgets.
|
||||
* Fixed the font loading when the data directory is overridden.
|
||||
|
||||
Version 1.5.6:
|
||||
* Authoring tools:
|
||||
|
|
25
src/font.cpp
25
src/font.cpp
|
@ -290,6 +290,25 @@ manager::manager()
|
|||
LOG_FT << "Initialized true type fonts\n";
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
manager::~manager()
|
||||
{
|
||||
deinit();
|
||||
|
||||
clear_fonts();
|
||||
TTF_Quit();
|
||||
}
|
||||
|
||||
void manager::update_font_path() const
|
||||
{
|
||||
deinit();
|
||||
init();
|
||||
}
|
||||
|
||||
void manager::init() const
|
||||
{
|
||||
#ifdef CAIRO_HAS_FT_FONT
|
||||
if(!FcConfigAppFontAddDir( FcConfigGetCurrent(),
|
||||
reinterpret_cast<const FcChar8*>
|
||||
|
@ -309,18 +328,14 @@ manager::manager()
|
|||
AddFontResource(file.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
manager::~manager()
|
||||
void manager::deinit() const
|
||||
{
|
||||
#ifdef CAIRO_HAS_FT_FONT
|
||||
FcConfigAppFontClear(FcConfigGetCurrent());
|
||||
#endif
|
||||
|
||||
clear_fonts();
|
||||
TTF_Quit();
|
||||
|
||||
#if CAIRO_HAS_WIN32_FONT
|
||||
foreach(const std::string& path, get_binary_paths("fonts")) {
|
||||
std::vector<std::string> files;
|
||||
|
|
14
src/font.hpp
14
src/font.hpp
|
@ -31,7 +31,21 @@ namespace font {
|
|||
struct manager {
|
||||
manager();
|
||||
~manager();
|
||||
|
||||
/**
|
||||
* Updates the font path, when initialized it sets the fontpath to
|
||||
* game_config::path. When this path is updated, this function should be
|
||||
* called.
|
||||
*/
|
||||
void update_font_path() const;
|
||||
|
||||
struct error {};
|
||||
private:
|
||||
/** Initializes the font path. */
|
||||
void init() const;
|
||||
|
||||
/** Deinitializes the font path. */
|
||||
void deinit() const;
|
||||
};
|
||||
|
||||
//various standard colours
|
||||
|
|
|
@ -260,6 +260,7 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
// The path can be hardcoded and it might be a relative path.
|
||||
if(!game_config::path.empty() && game_config::path[0] != '/') {
|
||||
game_config::path = get_cwd() + '/' + game_config::path;
|
||||
font_manager_.update_font_path();
|
||||
}
|
||||
|
||||
for(arg_ = 1; arg_ != argc_; ++arg_) {
|
||||
|
@ -401,6 +402,7 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
throw config::error("directory not found");
|
||||
}
|
||||
|
||||
font_manager_.update_font_path();
|
||||
}
|
||||
}
|
||||
std::cerr << '\n';
|
||||
|
|
Loading…
Add table
Reference in a new issue