Determine the texture size of bold face smartly

This commit is contained in:
Benau 2016-08-12 08:31:52 +08:00
parent 2d95df1722
commit aa15b0070e
5 changed files with 24 additions and 6 deletions

View File

@ -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

View File

@ -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; }
// ------------------------------------------------------------------------

View File

@ -33,6 +33,7 @@ void DigitFace::init()
m_font_max_height = m_glyph_max_height + 10;
} // init
// ----------------------------------------------------------------------------
void DigitFace::reset()
{

View File

@ -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
// ----------------------------------------------------------------------------

View File

@ -33,6 +33,7 @@ void RegularFace::init()
m_font_max_height = m_glyph_max_height + 10;
} // init
// ----------------------------------------------------------------------------
void RegularFace::reset()
{