Updates to osgText.

This commit is contained in:
Robert Osfield 2001-10-24 13:46:58 +00:00
parent a30a4132b8
commit 573f68c35b
5 changed files with 49 additions and 17 deletions

View File

@ -104,7 +104,11 @@ SOURCE=..\..\include\osgText\Export
# End Source File
# Begin Source File
SOURCE=..\..\include\osgText\Text.h
SOURCE=..\..\include\osgText\Text
# End Source File
# Begin Source File
SOURCE=..\..\include\osgText\Version
# End Source File
# End Group
# Begin Group "Ressourcendateien"

View File

@ -24,6 +24,9 @@ OSGDB_EXPORT extern void setFilePath( const char *_path );
/** set the data file path.*/
OSGDB_EXPORT extern const char* getFilePath();
/** find specified file if specified file path.*/
OSGDB_EXPORT extern char *osgDB::findFileInPath( const char *_file, const char * filePath );
/** find specified file on the set data file path.*/
OSGDB_EXPORT extern char *findFile( const char *file );

View File

@ -49,8 +49,8 @@ std::string ttfPath1("./fonts/verdana.ttf");
#else
std::string ttfPath("/usr/share/fonts/ttf/western/fudd.ttf");
std::string ttfPath1("/usr/share/fonts/ttf/western/fudd.ttf");
std::string ttfPath("dirtydoz.ttf");
std::string ttfPath1("fudd.ttf");
#endif

View File

@ -109,7 +109,7 @@ const char* osgDB::getFilePath()
}
static char *findFileInPath( const char *_file, const char * filePath )
char *osgDB::findFileInPath( const char *_file, const char * filePath )
{
#ifdef macintosh
return (char *)_file;

View File

@ -27,6 +27,33 @@
using namespace osgText;
// define the default paths to look for fonts.
// note delimator is : for unix, ; for windows.
#if defined(__linux) || defined(__FreeBSD__) || defined (__sgi)
static char* s_FontFilePath = "/usr/share/fonts/ttf:/usr/share/fonts/ttf/western:/usr/share/fonts/ttf/decoratives";
#elif defined(WIN32)
static char* s_FontFilePath = ".;";
#else
static char* s_FontFilePath = ".:";
#endif
std::string findFontFile(const std::string& str)
{
// try looking in OSGFILEPATH etc first for fonts.
char* filename = osgDB::findFile(str.c_str());
if (filename) return std::string(filename);
// else fallback into the standard font file paths.
if (s_FontFilePath)
{
filename = osgDB::findFileInPath(str.c_str(),s_FontFilePath);
if (filename) return std::string(filename);
}
return std::string();
}
///////////////////////////////////////////////////////////////////////////////
// Font
@ -66,20 +93,18 @@ open(const std::string& font)
{
clear();
char* filename = osgDB::findFile(font.c_str());
if (filename)
{
std::string filename = findFontFile(font);
if (filename.empty()) return false;
_font=createFontObj();
if( _font!=NULL && _font->Open(filename) )
{
_init=true;
_fontName=font;
return true;
}
else
return false;
}
_font=createFontObj();
if( _font!=NULL && _font->Open(filename.c_str()) )
{
_init=true;
_fontName=font;
return true;
}
else
return false;
}
bool Font::