1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:29:55 +00:00
openmw/components/widgets/fontwrapper.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
C++
Raw Normal View History

2018-06-18 09:43:39 +00:00
#ifndef OPENMW_WIDGETS_WRAPPER_H
#define OPENMW_WIDGETS_WRAPPER_H
2023-05-21 16:21:42 +00:00
#include <MyGUI_Prerequest.h>
2023-07-16 18:46:54 +00:00
#include "components/settings/values.hpp"
2018-06-18 09:43:39 +00:00
2022-08-15 21:04:54 +00:00
#include <algorithm>
2018-06-18 09:43:39 +00:00
namespace Gui
{
template <class T>
class FontWrapper : public T
{
2023-05-21 16:21:42 +00:00
#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2)
2018-06-18 09:43:39 +00:00
public:
void setFontName(const std::string& name) override
2018-06-18 09:43:39 +00:00
{
T::setFontName(name);
2023-07-16 18:46:54 +00:00
T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize));
2018-06-18 09:43:39 +00:00
}
protected:
void setPropertyOverride(const std::string& _key, const std::string& _value) override
2018-06-18 09:43:39 +00:00
{
T::setPropertyOverride(_key, _value);
2023-05-21 16:21:42 +00:00
// https://github.com/MyGUI/mygui/issues/113
2018-06-18 09:43:39 +00:00
// There is a bug in MyGUI: when it initializes the FontName property, it reset the font height.
// We should restore it.
if (_key == "FontName")
{
2023-07-16 18:46:54 +00:00
T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize));
2018-06-18 09:43:39 +00:00
}
}
2023-05-21 16:21:42 +00:00
#endif
};
2018-06-18 09:43:39 +00:00
}
#endif