Moved set/getFont from Text/Text3D into TextBase

This commit is contained in:
Robert Osfield
2010-09-29 11:34:55 +00:00
parent e942cc770a
commit b40acacf53
12 changed files with 78 additions and 149 deletions

View File

@@ -55,6 +55,7 @@ TextBase::TextBase():
TextBase::TextBase(const TextBase& textBase,const osg::CopyOp& copyop):
osg::Drawable(textBase,copyop),
_font(textBase._font),
_fontSize(textBase._fontSize),
_characterHeight(textBase._characterHeight),
_characterAspectRatio(textBase._characterAspectRatio),
@@ -81,6 +82,29 @@ TextBase::~TextBase()
{
}
void TextBase::setFont(osg::ref_ptr<Font> font)
{
if (_font==font) return;
osg::StateSet* previousFontStateSet = _font.valid() ? _font->getStateSet() : Font::getDefaultFont()->getStateSet();
osg::StateSet* newFontStateSet = font.valid() ? font->getStateSet() : Font::getDefaultFont()->getStateSet();
if (getStateSet() == previousFontStateSet)
{
setStateSet( newFontStateSet );
}
_font = font;
computeGlyphRepresentation();
}
void TextBase::setFont(const std::string& fontfile)
{
setFont(readRefFontFile(fontfile));
}
void TextBase::setFontResolution(unsigned int width, unsigned int height)
{
_fontSize = FontResolution(width,height);