Added new setFont(ref_ptr<>) variants to Text and Text3D

This commit is contained in:
Robert Osfield
2007-12-12 17:48:20 +00:00
parent 256391c3b4
commit 213a370c25
6 changed files with 108 additions and 11 deletions

View File

@@ -67,12 +67,12 @@ Text::~Text()
{
}
void Text::setFont(Font* font)
void Text::setFont(osg::ref_ptr<Font> font)
{
if (_font==font) return;
osg::StateSet* previousFontStateSet = _font.valid() ? _font->getStateSet() : DefaultFont::instance()->getStateSet();
osg::StateSet* newFontStateSet = font ? font->getStateSet() : DefaultFont::instance()->getStateSet();
osg::StateSet* newFontStateSet = font.valid() ? font->getStateSet() : DefaultFont::instance()->getStateSet();
if (getStateSet() == previousFontStateSet)
{
@@ -86,7 +86,7 @@ void Text::setFont(Font* font)
void Text::setFont(const std::string& fontfile)
{
setFont(readRefFontFile(fontfile).get());
setFont(readRefFontFile(fontfile));
}

View File

@@ -42,7 +42,7 @@ Text3D::Text3D(const Text3D & text3D, const osg::CopyOp & copyop):
// TODO
//}
void Text3D::setFont(Font3D * font)
void Text3D::setFont(osg::ref_ptr<Font3D> font)
{
_font = font;
@@ -51,7 +51,7 @@ void Text3D::setFont(Font3D * font)
void Text3D::setFont(const std::string & fontfile)
{
setFont(readRefFont3DFile(fontfile).get());
setFont(readRefFont3DFile(fontfile));
}
String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last)