From Tree, support for encoded text added into osgText.
This commit is contained in:
75
include/osgText/EncodedText
Normal file
75
include/osgText/EncodedText
Normal file
@@ -0,0 +1,75 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 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 (http://homepages.paradise.net.nz/henryj/code/)
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* prog: max rheiner;mrn@paus.ch
|
||||
* date: 4/25/2001 (m/d/y)
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OSGTEXT_ENCODEDTEXT
|
||||
#define OSGTEXT_ENCODEDTEXT 1
|
||||
|
||||
#include <osg/Referenced>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <osgText/Export>
|
||||
|
||||
namespace osgText {
|
||||
|
||||
class OSGTEXT_EXPORT EncodedText : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Types of string encodings supported
|
||||
*/
|
||||
enum Encoding
|
||||
{
|
||||
ENCODING_UNDEFINED, /// not using Unicode
|
||||
ENCODING_ASCII = ENCODING_UNDEFINED,/// unsigned char ASCII
|
||||
ENCODING_UTF8, /// 8-bit unicode transformation format
|
||||
ENCODING_UTF16, /// 16-bit signature
|
||||
ENCODING_UTF16_BE, /// 16-bit big-endian
|
||||
ENCODING_UTF16_LE, /// 16-bit little-endian
|
||||
ENCODING_UTF32, /// 32-bit signature
|
||||
ENCODING_UTF32_BE, /// 32-bit big-endian
|
||||
ENCODING_UTF32_LE, /// 32-bit little-endian
|
||||
ENCODING_SIGNATURE, /// detect encoding from signature
|
||||
};
|
||||
|
||||
EncodedText();
|
||||
|
||||
void setOverrideEncoding(Encoding encoding);
|
||||
Encoding getOverrideEncoding() const { return _overrideEncoding; }
|
||||
Encoding getEncoding() const { return _encoding; }
|
||||
|
||||
void setText(const unsigned char* text);
|
||||
std::vector<int>::const_iterator getUnicodeText() const { return _unicodeText.begin(); }
|
||||
|
||||
protected:
|
||||
|
||||
int getNextCharacter(const unsigned char*& charString) const;
|
||||
|
||||
/// This method will extract any ZWNBSP signature at the start of the string
|
||||
Encoding findEncoding(const unsigned char*& charString) const;
|
||||
|
||||
Encoding _encoding;
|
||||
Encoding _overrideEncoding;
|
||||
std::vector<int> _unicodeText;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OSGTEXT_TEXT
|
||||
@@ -45,7 +45,7 @@ namespace osgText {
|
||||
virtual const char* libraryName() const { return #library; } \
|
||||
virtual const char* className() const { return #name; } \
|
||||
|
||||
|
||||
class EncodedText;
|
||||
|
||||
class OSGTEXT_EXPORT Font : public osg::Object
|
||||
{
|
||||
@@ -73,12 +73,12 @@ class OSGTEXT_EXPORT Font : public osg::Object
|
||||
|
||||
virtual bool create(osg::State& state,int pointSize, unsigned int res = 72 );
|
||||
virtual bool create(osg::State& state);
|
||||
virtual void output(osg::State& state,const char* text) const;
|
||||
virtual void output(osg::State& state, const EncodedText* text) const;
|
||||
|
||||
virtual bool isOk(void) const { return _init; }
|
||||
virtual bool isCreated(void) const { return isOk() && _created; }
|
||||
|
||||
virtual float getWidth(const char* text) const;
|
||||
virtual float getWidth(const EncodedText* text) const;
|
||||
virtual int getHeight() const;
|
||||
virtual int getDescender() const;
|
||||
virtual int getAscender() const;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <osg/Vec2>
|
||||
|
||||
#include <osgText/Font>
|
||||
#include <osgText/EncodedText>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -107,8 +108,8 @@ class OSGTEXT_EXPORT Text : public osg::Drawable
|
||||
Font* getFont() { return _font.get(); }
|
||||
const Font* getFont() const { return _font.get(); }
|
||||
|
||||
void setText(const char* text) { _text=text; _initAlignment=false; }
|
||||
void setText(const std::string& text) { _text=text; _initAlignment=false; }
|
||||
void setText(const char* text);
|
||||
void setText(const std::string& text);
|
||||
const std::string& getText() const { return _text; }
|
||||
|
||||
virtual bool supports(PrimitiveFunctor& pf) const;
|
||||
@@ -120,6 +121,8 @@ class OSGTEXT_EXPORT Text : public osg::Drawable
|
||||
|
||||
const osg::Vec3& getAlignmentPos() const { return _alignmentPos; };
|
||||
|
||||
void setEncodedText(EncodedText* encodedText) { _encodedText = encodedText; }
|
||||
const EncodedText* getEncodedText() const { return _encodedText.get(); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -152,6 +155,8 @@ class OSGTEXT_EXPORT Text : public osg::Drawable
|
||||
int _boundingBoxType;
|
||||
AxisAlignment _axisAlignment;
|
||||
|
||||
osg::ref_ptr<EncodedText> _encodedText;
|
||||
|
||||
osg::Vec3 _pos;
|
||||
osg::Vec3 _alignmentPos;
|
||||
osg::Vec4 _color;
|
||||
|
||||
Reference in New Issue
Block a user