Commit dd198af9 authored by hybrid's avatar hybrid

Add possibility to add externally loaded/created fonts.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2989 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e699ab88
......@@ -166,6 +166,14 @@ public:
more information. */
virtual IGUIFont* getFont(const io::path& filename) = 0;
//! Adds an externally loaded font to the font list.
/** This method allows to attach an already loaded font to the list of
existing fonts. The font is grabbed if non-null.
\param name Name the font should be stored as.
\param font Pointer to font to add.
\return Pointer to the font stored. This can differ from given parameter if the name previously existed. */
virtual IGUIFont* addFont(const io::path& name, IGUIFont* font) = 0;
//! Returns the default built-in font.
/** \return Pointer to the default built-in font.
This pointer should not be dropped. See IReferenceCounted::drop() for
......
......@@ -1303,16 +1303,13 @@ IGUIComboBox* CGUIEnvironment::addComboBox(const core::rect<s32>& rectangle,
}
//! returns the font
IGUIFont* CGUIEnvironment::getFont(const io::path& filename)
{
// search existing font
SFont f;
IGUIFont* ifont=0;
f.Filename = filename;
f.Filename.make_lower();
s32 index = Fonts.binary_search(f);
......@@ -1329,6 +1326,7 @@ IGUIFont* CGUIEnvironment::getFont(const io::path& filename)
return 0;
}
IGUIFont* ifont=0;
io::IXMLReader *xml = FileSystem->createXMLReader(filename );
if (xml)
{
......@@ -1409,6 +1407,34 @@ IGUIFont* CGUIEnvironment::getFont(const io::path& filename)
}
//! add an externally loaded font
IGUIFont* CGUIEnvironment::addFont(const io::path& name, IGUIFont* font)
{
if (font)
{
SFont f;
f.Filename = name;
s32 index = Fonts.binary_search(f);
if (index != -1)
return Fonts[index].Font;
f.Font = font;
Fonts.push_back(f);
font->grab();
}
return font;
}
//! returns default font
IGUIFont* CGUIEnvironment::getBuiltInFont() const
{
if (Fonts.empty())
return 0;
return Fonts[0].Font;
}
IGUISpriteBank* CGUIEnvironment::getSpriteBank(const io::path& filename)
{
// search for the file name
......@@ -1456,15 +1482,6 @@ IGUISpriteBank* CGUIEnvironment::addEmptySpriteBank(const io::path& name)
}
//! returns default font
IGUIFont* CGUIEnvironment::getBuiltInFont() const
{
if (Fonts.empty())
return 0;
return Fonts[0].Font;
}
//! Creates the image list from the given texture.
IGUIImageList* CGUIEnvironment::createImageList( video::ITexture* texture,
core::dimension2d<s32> imageSize, bool useAlphaChannel )
......
......@@ -77,6 +77,11 @@ public:
//! returns the font
virtual IGUIFont* getFont(const io::path& filename);
//! add an externally loaded font
virtual IGUIFont* addFont(const io::path& name, IGUIFont* font);
//! returns default font
virtual IGUIFont* getBuiltInFont() const;
//! returns the sprite bank
virtual IGUISpriteBank* getSpriteBank(const io::path& filename);
......@@ -182,9 +187,6 @@ public:
//! Returns the element with the focus
virtual IGUIElement* getFocus() const;
//! returns default font
virtual IGUIFont* getBuiltInFont() const;
//! Adds an element for fading in or out.
virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1);
......
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