2001-11-12 18:04:57 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* openscenegraph textLib / FTGL wrapper
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* prog: max rheiner;mrn@paus.ch
|
|
|
|
* date: 4/25/2001 (m/d/y)
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OSGTEXT_FONT
|
|
|
|
#define OSGTEXT_FONT 1
|
|
|
|
|
|
|
|
#include <osg/Object>
|
|
|
|
|
|
|
|
#include <osgText/Export>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
// http://homepages.paradise.net.nz/henryj/code/
|
|
|
|
|
|
|
|
class FTFont;
|
|
|
|
|
|
|
|
namespace osgText {
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Font - FontBaseClass
|
|
|
|
class OSGTEXT_EXPORT Font : public osg::Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
Font();
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool open(const std::string& font);
|
|
|
|
|
|
|
|
virtual bool create(int pointSize, const unsigned int res = 72 );
|
|
|
|
virtual bool create();
|
|
|
|
virtual void output(const char* text);
|
|
|
|
|
|
|
|
virtual bool isOk(void) const { return _init; }
|
|
|
|
virtual bool isCreated(void) const { return isOk() && _created; }
|
|
|
|
|
|
|
|
virtual float getWidth(const char* text) const;
|
|
|
|
virtual int getHeight() const;
|
|
|
|
virtual int getDescender() const;
|
|
|
|
virtual int getAscender() const;
|
|
|
|
|
|
|
|
int getPointSize(void) const { return _pointSize; }
|
2002-01-16 18:36:20 +08:00
|
|
|
int getTextureSize(void) const { return _textureSize; }
|
2001-11-12 18:04:57 +08:00
|
|
|
const std::string& getFontName();
|
|
|
|
|
|
|
|
FTFont* getFont(void) { return _font; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~Font();
|
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
|
|
|
|
virtual FTFont* createFontObj(void)=0;
|
|
|
|
|
|
|
|
bool init(const std::string& font);
|
|
|
|
|
|
|
|
bool _init;
|
|
|
|
bool _created;
|
|
|
|
|
|
|
|
FTFont* _font;
|
|
|
|
std::string _fontName;
|
|
|
|
int _pointSize;
|
|
|
|
int _res;
|
2002-01-16 18:36:20 +08:00
|
|
|
int _textureSize;
|
2001-11-12 18:04:57 +08:00
|
|
|
};
|
|
|
|
// Font
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// RasterFont
|
|
|
|
class OSGTEXT_EXPORT RasterFont:public Font
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RasterFont():Font(){;}
|
|
|
|
RasterFont(const std::string& font):Font(){;}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// RasterFont
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// VectorFont
|
|
|
|
class OSGTEXT_EXPORT VectorFont:public Font
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VectorFont():Font(){;}
|
|
|
|
VectorFont(const std::string& font):Font(){;}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
double _precision;
|
|
|
|
};
|
|
|
|
|
|
|
|
// VectorFont
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// BitmapFont
|
|
|
|
class OSGTEXT_EXPORT BitmapFont:public RasterFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
BitmapFont() {;}
|
|
|
|
|
|
|
|
BitmapFont(const std::string& font,
|
|
|
|
int point_size);
|
|
|
|
|
|
|
|
META_Object(BitmapFont);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
virtual FTFont* createFontObj(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
// BitmapFont
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// PixmapFont
|
|
|
|
class OSGTEXT_EXPORT PixmapFont:public RasterFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
PixmapFont() {;}
|
|
|
|
|
|
|
|
PixmapFont(const std::string& font,
|
|
|
|
int point_size);
|
|
|
|
|
|
|
|
META_Object(PixmapFont);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual FTFont* createFontObj(void);
|
|
|
|
|
|
|
|
};
|
|
|
|
// PixmapFont
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextureFont
|
|
|
|
|
|
|
|
class OSGTEXT_EXPORT TextureFont:public RasterFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
TextureFont() {;}
|
|
|
|
|
|
|
|
TextureFont(const std::string& font,
|
|
|
|
int point_size);
|
2002-01-16 18:36:20 +08:00
|
|
|
|
|
|
|
TextureFont(const std::string& font,
|
|
|
|
int point_size,
|
|
|
|
int textureSize );
|
2001-11-12 18:04:57 +08:00
|
|
|
|
|
|
|
META_Object(TextureFont);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual FTFont* createFontObj(void);
|
|
|
|
|
|
|
|
};
|
|
|
|
// PixmapFont
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// OutlineFont
|
|
|
|
class OSGTEXT_EXPORT OutlineFont:public VectorFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
OutlineFont() {;}
|
|
|
|
|
|
|
|
OutlineFont(const std::string& font,
|
|
|
|
int point_size,
|
|
|
|
double precision);
|
|
|
|
|
|
|
|
META_Object(OutlineFont);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual FTFont* createFontObj(void);
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
// OutlineFont
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// PolygonFont
|
|
|
|
class OSGTEXT_EXPORT PolygonFont:public VectorFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
PolygonFont() {;}
|
|
|
|
|
|
|
|
PolygonFont(const std::string& font,
|
|
|
|
int point_size,
|
|
|
|
double precision);
|
|
|
|
|
|
|
|
META_Object(PolygonFont);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual FTFont* createFontObj(void);
|
|
|
|
|
|
|
|
};
|
|
|
|
// PolygonFont
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OSGTEXT_FONT
|