Commit 26cb207c authored by cutealien's avatar cutealien

Bugfix: getFont for xml-fonts now also works for fonts inside archives (thx @Neirdan for bugreport)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4682 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1e828d9a
......@@ -1448,19 +1448,16 @@ IGUIFont* CGUIEnvironment::getFont(const io::path& filename)
{
CGUIFont* font = new CGUIFont(this, filename);
ifont = (IGUIFont*)font;
// change working directory, for loading textures
io::path workingDir = FileSystem->getWorkingDirectory();
FileSystem->changeWorkingDirectoryTo(FileSystem->getFileDir(f.NamedPath.getPath()));
// load the font
if (!font->load(xml))
io::path directory;
core::splitFilename(filename, &directory);
if (!font->load(xml, directory))
{
font->drop();
font = 0;
ifont = 0;
}
// change working dir back again
FileSystem->changeWorkingDirectoryTo( workingDir );
}
else if (t==EGFT_VECTOR)
{
......
......@@ -6,6 +6,7 @@
#ifdef _IRR_COMPILE_WITH_GUI_
#include "os.h"
#include "coreutil.h"
#include "IGUIEnvironment.h"
#include "IXMLReader.h"
#include "IReadFile.h"
......@@ -63,7 +64,7 @@ CGUIFont::~CGUIFont()
//! loads a font file from xml
bool CGUIFont::load(io::IXMLReader* xml)
bool CGUIFont::load(io::IXMLReader* xml, const io::path& directory)
{
if (!SpriteBank)
return false;
......@@ -89,7 +90,8 @@ bool CGUIFont::load(io::IXMLReader* xml)
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
// load texture
SpriteBank->setTexture(i, Driver->getTexture(fn));
io::path textureFullName = core::mergeFilename(directory, fn);
SpriteBank->setTexture(i, Driver->getTexture(textureFullName));
// set previous mip-map+filter state
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap);
......
......@@ -46,7 +46,8 @@ public:
bool load(io::IReadFile* file);
//! loads a font from an XML file
bool load(io::IXMLReader* xml);
//\param directory Directory in which the bitmaps can be found
bool load(io::IXMLReader* xml, const io::path& directory);
//! draws an text and clips it to the specified rectangle if wanted
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment