diff --git a/include/osgText/Font b/include/osgText/Font index 6951b9116..1514ce591 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -104,9 +104,6 @@ public: /** Return true if this font provides vertical alignments and spacing or glyphs.*/ virtual bool hasVertical() const; - /** Return the scale to apply on the glyph to have a charactere size equal to 1 */ - virtual float getScale() const { return _implementation->getScale(); }; - /** Set the margin around each glyph, * to ensure that texture filtering doesn't bleed adjacent glyph's into each other. * Default margin is 1 texels.*/ @@ -229,9 +226,6 @@ public: /** Return true if this font provides vertical alignments and spacing or glyphs.*/ virtual bool hasVertical() const = 0; - /** Return scale of font, used by 3D text.*/ - virtual float getScale() const = 0; - void addGlyph(const FontResolution& fontRes, unsigned int charcode, Glyph* glyph) { _facade->addGlyph(fontRes, charcode, glyph); diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index 2a2cf317b..7eb87904f 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -206,7 +206,6 @@ FreeTypeFont::FreeTypeFont(const std::string& filename, FT_Face face, unsigned i _buffer(0), _face(face), _flags(flags), - _scale(1.0f), _freetype_scale(1.0f) { init(); @@ -218,7 +217,6 @@ FreeTypeFont::FreeTypeFont(FT_Byte* buffer, FT_Face face, unsigned int flags): _buffer(buffer), _face(face), _flags(flags), - _scale(1.0f), _freetype_scale(1.0f) { init(); @@ -303,14 +301,7 @@ void FreeTypeFont::init() // long xmin = ft_floor( bb.xMin ); // long xmax = ft_ceiling( bb.xMax ); // double width = (xmax - xmin)/64.0; - -#if 1 _freetype_scale = 1.0f/height; - _scale = 1.0f; -#else - _freetype_scale = 1.0f; - _scale = 1.0f/height; -#endif } } diff --git a/src/osgPlugins/freetype/FreeTypeFont.h b/src/osgPlugins/freetype/FreeTypeFont.h index ecfd58b4f..0906d8e6f 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.h +++ b/src/osgPlugins/freetype/FreeTypeFont.h @@ -39,8 +39,6 @@ public: virtual bool hasVertical() const; - virtual float getScale() const { return _scale; } - protected: void init(); @@ -57,7 +55,6 @@ protected: FT_Byte* _buffer; FT_Face _face; unsigned int _flags; - float _scale; float _freetype_scale; }; diff --git a/src/osgText/Text3D.cpp b/src/osgText/Text3D.cpp index 0a7bffa88..9730f0a86 100644 --- a/src/osgText/Text3D.cpp +++ b/src/osgText/Text3D.cpp @@ -138,8 +138,8 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i String::iterator lastChar = first; - float maximumHeight = _maximumHeight / _font->getScale(); - float maximumWidth = _maximumWidth / _font->getScale(); + float maximumHeight = _maximumHeight; + float maximumWidth = _maximumWidth; for(bool outOfSpace=false;lastChar!=last;++lastChar) { @@ -443,13 +443,13 @@ void Text3D::computeGlyphRepresentation() case LEFT_TO_RIGHT: case RIGHT_TO_LEFT: { - startOfLine_coords.y() -= (1.0 + _lineSpacing) / _font->getScale(); + startOfLine_coords.y() -= (1.0 + _lineSpacing); ++_lineCount; break; } case VERTICAL: { - startOfLine_coords.x() += _characterHeight / _font->getScale() / _characterAspectRatio * (1.0 + _lineSpacing); + startOfLine_coords.x() += _characterHeight / _characterAspectRatio * (1.0 + _lineSpacing); // because _lineCount is the max vertical no. of characters.... _lineCount = (_lineCount >linelength)?_lineCount:linelength; break; @@ -518,8 +518,7 @@ void Text3D::computePositions(unsigned int contextID) const osg::Matrix& matrix = atc._matrix; - float scale = _font->getScale(); - osg::Vec3 scaleVec(scale * _characterHeight, scale * _characterHeight / _characterAspectRatio, scale * _characterHeight); + osg::Vec3 scaleVec(_characterHeight, _characterHeight / _characterAspectRatio, _characterHeight); matrix.makeTranslate(-_offset); matrix.postMultScale(scaleVec); diff --git a/src/osgText/TextNode.cpp b/src/osgText/TextNode.cpp index ec0185603..d3d013e2f 100644 --- a/src/osgText/TextNode.cpp +++ b/src/osgText/TextNode.cpp @@ -80,12 +80,7 @@ void Layout::layout(TextNode& text) const float characterHeightScale = 1.0f; bool textIs3D = (style && style->getThicknessRatio()!=0.0); - if (textIs3D) - { - characterWidthScale = font->getScale(); - characterHeightScale = font->getScale(); - } - else + if (!textIs3D) { characterWidthScale = 1.0f/static_cast(resolution.first); characterHeightScale = 1.0f/static_cast(resolution.second); @@ -116,10 +111,8 @@ void Layout::layout(TextNode& text) const if (glyph) { osg::Vec3 local_scale( size ); - local_scale *= (1.0f/font->getScale()); - technique->addCharacter(pos, local_scale, glyph, style); - pos += osg::Vec3(size.x()*(glyph->getHorizontalWidth()/font->getScale()), 0.0f ,0.0f); + pos += osg::Vec3(size.x()*glyph->getHorizontalWidth(), 0.0f ,0.0f); } }