From ba10f56f86f29cd017e696ef1d936c9abd87ce8d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 3 Sep 2010 09:08:19 +0000 Subject: [PATCH] Refactored to use a typedef of Font to Font3D rather than have a separate Font3D class --- include/osgQt/QFontImplementation | 3 +- include/osgText/Font | 5 +- include/osgText/Font3D | 172 ++---------------- include/osgText/Text3D | 2 +- src/osgPlugins/freetype/CMakeLists.txt | 2 - src/osgPlugins/freetype/FreeTypeFont.cpp | 4 +- src/osgPlugins/freetype/FreeTypeFont.h | 2 +- src/osgPlugins/freetype/FreeTypeLibrary.cpp | 40 ---- src/osgPlugins/freetype/FreeTypeLibrary.h | 7 - .../freetype/ReaderWriterFreeType.cpp | 23 +-- src/osgPlugins/txf/TXFFont.cpp | 2 +- src/osgPlugins/txf/TXFFont.h | 2 +- src/osgQt/QFontImplementation.cpp | 3 +- src/osgText/CMakeLists.txt | 1 - src/osgText/DefaultFont.cpp | 2 +- src/osgText/DefaultFont.h | 2 +- src/osgText/Font.cpp | 10 +- src/osgText/Font3D.cpp | 5 - src/osgText/Text.cpp | 8 +- src/osgText/Text3D.cpp | 6 +- 20 files changed, 50 insertions(+), 251 deletions(-) diff --git a/include/osgQt/QFontImplementation b/include/osgQt/QFontImplementation index 5944e6bd8..c2bd056c0 100644 --- a/include/osgQt/QFontImplementation +++ b/include/osgQt/QFontImplementation @@ -33,8 +33,7 @@ public: void setFontResolution(const osgText::FontResolution& fontSize); virtual osgText::Glyph* getGlyph(const osgText::FontResolution& fontRes, unsigned int charcode); virtual osgText::Glyph3D* getGlyph3D(unsigned int charcode) { return 0; } - virtual osg::Vec2 getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, - unsigned int rightcharcode, osgText::KerningType kerningType); + virtual osg::Vec2 getKerning(unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType kerningType); virtual bool hasVertical() const; virtual float getScale() const { return 1.0f; } diff --git a/include/osgText/Font b/include/osgText/Font index 256e7546e..6f8013916 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -317,11 +317,12 @@ public: /** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/ - virtual osg::Vec2 getKerning(const FontResolution& fontSize, unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType); + virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType); /** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/ virtual Glyph* getGlyph(const FontResolution& fontSize, unsigned int charcode); + /** Get a Glyph3D for specified charcode.*/ virtual Glyph3D* getGlyph3D(unsigned int charcode); @@ -448,7 +449,7 @@ public: virtual Glyph3D* getGlyph3D(unsigned int charcode) = 0; /** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/ - virtual osg::Vec2 getKerning(const FontResolution& fontRes, unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType) = 0; + virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType) = 0; /** Return true if this font provides vertical alignments and spacing or glyphs.*/ virtual bool hasVertical() const = 0; diff --git a/include/osgText/Font3D b/include/osgText/Font3D index 56cda8ec4..d3c51eabb 100644 --- a/include/osgText/Font3D +++ b/include/osgText/Font3D @@ -14,169 +14,37 @@ #ifndef OSGTEXT_FONT3D #define OSGTEXT_FONT3D 1 -#include -#include - -#include -#include -#include -#include -#include #include -#include - namespace osgText { -class Font3D; -class Text3D; +typedef Font Font3D; - -/** Read a font from specified file. The filename may contain a path. - * It will search for the font file in the following places in this order: - * - In the current directory - * - All paths defined in OSG_FILE_PATH or OSGFILEPATH environment variable - * - Filename with path stripped: In the current directory - * - Filename with path stripped: All paths defined in OSG_FILE_PATH or OSGFILEPATH - * - * Then the file will be searched in OS specific directories in the following order: - * - Again in the current directory - * - Windows: In C:/winnt/fonts - * - Windows: In C:/windows/fonts - * - Windows: In the fonts directory of the windows install directory - * - Other OS: In /usr/share/fonts/ttf - * - Other OS: In /usr/share/fonts/ttf/western - * - Other OS: In /usr/share/fonts/ttf/decoratives - * - * If the given file could not be found, the path part will be stripped and - * the file will be searched again in the OS specific directories. - */ -extern OSGTEXT_EXPORT Font3D* readFont3DFile(const std::string& filename, const osgDB::ReaderWriter::Options* userOptions = 0); - -/** read a font from specified stream.*/ -extern OSGTEXT_EXPORT Font3D* readFont3DStream(std::istream& stream, const osgDB::ReaderWriter::Options* userOptions = 0); - -extern OSGTEXT_EXPORT osg::ref_ptr readRefFont3DFile(const std::string& filename, const osgDB::ReaderWriter::Options* userOptions = 0); - -extern OSGTEXT_EXPORT osg::ref_ptr readRefFont3DStream(std::istream& stream, const osgDB::ReaderWriter::Options* userOptions = 0); - -extern OSGTEXT_EXPORT std::string findFont3DFile(const std::string& str); - -/** Pure virtual base class for fonts. - * Concrete implementation are the DefaultFont found in src/osgText/DefaultFont.cpp - * and FreeTypeFont found in src/osgPlugins/freetype/FreeTypeFont.cpp*/ -class OSGTEXT_EXPORT Font3D : public osg::Object +inline Font* readFont3DFile(const std::string& filename, const osgDB::ReaderWriter::Options* userOptions = 0) { -// declare the interface to a font. -public: + return readFontFile(filename,userOptions); +} - // forward declare nested classes. - class Font3DImplementation; +inline Font* readFont3DStream(std::istream& stream, const osgDB::ReaderWriter::Options* userOptions = 0) +{ + return readFontStream(stream, userOptions); +} -public: - Font3D(Font3DImplementation* implementation=0); +inline osg::ref_ptr readRefFont3DFile(const std::string& filename, const osgDB::ReaderWriter::Options* userOptions = 0) +{ + return readRefFontFile(filename, userOptions); +} - virtual osg::Object* cloneType() const { return 0; } // cloneType() not appropriate - virtual osg::Object* clone(const osg::CopyOp&) const { return 0; } // clone() not appropriate - virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } - virtual const char* className() const { return "Font3D"; } - virtual const char* libraryName() const { return "osgText"; } +inline osg::ref_ptr readRefFont3DStream(std::istream& stream, const osgDB::ReaderWriter::Options* userOptions = 0) +{ + return readRefFontStream(stream, userOptions); +} - virtual std::string getFileName() const; - - unsigned int getFontWidth() const { return _width; } - unsigned int getFontHeight() const { return _height; } - unsigned int getFontDepth() const { return _depth; } - - void setNumberCurveSamples(unsigned int numSamples) { _numCurveSamples = numSamples; } - unsigned int getNumberCurveSamples() const { return _numCurveSamples; } - - /** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/ - virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType); - - /** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/ - virtual Glyph3D* getGlyph(unsigned int charcode); - - /** 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(); }; - - // make Text a friend to allow it add and remove its entry in the Font's _textList. - friend class Font3DImplementation; - - void setImplementation(Font3DImplementation* implementation); - - Font3DImplementation* getImplementation(); - const Font3DImplementation* getImplementation() const; - - /** Set whether to use a mutex to ensure ref() and unref() */ - virtual void setThreadSafeRefUnref(bool threadSafe); - - typedef OpenThreads::Mutex Font3DMutex; - -protected: - - virtual ~Font3D(); - -// void addGlyph(unsigned int width, unsigned int height, unsigned int charcode, Glyph* glyph); - void addGlyph(unsigned int charcode, Glyph3D* glyph); - - // current active size of font - unsigned int _depth; - unsigned int _width; - unsigned int _height; - - unsigned int _numCurveSamples; - -// unsigned int _margin; -// float _marginRatio; - - typedef std::map > Glyph3DMap; - Glyph3DMap _glyph3DMap; - - osg::ref_ptr _implementation; - - -// declare the nested classes. -public: - - class Font3DImplementation : public osg::Referenced - { - public: - - Font3DImplementation(): - osg::Referenced(true), - _facade(0) {} - - virtual std::string getFileName() const = 0; - - /** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/ - virtual Glyph3D* getGlyph(unsigned int charcode) = 0; - - /** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/ - virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType) = 0; - - /** Return true if this font provides vertical alignments and spacing or glyphs.*/ - virtual bool hasVertical() const = 0; - - virtual float getScale() const = 0; - - void setFontWidth(unsigned int width) { _facade->_width = width; } - - void setFontHeight(unsigned int height) { _facade->_height = height; } - - void setFontDepth(unsigned int depth) { _facade->_depth = depth; } - - Font3D* _facade; - }; - - - -}; +inline std::string findFont3DFile(const std::string& str) +{ + return findFontFile(str); +} } - #endif diff --git a/include/osgText/Text3D b/include/osgText/Text3D index a9501d0e9..16924780e 100644 --- a/include/osgText/Text3D +++ b/include/osgText/Text3D @@ -124,7 +124,7 @@ public: // // make Font a friend to allow it set the _font to 0 if the font is // // forcefully unloaded. - friend class Font3D; + friend class Font; virtual osg::BoundingBox computeBound() const; diff --git a/src/osgPlugins/freetype/CMakeLists.txt b/src/osgPlugins/freetype/CMakeLists.txt index 72d5463f3..24436fee5 100644 --- a/src/osgPlugins/freetype/CMakeLists.txt +++ b/src/osgPlugins/freetype/CMakeLists.txt @@ -10,12 +10,10 @@ ENDIF() SET(TARGET_SRC FreeTypeFont.cpp - FreeTypeFont3D.cpp FreeTypeLibrary.cpp ReaderWriterFreeType.cpp ) SET(TARGET_H FreeTypeFont.h - FreeTypeFont3D.h FreeTypeLibrary.h ) SET(TARGET_ADDED_LIBRARIES osgText ) SET(TARGET_LIBRARIES_VARS FREETYPE_LIBRARY ) diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index 2707aecc0..de8b17823 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -620,14 +620,12 @@ osgText::Glyph3D * FreeTypeFont::getGlyph3D(unsigned int charcode) return glyph3D.release(); } -osg::Vec2 FreeTypeFont::getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType) +osg::Vec2 FreeTypeFont::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType) { OpenThreads::ScopedLock lock(FreeTypeLibrary::instance()->getMutex()); if (!FT_HAS_KERNING(_face) || (kerningType == osgText::KERNING_NONE)) return osg::Vec2(0.0f,0.0f); - setFontResolution(fontRes); - FT_Kerning_Mode mode = (kerningType==osgText::KERNING_DEFAULT) ? ft_kerning_default : ft_kerning_unfitted; // convert character code to glyph index diff --git a/src/osgPlugins/freetype/FreeTypeFont.h b/src/osgPlugins/freetype/FreeTypeFont.h index aeeecb48c..9f002041d 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.h +++ b/src/osgPlugins/freetype/FreeTypeFont.h @@ -35,7 +35,7 @@ public: virtual osgText::Glyph3D* getGlyph3D(unsigned int charcode); - virtual osg::Vec2 getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType _kerningType); + virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType _kerningType); virtual bool hasVertical() const; diff --git a/src/osgPlugins/freetype/FreeTypeLibrary.cpp b/src/osgPlugins/freetype/FreeTypeLibrary.cpp index 07f482e72..2969093b6 100644 --- a/src/osgPlugins/freetype/FreeTypeLibrary.cpp +++ b/src/osgPlugins/freetype/FreeTypeLibrary.cpp @@ -49,15 +49,6 @@ FreeTypeLibrary::~FreeTypeLibrary() else fontImplementation->_facade = 0; } - while(!_font3DImplementationSet.empty()) - { - FreeTypeFont3D* font3DImplementation = *_font3DImplementationSet.begin(); - _font3DImplementationSet.erase(_font3DImplementationSet.begin()); - osgText::Font3D* font3D = font3DImplementation->_facade; - if (font3D) font3D->setImplementation(0); - else font3DImplementation->_facade = 0; - } - FT_Done_FreeType( _ftlibrary); } @@ -189,37 +180,6 @@ osgText::Font* FreeTypeLibrary::getFont(std::istream& fontstream, unsigned int i return font; } -osgText::Font3D* FreeTypeLibrary::getFont3D(const std::string& fontfile, unsigned int index, unsigned int flags) -{ - FT_Face face; - if (getFace(fontfile, index, face) == false) return (0); - - OpenThreads::ScopedLock lock(getMutex()); - - FreeTypeFont3D* font3DImp = new FreeTypeFont3D(fontfile,face,flags); - osgText::Font3D* font3D = new osgText::Font3D(font3DImp); - - _font3DImplementationSet.insert(font3DImp); - - return font3D; -} -osgText::Font3D* FreeTypeLibrary::getFont3D(std::istream& fontstream, unsigned int index, unsigned int flags) -{ - - FT_Face face = 0; - FT_Byte * buffer = getFace(fontstream, index, face); - if (face == 0) return (0); - - OpenThreads::ScopedLock lock(getMutex()); - - FreeTypeFont3D* font3DImp = new FreeTypeFont3D(buffer,face,flags); - osgText::Font3D* font3D = new osgText::Font3D(font3DImp); - - _font3DImplementationSet.insert(font3DImp); - - return font3D; -} - void FreeTypeLibrary::verifyCharacterMap(FT_Face face) { // diff --git a/src/osgPlugins/freetype/FreeTypeLibrary.h b/src/osgPlugins/freetype/FreeTypeLibrary.h index 4e508a808..58ac6fc08 100644 --- a/src/osgPlugins/freetype/FreeTypeLibrary.h +++ b/src/osgPlugins/freetype/FreeTypeLibrary.h @@ -15,7 +15,6 @@ #define FREETYPE_LIBRARY #include "FreeTypeFont.h" -#include "FreeTypeFont3D.h" #include #include @@ -40,11 +39,7 @@ public: osgText::Font* getFont(const std::string& fontfile,unsigned int index=0, unsigned int flags=0); osgText::Font* getFont(std::istream& fontstream, unsigned int index=0, unsigned int flags=0); - osgText::Font3D* getFont3D(const std::string& fontfile, unsigned int index=0, unsigned int flags=0); - osgText::Font3D* getFont3D(std::istream& fontstream, unsigned int index=0, unsigned int flags=0); - void removeFontImplmentation(FreeTypeFont* fontImpl) { _fontImplementationSet.erase(fontImpl); } - void removeFont3DImplmentation(FreeTypeFont3D* font3DImpl) { _font3DImplementationSet.erase(font3DImpl); } protected: @@ -61,12 +56,10 @@ protected: FreeTypeLibrary(); typedef std::set< FreeTypeFont* > FontImplementationSet; - typedef std::set< FreeTypeFont3D* > Font3DImplementationSet; mutable OpenThreads::Mutex _mutex; FT_Library _ftlibrary; FontImplementationSet _fontImplementationSet; - Font3DImplementationSet _font3DImplementationSet; }; diff --git a/src/osgPlugins/freetype/ReaderWriterFreeType.cpp b/src/osgPlugins/freetype/ReaderWriterFreeType.cpp index d383b7452..c31de8d45 100644 --- a/src/osgPlugins/freetype/ReaderWriterFreeType.cpp +++ b/src/osgPlugins/freetype/ReaderWriterFreeType.cpp @@ -39,24 +39,10 @@ class ReaderWriterFreeType : public osgDB::ReaderWriter virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const { - std::string tmpFile = file; - bool needFont3D = false; - - std::string ext = osgDB::getLowerCaseFileExtension(tmpFile); - if (ext == "text3d") - { - needFont3D = true; - tmpFile.erase(tmpFile.size()-7, 7); - ext = osgDB::getLowerCaseFileExtension(tmpFile); - } - else if ((options != NULL) && (options->getPluginData("3D"))) - { - needFont3D = true; - } - + std::string ext = osgDB::getLowerCaseFileExtension(file); if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; - std::string fileName = osgDB::findDataFile( tmpFile, options ); + std::string fileName = osgDB::findDataFile( file, options ); if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; FreeTypeLibrary* freeTypeLibrary = FreeTypeLibrary::instance(); @@ -66,10 +52,7 @@ class ReaderWriterFreeType : public osgDB::ReaderWriter return ReadResult::ERROR_IN_READING_FILE; } - if (needFont3D) - return freeTypeLibrary->getFont3D(fileName,0,getFlags(options)); - else - return freeTypeLibrary->getFont(fileName,0,getFlags(options)); + return freeTypeLibrary->getFont(fileName,0,getFlags(options)); } virtual ReadResult readObject(std::istream& stream, const osgDB::ReaderWriter::Options* options) const diff --git a/src/osgPlugins/txf/TXFFont.cpp b/src/osgPlugins/txf/TXFFont.cpp index 7f63ce773..ed95dc5d6 100644 --- a/src/osgPlugins/txf/TXFFont.cpp +++ b/src/osgPlugins/txf/TXFFont.cpp @@ -118,7 +118,7 @@ TXFFont::hasVertical() const } osg::Vec2 -TXFFont::getKerning(const osgText::FontResolution&, unsigned int, unsigned int, osgText::KerningType) +TXFFont::getKerning(unsigned int, unsigned int, osgText::KerningType) { return osg::Vec2(0, 0); } diff --git a/src/osgPlugins/txf/TXFFont.h b/src/osgPlugins/txf/TXFFont.h index 8c7d834f2..2286f341b 100644 --- a/src/osgPlugins/txf/TXFFont.h +++ b/src/osgPlugins/txf/TXFFont.h @@ -34,7 +34,7 @@ public: virtual bool hasVertical() const; - virtual osg::Vec2 getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType); + virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType); virtual float getScale() const { return 1.0; } diff --git a/src/osgQt/QFontImplementation.cpp b/src/osgQt/QFontImplementation.cpp index efebf5c23..65cb632d5 100644 --- a/src/osgQt/QFontImplementation.cpp +++ b/src/osgQt/QFontImplementation.cpp @@ -128,8 +128,7 @@ QFontImplementation::getGlyph(const osgText::FontResolution& fontRes, unsigned i } osg::Vec2 -QFontImplementation::getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, - unsigned int rightcharcode, osgText::KerningType kerningType) +QFontImplementation::getKerning(unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType kerningType) { return osg::Vec2(0, 0); } diff --git a/src/osgText/CMakeLists.txt b/src/osgText/CMakeLists.txt index db1f041f9..f33ec6455 100644 --- a/src/osgText/CMakeLists.txt +++ b/src/osgText/CMakeLists.txt @@ -27,7 +27,6 @@ ADD_LIBRARY(${LIB_NAME} DefaultFont.cpp DefaultFont.h Font.cpp - Font3D.cpp String.cpp FadeText.cpp TextBase.cpp diff --git a/src/osgText/DefaultFont.cpp b/src/osgText/DefaultFont.cpp index c399a47dd..7783ef39d 100644 --- a/src/osgText/DefaultFont.cpp +++ b/src/osgText/DefaultFont.cpp @@ -74,7 +74,7 @@ osgText::Glyph* DefaultFont::getGlyph(const FontResolution& fontRes, unsigned in } -osg::Vec2 DefaultFont::getKerning(const FontResolution&, unsigned int,unsigned int, KerningType) +osg::Vec2 DefaultFont::getKerning(unsigned int,unsigned int, KerningType) { // no kerning on default font. return osg::Vec2(0.0f,0.0f); diff --git a/src/osgText/DefaultFont.h b/src/osgText/DefaultFont.h index 4745f307a..9eec8d2f2 100644 --- a/src/osgText/DefaultFont.h +++ b/src/osgText/DefaultFont.h @@ -37,7 +37,7 @@ public: virtual osgText::Glyph3D* getGlyph3D(unsigned int charcode) { return 0; } - virtual osg::Vec2 getKerning(const FontResolution&, unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType); + virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType); virtual bool hasVertical() const; diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index ca9d27da7..83a13cee1 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -422,9 +422,9 @@ void Font::releaseGLObjects(osg::State* state) const // const_cast(this)->_sizeGlyphMap.clear(); } -osg::Vec2 Font::getKerning(const FontResolution& fontRes, unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType) +osg::Vec2 Font::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType) { - if (_implementation.valid()) return _implementation->getKerning(fontRes, leftcharcode,rightcharcode,kerningType); + if (_implementation.valid()) return _implementation->getKerning(leftcharcode,rightcharcode,kerningType); else return osg::Vec2(0.0f,0.0f); } @@ -943,3 +943,9 @@ void Glyph::subload() const "\t 0x"<<(unsigned long)data()<<");"<setThreadSafeRefUnref(threadSafe); + if (_normalArray.valid()) _normalArray->setThreadSafeRefUnref(threadSafe); +} diff --git a/src/osgText/Font3D.cpp b/src/osgText/Font3D.cpp index 7d9a5999d..30915df49 100644 --- a/src/osgText/Font3D.cpp +++ b/src/osgText/Font3D.cpp @@ -312,9 +312,4 @@ bool Font3D::hasVertical() const else return false; } -void Glyph3D::setThreadSafeRefUnref(bool threadSafe) -{ - if (_vertexArray.valid()) _vertexArray->setThreadSafeRefUnref(threadSafe); - if (_normalArray.valid()) _normalArray->setThreadSafeRefUnref(threadSafe); -} } diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index d34aa4063..a2a41cf69 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -149,14 +149,14 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite { case LEFT_TO_RIGHT: { - osg::Vec2 delta(activefont->getKerning(_fontSize, previous_charcode,charcode,_kerningType)); + osg::Vec2 delta(activefont->getKerning(previous_charcode,charcode,_kerningType)); cursor.x() += delta.x() * wr; cursor.y() += delta.y() * hr; break; } case RIGHT_TO_LEFT: { - osg::Vec2 delta(activefont->getKerning(_fontSize, charcode,previous_charcode,_kerningType)); + osg::Vec2 delta(activefont->getKerning(charcode,previous_charcode,_kerningType)); cursor.x() -= delta.x() * wr; cursor.y() -= delta.y() * hr; break; @@ -418,14 +418,14 @@ void Text::computeGlyphRepresentation() { case LEFT_TO_RIGHT: { - osg::Vec2 delta(activefont->getKerning(_fontSize, previous_charcode,charcode,_kerningType)); + osg::Vec2 delta(activefont->getKerning(previous_charcode,charcode,_kerningType)); cursor.x() += delta.x() * wr; cursor.y() += delta.y() * hr; break; } case RIGHT_TO_LEFT: { - osg::Vec2 delta(activefont->getKerning(_fontSize, charcode,previous_charcode,_kerningType)); + osg::Vec2 delta(activefont->getKerning(charcode,previous_charcode,_kerningType)); cursor.x() -= delta.x() * wr; cursor.y() -= delta.y() * hr; break; diff --git a/src/osgText/Text3D.cpp b/src/osgText/Text3D.cpp index bfd66c429..4a0143417 100644 --- a/src/osgText/Text3D.cpp +++ b/src/osgText/Text3D.cpp @@ -135,7 +135,7 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i return lastChar; } - Glyph3D* glyph = _font->getGlyph(charcode); + Glyph3D* glyph = _font->getGlyph3D(charcode); if (glyph) { const osg::BoundingBox & bb = glyph->getBoundingBox(); @@ -245,7 +245,7 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i // Subtract off glyphs from the cursor position (to correctly center text) if(*prevChar != '-') { - Glyph3D* glyph = _font->getGlyph(*prevChar); + Glyph3D* glyph = _font->getGlyph3D(*prevChar); if (glyph) { switch(_layout) @@ -316,7 +316,7 @@ void Text3D::computeGlyphRepresentation() { unsigned int charcode = *itr; - Glyph3D* glyph = _font->getGlyph(charcode); + Glyph3D* glyph = _font->getGlyph3D(charcode); if (glyph) { const osg::BoundingBox & bb = glyph->getBoundingBox();