Previous changes for fixing font (issue #33) where not needed, mistake was way smaller

0.8
Bruno Van de Velde 2015-01-21 13:57:23 +01:00
parent 098b8003ac
commit 977e239dae
3 changed files with 4 additions and 14 deletions

View File

@ -291,6 +291,7 @@ namespace tgui
void ChatBox::setTextFont(std::shared_ptr<sf::Font> font)
{
m_font = font;
m_panel->setGlobalFont(font);
bool lineChanged = false;
for (auto& label : m_panel->getWidgets())
@ -312,8 +313,6 @@ namespace tgui
updateDisplayedText();
}
m_panel->setGlobalFont(font);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -475,12 +475,9 @@ namespace tgui
void ChildWindow::initialize(Container *const parent)
{
Widget::initialize(parent);
Container::initialize(parent);
m_closeButton.initialize(this);
if (!m_font && m_parent->getGlobalFont())
setGlobalFont(m_parent->getGlobalFont());
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -89,11 +89,9 @@ namespace tgui
void Container::setGlobalFont(const std::string& filename)
{
auto font = std::make_shared<sf::Font>();
if (!font->loadFromFile(getResourcePath() + filename))
m_font = std::make_shared<sf::Font>();
if (!m_font->loadFromFile(getResourcePath() + filename))
throw Exception{"Failed to load font '" + filename + "'."};
setGlobalFont(font);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -101,10 +99,6 @@ namespace tgui
void Container::setGlobalFont(std::shared_ptr<sf::Font> font)
{
m_font = font;
// Widgets without a font are given a font now
for (auto& widget : m_widgets)
widget->initialize(this);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////