summaryrefslogtreecommitdiff
path: root/src/client/fontengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/fontengine.cpp')
-rw-r--r--src/client/fontengine.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client/fontengine.cpp b/src/client/fontengine.cpp
index ad8305b45..0ae50dfe2 100644
--- a/src/client/fontengine.cpp
+++ b/src/client/fontengine.cpp
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "gettext.h"
#include "irrlicht_changes/CGUITTFont.h"
+#include "util/numeric.h" // rangelim
/** maximum size distance for getting a "similar" font size */
#define MAX_FONT_SIZE_OFFSET 10
@@ -172,9 +173,9 @@ unsigned int FontEngine::getFontSize(FontMode mode)
/******************************************************************************/
void FontEngine::readSettings()
{
- m_default_size[FM_Standard] = g_settings->getU16("font_size");
- m_default_size[_FM_Fallback] = g_settings->getU16("font_size");
- m_default_size[FM_Mono] = g_settings->getU16("mono_font_size");
+ m_default_size[FM_Standard] = rangelim(g_settings->getU16("font_size"), 5, 72);
+ m_default_size[_FM_Fallback] = m_default_size[FM_Standard];
+ m_default_size[FM_Mono] = rangelim(g_settings->getU16("mono_font_size"), 5, 72);
m_default_bold = g_settings->getBool("font_bold");
m_default_italic = g_settings->getBool("font_italic");
@@ -217,8 +218,9 @@ gui::IGUIFont *FontEngine::initFont(const FontSpec &spec)
if (spec.italic)
setting_suffix.append("_italic");
- u32 size = std::max<u32>(spec.size * RenderingEngine::getDisplayDensity() *
- g_settings->getFloat("gui_scaling"), 1);
+ // Font size in pixels for FreeType
+ u32 size = rangelim(spec.size * RenderingEngine::getDisplayDensity() *
+ g_settings->getFloat("gui_scaling"), 1U, 500U);
// Constrain the font size to a certain multiple, if necessary
u16 divisible_by = g_settings->getU16(setting_prefix + "font_size_divisible_by");