Updates to osgText and osgDB so that the loading of text fonts can use
osgDB::findFile() to locate font files from the OSGFILEPATH environmental variable.
This commit is contained in:
@@ -63,6 +63,7 @@ static const char *s_default_dso_path = "/usr/lib/osgPlugins/";
|
||||
static char *s_filePath = ".:";
|
||||
#endif
|
||||
|
||||
static bool s_filePathInitialized = false;
|
||||
|
||||
void osgDB::initFilePath( void )
|
||||
{
|
||||
@@ -76,6 +77,7 @@ void osgDB::initFilePath( void )
|
||||
{
|
||||
notify(DEBUG_INFO) << "osgDB::Init(NULL)"<<endl;
|
||||
}
|
||||
s_filePathInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +98,8 @@ void osgDB::setFilePath( const char *_path )
|
||||
strcat( buff, _path );
|
||||
|
||||
s_filePath = strdup( buff );
|
||||
|
||||
s_filePathInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +156,8 @@ char *osgDB::findFile( const char *file )
|
||||
{
|
||||
if (!file) return NULL;
|
||||
|
||||
if (!s_filePathInitialized) initFilePath();
|
||||
|
||||
char* newFileName = findFileInPath( file, s_filePath );
|
||||
if (newFileName) return newFileName;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ C++FILES = \
|
||||
TARGET_BASENAME = osgText
|
||||
|
||||
|
||||
LIBS = -L../../lib -lfreetype -losgDB -losgUtil -losg -lGLU -lGL -lm
|
||||
LIBS = -L../../lib -lfreetype -losgDB -losg -lGLU -lGL -lm
|
||||
|
||||
LIB = ../../lib/lib$(TARGET_BASENAME).so
|
||||
#LIB = ../../lib/lib$(TARGET_BASENAME).a
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include <osgText/Text>
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
#include "FTFace.h"
|
||||
#include "FTGLBitmapFont.h"
|
||||
#include "FTGLPixmapFont.h"
|
||||
@@ -63,16 +65,21 @@ bool Font::
|
||||
open(const std::string& font)
|
||||
{
|
||||
clear();
|
||||
|
||||
char* filename = osgDB::findFile(font.c_str());
|
||||
if (filename)
|
||||
{
|
||||
|
||||
_font=createFontObj();
|
||||
if( _font!=NULL && _font->Open(font.c_str()) )
|
||||
{
|
||||
_init=true;
|
||||
_fontName=font;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
_font=createFontObj();
|
||||
if( _font!=NULL && _font->Open(filename) )
|
||||
{
|
||||
_init=true;
|
||||
_fontName=font;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Font::
|
||||
|
||||
Reference in New Issue
Block a user