Moved Font code across to using FontSizePair internally and on Font methods, but

still using original implemetations.
This commit is contained in:
Robert Osfield
2007-12-23 13:45:37 +00:00
parent dea067050c
commit f290b75bc9
10 changed files with 20 additions and 22 deletions

View File

@@ -261,9 +261,9 @@ std::string Font::getFileName() const
return "";
}
void Font::setFontResolution(unsigned int width, unsigned int height)
void Font::setFontResolution(const FontSizePair& fontSize)
{
if (_implementation.valid()) _implementation->setFontResolution(width, height);
if (_implementation.valid()) _implementation->setFontResolution(fontSize);
}
unsigned int Font::getFontWidth() const

View File

@@ -279,7 +279,7 @@ void Text::computeGlyphRepresentation()
unsigned int lineNumber = 0;
activefont->setFontResolution(_fontWidth,_fontHeight);
activefont->setFontResolution(_fontSize);
float hr = _characterHeight/(float)activefont->getFontHeight();
float wr = hr/_characterAspectRatio;
@@ -696,9 +696,9 @@ void Text::computePositions(unsigned int contextID) const
scale_font_vert=-scale_font_vert;
matrix.postMult(osg::Matrix::scale(scale_font_hori, scale_font_vert,1.0f));
}
else if (pixelSizeVert>_fontHeight)
else if (pixelSizeVert>getFontHeight())
{
float scale_font = _fontHeight/pixelSizeVert;
float scale_font = getFontHeight()/pixelSizeVert;
matrix.postMult(osg::Matrix::scale(scale_font, scale_font,1.0f));
}

View File

@@ -32,8 +32,7 @@ using namespace osgText;
//#define TREES_CODE_FOR_MAKING_SPACES_EDITABLE
TextBase::TextBase():
_fontWidth(32),
_fontHeight(32),
_fontSize(32,32),
_characterHeight(32),
_characterAspectRatio(1.0f),
_characterSizeMode(OBJECT_COORDS),
@@ -55,8 +54,7 @@ TextBase::TextBase():
TextBase::TextBase(const TextBase& textBase,const osg::CopyOp& copyop):
osg::Drawable(textBase,copyop),
_fontWidth(textBase._fontWidth),
_fontHeight(textBase._fontHeight),
_fontSize(textBase._fontSize),
_characterHeight(textBase._characterHeight),
_characterAspectRatio(textBase._characterAspectRatio),
_characterSizeMode(textBase._characterSizeMode),
@@ -82,8 +80,7 @@ TextBase::~TextBase()
void TextBase::setFontResolution(unsigned int width, unsigned int height)
{
_fontWidth = width;
_fontHeight = height;
_fontSize = FontSizePair(width,height);
computeGlyphRepresentation();
}