From 977e239dae7ee2fa975f159964c6803cc9cba6f5 Mon Sep 17 00:00:00 2001 From: Bruno Van de Velde Date: Wed, 21 Jan 2015 13:57:23 +0100 Subject: [PATCH] Previous changes for fixing font (issue #33) where not needed, mistake was way smaller --- src/TGUI/ChatBox.cpp | 3 +-- src/TGUI/ChildWindow.cpp | 5 +---- src/TGUI/Container.cpp | 10 ++-------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/TGUI/ChatBox.cpp b/src/TGUI/ChatBox.cpp index c8287416..42a258c8 100644 --- a/src/TGUI/ChatBox.cpp +++ b/src/TGUI/ChatBox.cpp @@ -291,6 +291,7 @@ namespace tgui void ChatBox::setTextFont(std::shared_ptr 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); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/TGUI/ChildWindow.cpp b/src/TGUI/ChildWindow.cpp index 3a49a7aa..f3efe228 100644 --- a/src/TGUI/ChildWindow.cpp +++ b/src/TGUI/ChildWindow.cpp @@ -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()); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/TGUI/Container.cpp b/src/TGUI/Container.cpp index e9f821e6..40f61b2c 100644 --- a/src/TGUI/Container.cpp +++ b/src/TGUI/Container.cpp @@ -89,11 +89,9 @@ namespace tgui void Container::setGlobalFont(const std::string& filename) { - auto font = std::make_shared(); - if (!font->loadFromFile(getResourcePath() + filename)) + m_font = std::make_shared(); + 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 font) { m_font = font; - - // Widgets without a font are given a font now - for (auto& widget : m_widgets) - widget->initialize(this); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////