diff --git a/src/font/bold_face.cpp b/src/font/bold_face.cpp index f32aea7b5..5afe7ef5b 100644 --- a/src/font/bold_face.cpp +++ b/src/font/bold_face.cpp @@ -18,6 +18,7 @@ #include "font/bold_face.hpp" +#include "config/user_config.hpp" #include "font/face_ttf.hpp" // ---------------------------------------------------------------------------- @@ -37,6 +38,7 @@ void BoldFace::init() setFallbackFontScale(2.0f);*/ } // init + // ---------------------------------------------------------------------------- void BoldFace::reset() { @@ -52,3 +54,17 @@ void BoldFace::reset() insertCharacters(preload_chars.c_str()); updateCharactersList(); } // reset + +// ---------------------------------------------------------------------------- +unsigned int BoldFace::getGlyphPageSize() const +{ + // If players somehow disable "Use high definition textures", irrlicht will + // set the max texture size to 512x512, which means it will resize all + // large texture, but it doesn't suitable for font texture, as the + // rectangle in spritebank depends on the original texture size, so we test + // if m_high_definition_textures is enabled here + if ((UserConfigParams::m_high_definition_textures & 0x01) == 0) + return 512; + + return 1024; +} // getGlyphPageSize diff --git a/src/font/bold_face.hpp b/src/font/bold_face.hpp index 53ddce8f5..12193141a 100644 --- a/src/font/bold_face.hpp +++ b/src/font/bold_face.hpp @@ -28,7 +28,7 @@ class BoldFace : public FontWithFace private: virtual bool supportLazyLoadChar() const OVERRIDE { return true; } // ------------------------------------------------------------------------ - virtual unsigned int getGlyphPageSize() const OVERRIDE { return 1024; } + virtual unsigned int getGlyphPageSize() const OVERRIDE; // ------------------------------------------------------------------------ virtual float getScalingFactorOne() const OVERRIDE { return 0.2f; } // ------------------------------------------------------------------------ diff --git a/src/font/digit_face.cpp b/src/font/digit_face.cpp index 7b257fce5..2403c4d6d 100644 --- a/src/font/digit_face.cpp +++ b/src/font/digit_face.cpp @@ -33,6 +33,7 @@ void DigitFace::init() m_font_max_height = m_glyph_max_height + 10; } // init + // ---------------------------------------------------------------------------- void DigitFace::reset() { diff --git a/src/font/font_with_face.cpp b/src/font/font_with_face.cpp index 0e1659ae0..a9befa2ae 100644 --- a/src/font/font_with_face.cpp +++ b/src/font/font_with_face.cpp @@ -306,11 +306,11 @@ void FontWithFace::dumpGlyphPage(const std::string& name) video::IImage* image = irr_driver->getVideoDriver() ->createImageFromData(col_format, size, data, false/*copy mem*/); - tex->unlock(); - irr_driver->getVideoDriver()->writeImageToFile(image, std::string - (name + "_" + StringUtils::toString(i) + ".png").c_str()); - image->drop(); - } + tex->unlock(); + irr_driver->getVideoDriver()->writeImageToFile(image, std::string + (name + "_" + StringUtils::toString(i) + ".png").c_str()); + image->drop(); + } } // dumpGlyphPage // ---------------------------------------------------------------------------- diff --git a/src/font/regular_face.cpp b/src/font/regular_face.cpp index f86a9ffc1..0a5fc500a 100644 --- a/src/font/regular_face.cpp +++ b/src/font/regular_face.cpp @@ -33,6 +33,7 @@ void RegularFace::init() m_font_max_height = m_glyph_max_height + 10; } // init + // ---------------------------------------------------------------------------- void RegularFace::reset() {