Correct fixes to #2599
This commit is contained in:
parent
aa15b0070e
commit
c71b24f98f
@ -54,17 +54,3 @@ 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
|
||||
|
@ -28,7 +28,7 @@ class BoldFace : public FontWithFace
|
||||
private:
|
||||
virtual bool supportLazyLoadChar() const OVERRIDE { return true; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual unsigned int getGlyphPageSize() const OVERRIDE;
|
||||
virtual unsigned int getGlyphPageSize() const OVERRIDE { return 1024; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual float getScalingFactorOne() const OVERRIDE { return 0.2f; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -116,6 +116,13 @@ void FontWithFace::createNewGlyphPage()
|
||||
m_used_width = 0;
|
||||
m_used_height = 0;
|
||||
|
||||
// Font textures can not be resized (besides the impact on quality in
|
||||
// this case, the rectangles in spritebank would become wrong).
|
||||
core::dimension2du old_max_size = irr_driver->getVideoDriver()
|
||||
->getDriverAttributes().getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
|
||||
irr_driver->getVideoDriver()->getNonConstDriverAttributes()
|
||||
.setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(0, 0));
|
||||
|
||||
video::ITexture* page_texture = irr_driver->getVideoDriver()
|
||||
->addTexture("Glyph_page", m_page);
|
||||
m_spritebank->addTexture(NULL);
|
||||
@ -127,6 +134,9 @@ void FontWithFace::createNewGlyphPage()
|
||||
irr_driver->getVideoDriver()->removeTexture(page_texture);
|
||||
assert(page_texture->getReferenceCount() == 1);
|
||||
|
||||
irr_driver->getVideoDriver()->getNonConstDriverAttributes()
|
||||
.setAttribute("MAX_TEXTURE_SIZE", old_max_size);
|
||||
|
||||
} // createNewGlyphPage
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -172,13 +182,22 @@ void FontWithFace::insertGlyph(wchar_t c, const GlyphInfo& gi)
|
||||
{
|
||||
// Current glyph page is full:
|
||||
// Save the old glyph page
|
||||
core::dimension2du old_max_size = irr_driver->getVideoDriver()
|
||||
->getDriverAttributes().getAttributeAsDimension2d
|
||||
("MAX_TEXTURE_SIZE");
|
||||
irr_driver->getVideoDriver()->getNonConstDriverAttributes()
|
||||
.setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(0, 0));
|
||||
video::ITexture* page_texture = irr_driver->getVideoDriver()
|
||||
->addTexture("Glyph_page", m_page);
|
||||
|
||||
m_spritebank->setTexture(m_spritebank->getTextureCount() - 1,
|
||||
page_texture);
|
||||
irr_driver->getVideoDriver()->removeTexture(page_texture);
|
||||
assert(page_texture->getReferenceCount() == 1);
|
||||
|
||||
irr_driver->getVideoDriver()->getNonConstDriverAttributes()
|
||||
.setAttribute("MAX_TEXTURE_SIZE", old_max_size);
|
||||
|
||||
// Clear and add a new one
|
||||
createNewGlyphPage();
|
||||
}
|
||||
@ -283,6 +302,11 @@ void FontWithFace::updateCharactersList()
|
||||
m_new_char_holder.clear();
|
||||
|
||||
// Update last glyph page
|
||||
core::dimension2du old_max_size = irr_driver->getVideoDriver()
|
||||
->getDriverAttributes().getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
|
||||
irr_driver->getVideoDriver()->getNonConstDriverAttributes()
|
||||
.setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(0, 0));
|
||||
|
||||
video::ITexture* page_texture = irr_driver->getVideoDriver()
|
||||
->addTexture("Glyph_page", m_page);
|
||||
m_spritebank->setTexture(m_spritebank->getTextureCount() - 1,
|
||||
@ -291,6 +315,9 @@ void FontWithFace::updateCharactersList()
|
||||
irr_driver->getVideoDriver()->removeTexture(page_texture);
|
||||
assert(page_texture->getReferenceCount() == 1);
|
||||
|
||||
irr_driver->getVideoDriver()->getNonConstDriverAttributes()
|
||||
.setAttribute("MAX_TEXTURE_SIZE", old_max_size);
|
||||
|
||||
} // updateCharactersList
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -109,14 +109,12 @@ private:
|
||||
FontWithFace* m_fallback_font;
|
||||
float m_fallback_font_scale;
|
||||
|
||||
/** A temporary holder stored new char to be inserted.
|
||||
*/
|
||||
/** A temporary holder stored new char to be inserted. */
|
||||
std::set<wchar_t> m_new_char_holder;
|
||||
|
||||
gui::IGUISpriteBank* m_spritebank;
|
||||
|
||||
/** A full glyph page for this font.
|
||||
*/
|
||||
/** A full glyph page for this font. */
|
||||
video::IImage* m_page;
|
||||
|
||||
unsigned int m_temp_height;
|
||||
|
Loading…
Reference in New Issue
Block a user