diff --git a/src/font/bold_face.cpp b/src/font/bold_face.cpp index 5afe7ef5b..771e35a26 100644 --- a/src/font/bold_face.cpp +++ b/src/font/bold_face.cpp @@ -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 diff --git a/src/font/bold_face.hpp b/src/font/bold_face.hpp index 12193141a..53ddce8f5 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; + virtual unsigned int getGlyphPageSize() const OVERRIDE { return 1024; } // ------------------------------------------------------------------------ virtual float getScalingFactorOne() const OVERRIDE { return 0.2f; } // ------------------------------------------------------------------------ diff --git a/src/font/font_with_face.cpp b/src/font/font_with_face.cpp index a9befa2ae..7dedffbef 100644 --- a/src/font/font_with_face.cpp +++ b/src/font/font_with_face.cpp @@ -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 // ---------------------------------------------------------------------------- diff --git a/src/font/font_with_face.hpp b/src/font/font_with_face.hpp index e219c9c30..52417a03c 100644 --- a/src/font/font_with_face.hpp +++ b/src/font/font_with_face.hpp @@ -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 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;