Unified more of the 2D and 3D text setup, fixed bugs in Text3D setup
which address the problems of black 3D text and the kerning causing problems with font positioning.
This commit is contained in:
parent
d59ac54b31
commit
74cf034404
@ -49,6 +49,12 @@ public:
|
|||||||
|
|
||||||
unsigned int getGlyphCode() const { return _glyphCode; }
|
unsigned int getGlyphCode() const { return _glyphCode; }
|
||||||
|
|
||||||
|
void setWidth(float width) { _width = width; }
|
||||||
|
float getWidth() const { return _width; }
|
||||||
|
|
||||||
|
void setHeight(float height) { _height = height; }
|
||||||
|
float getHeight() const { return _height; }
|
||||||
|
|
||||||
void setHorizontalBearing(const osg::Vec2& bearing);
|
void setHorizontalBearing(const osg::Vec2& bearing);
|
||||||
const osg::Vec2& getHorizontalBearing() const;
|
const osg::Vec2& getHorizontalBearing() const;
|
||||||
|
|
||||||
@ -84,6 +90,9 @@ protected:
|
|||||||
Font* _font;
|
Font* _font;
|
||||||
unsigned int _glyphCode;
|
unsigned int _glyphCode;
|
||||||
|
|
||||||
|
float _width;
|
||||||
|
float _height;
|
||||||
|
|
||||||
osg::Vec2 _horizontalBearing;
|
osg::Vec2 _horizontalBearing;
|
||||||
float _horizontalAdvance;
|
float _horizontalAdvance;
|
||||||
|
|
||||||
@ -159,6 +168,12 @@ public:
|
|||||||
|
|
||||||
unsigned int getGlyphCode() const { return _glyphCode; }
|
unsigned int getGlyphCode() const { return _glyphCode; }
|
||||||
|
|
||||||
|
void setWidth(float width) { _width = width; }
|
||||||
|
float getWidth() const { return _width; }
|
||||||
|
|
||||||
|
void setHeight(float height) { _height = height; }
|
||||||
|
float getHeight() const { return _height; }
|
||||||
|
|
||||||
void setHorizontalBearing(const osg::Vec2& bearing) { _horizontalBearing=bearing; }
|
void setHorizontalBearing(const osg::Vec2& bearing) { _horizontalBearing=bearing; }
|
||||||
const osg::Vec2 & getHorizontalBearing() const { return _horizontalBearing; }
|
const osg::Vec2 & getHorizontalBearing() const { return _horizontalBearing; }
|
||||||
|
|
||||||
@ -187,18 +202,6 @@ public:
|
|||||||
osg::Geometry::PrimitiveSetList & getRawFacePrimitiveSetList() { return _rawFacePrimitiveSetList; }
|
osg::Geometry::PrimitiveSetList & getRawFacePrimitiveSetList() { return _rawFacePrimitiveSetList; }
|
||||||
const osg::Geometry::PrimitiveSetList & getRawFacePrimitiveSetList() const { return _rawFacePrimitiveSetList; }
|
const osg::Geometry::PrimitiveSetList & getRawFacePrimitiveSetList() const { return _rawFacePrimitiveSetList; }
|
||||||
|
|
||||||
|
|
||||||
float getHorizontalWidth() const { return (-_horizontalBearing.x() + _horizontalAdvance); }
|
|
||||||
float getHorizontalHeight() const { return (-_horizontalBearing.y() + _bb.yMax()); }
|
|
||||||
float getVerticalWidth() const { return (-_verticalBearing.x() + _bb.xMax()); }
|
|
||||||
float getVerticalHeight() const { return (-_verticalBearing.y() + _verticalAdvance); }
|
|
||||||
|
|
||||||
void setWidth(float width) { _width = width; }
|
|
||||||
float getWidth() const { return _width; }
|
|
||||||
|
|
||||||
void setHeight(float height) { _height = height; }
|
|
||||||
float getHeight() const { return _height; }
|
|
||||||
|
|
||||||
GlyphGeometry* getGlyphGeometry(const Style* style);
|
GlyphGeometry* getGlyphGeometry(const Style* style);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -208,6 +211,9 @@ protected:
|
|||||||
Font* _font;
|
Font* _font;
|
||||||
unsigned int _glyphCode;
|
unsigned int _glyphCode;
|
||||||
|
|
||||||
|
float _width;
|
||||||
|
float _height;
|
||||||
|
|
||||||
osg::Vec2 _horizontalBearing;
|
osg::Vec2 _horizontalBearing;
|
||||||
float _horizontalAdvance;
|
float _horizontalAdvance;
|
||||||
|
|
||||||
@ -217,8 +223,6 @@ protected:
|
|||||||
osg::BoundingBox _bb;
|
osg::BoundingBox _bb;
|
||||||
// osg::Vec2 _advance;
|
// osg::Vec2 _advance;
|
||||||
|
|
||||||
float _width;
|
|
||||||
float _height;
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Vec3Array> _rawVertexArray;
|
osg::ref_ptr<osg::Vec3Array> _rawVertexArray;
|
||||||
osg::Geometry::PrimitiveSetList _rawFacePrimitiveSetList;
|
osg::Geometry::PrimitiveSetList _rawFacePrimitiveSetList;
|
||||||
|
@ -37,6 +37,15 @@ public:
|
|||||||
virtual const char* className() const { return "Text"; }
|
virtual const char* className() const { return "Text"; }
|
||||||
virtual const char* libraryName() const { return "osgText"; }
|
virtual const char* libraryName() const { return "osgText"; }
|
||||||
|
|
||||||
|
virtual void setFont(Font* font=0) { setFont(osg::ref_ptr<Font>(font)); };
|
||||||
|
|
||||||
|
/** Set the Font to use to render the text.*/
|
||||||
|
virtual void setFont(osg::ref_ptr<Font> font);
|
||||||
|
|
||||||
|
/** Set the font, loaded from the specified front file, to use to render the text,
|
||||||
|
* setFont("") sets the use of the default font.
|
||||||
|
* See the osgText::readFontFile function for how the font file will be located. */
|
||||||
|
virtual void setFont(const std::string& fontfile) { TextBase::setFont(fontfile); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns off writing to the depth buffer when rendering text. This only affects text
|
* Turns off writing to the depth buffer when rendering text. This only affects text
|
||||||
|
@ -41,15 +41,15 @@ public:
|
|||||||
|
|
||||||
/** Set the Font to use to render the text.
|
/** Set the Font to use to render the text.
|
||||||
* setFont(0) sets the use of the default font.*/
|
* setFont(0) sets the use of the default font.*/
|
||||||
inline void setFont(Font* font=0) { setFont(osg::ref_ptr<Font>(font)); };
|
virtual void setFont(Font* font=0) { setFont(osg::ref_ptr<Font>(font)); };
|
||||||
|
|
||||||
/** Set the Font to use to render the text.*/
|
/** Set the Font to use to render the text.*/
|
||||||
void setFont(osg::ref_ptr<Font> font);
|
virtual void setFont(osg::ref_ptr<Font> font);
|
||||||
|
|
||||||
/** Set the font, loaded from the specified front file, to use to render the text,
|
/** Set the font, loaded from the specified front file, to use to render the text,
|
||||||
* setFont("") sets the use of the default font.
|
* setFont("") sets the use of the default font.
|
||||||
* See the osgText::readFontFile function for how the font file will be located. */
|
* See the osgText::readFontFile function for how the font file will be located. */
|
||||||
void setFont(const std::string& fontfile);
|
virtual void setFont(const std::string& fontfile);
|
||||||
|
|
||||||
/** Get the font. Return 0 if default is being used.*/
|
/** Get the font. Return 0 if default is being used.*/
|
||||||
const Font* getFont() const { return _font.get(); }
|
const Font* getFont() const { return _font.get(); }
|
||||||
|
@ -205,8 +205,7 @@ FreeTypeFont::FreeTypeFont(const std::string& filename, FT_Face face, unsigned i
|
|||||||
_filename(filename),
|
_filename(filename),
|
||||||
_buffer(0),
|
_buffer(0),
|
||||||
_face(face),
|
_face(face),
|
||||||
_flags(flags),
|
_flags(flags)
|
||||||
_freetype_scale(1.0f)
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -216,8 +215,7 @@ FreeTypeFont::FreeTypeFont(FT_Byte* buffer, FT_Face face, unsigned int flags):
|
|||||||
_filename(""),
|
_filename(""),
|
||||||
_buffer(buffer),
|
_buffer(buffer),
|
||||||
_face(face),
|
_face(face),
|
||||||
_flags(flags),
|
_flags(flags)
|
||||||
_freetype_scale(1.0f)
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -250,60 +248,14 @@ FreeTypeFont::~FreeTypeFont()
|
|||||||
void FreeTypeFont::init()
|
void FreeTypeFont::init()
|
||||||
{
|
{
|
||||||
FT_Error _error;
|
FT_Error _error;
|
||||||
#if 0
|
|
||||||
_error = FT_Set_Pixel_Sizes(_face, 32, 32);
|
_error = FT_Set_Pixel_Sizes(_face, 32, 32);
|
||||||
if (_error)
|
if (_error)
|
||||||
{
|
{
|
||||||
OSG_NOTICE << "FreeTypeFont3D: set pixel sizes failed ..." << std::endl;
|
OSG_NOTICE << "FreeTypeFont3D: set pixel sizes failed ..." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
_currentRes.first = 32;
|
||||||
FT_Set_Char_Size( _face, 64*64, 64*64, 600, 600);
|
_currentRes.second = 32;
|
||||||
|
|
||||||
int glyphIndex = FT_Get_Char_Index( _face, 'M' );
|
|
||||||
_error = FT_Load_Glyph( _face, glyphIndex, FT_LOAD_DEFAULT );
|
|
||||||
if (_error)
|
|
||||||
{
|
|
||||||
OSG_NOTICE << "FreeTypeFont3D: initial glyph load failed ..." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|
|
||||||
{
|
|
||||||
OSG_NOTICE << "FreeTypeFont3D: not a vector font" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
FreeType::Char3DInfo char3d(10);
|
|
||||||
|
|
||||||
FT_Outline outline = _face->glyph->outline;
|
|
||||||
FT_Outline_Funcs funcs;
|
|
||||||
funcs.conic_to = (FT_Outline_ConicToFunc)&FreeType::conicTo;
|
|
||||||
funcs.line_to = (FT_Outline_LineToFunc)&FreeType::lineTo;
|
|
||||||
funcs.cubic_to = (FT_Outline_CubicToFunc)&FreeType::cubicTo;
|
|
||||||
funcs.move_to = (FT_Outline_MoveToFunc)&FreeType::moveTo;
|
|
||||||
funcs.shift = 0;
|
|
||||||
funcs.delta = 0;
|
|
||||||
_error = FT_Outline_Decompose(&outline,&funcs,&char3d);
|
|
||||||
if (_error)
|
|
||||||
{
|
|
||||||
OSG_NOTICE << "FreeTypeFont3D: - outline decompose failed ..." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_BBox bb;
|
|
||||||
FT_Outline_Get_BBox(&outline,&bb);
|
|
||||||
|
|
||||||
long ymin = ft_floor( bb.yMin );
|
|
||||||
long ymax = ft_ceiling( bb.yMax );
|
|
||||||
double height = double(ymax - ymin)/64.0;
|
|
||||||
|
|
||||||
// long xmin = ft_floor( bb.xMin );
|
|
||||||
// long xmax = ft_ceiling( bb.xMax );
|
|
||||||
// double width = (xmax - xmin)/64.0;
|
|
||||||
_freetype_scale = 1.0f/height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeTypeFont::setFontResolution(const osgText::FontResolution& fontSize)
|
void FreeTypeFont::setFontResolution(const osgText::FontResolution& fontSize)
|
||||||
@ -347,6 +299,8 @@ osgText::Glyph* FreeTypeFont::getGlyph(const osgText::FontResolution& fontRes, u
|
|||||||
|
|
||||||
setFontResolution(fontRes);
|
setFontResolution(fontRes);
|
||||||
|
|
||||||
|
float coord_scale = 1.0f/(float(_currentRes.second)*64.0f);
|
||||||
|
|
||||||
//
|
//
|
||||||
// GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being
|
// GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being
|
||||||
// returned, for symbol fonts in windows (FT_ENCONDING_MS_SYMBOL in freetype) the correct
|
// returned, for symbol fonts in windows (FT_ENCONDING_MS_SYMBOL in freetype) the correct
|
||||||
@ -432,17 +386,23 @@ osgText::Glyph* FreeTypeFont::getGlyph(const osgText::FontResolution& fontRes, u
|
|||||||
|
|
||||||
FT_Glyph_Metrics* metrics = &(_face->glyph->metrics);
|
FT_Glyph_Metrics* metrics = &(_face->glyph->metrics);
|
||||||
|
|
||||||
#if 0
|
glyph->setWidth((float)metrics->width * coord_scale);
|
||||||
float coord_scale = _freetype_scale/64.0f;
|
glyph->setHeight((float)metrics->height * coord_scale);
|
||||||
#else
|
|
||||||
float coord_scale = 1.0f/64.0f;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glyph->setHorizontalBearing(osg::Vec2((float)metrics->horiBearingX * coord_scale,(float)(metrics->horiBearingY-metrics->height) * coord_scale)); // bottom left.
|
glyph->setHorizontalBearing(osg::Vec2((float)metrics->horiBearingX * coord_scale,(float)(metrics->horiBearingY-metrics->height) * coord_scale)); // bottom left.
|
||||||
glyph->setHorizontalAdvance((float)metrics->horiAdvance * coord_scale);
|
glyph->setHorizontalAdvance((float)metrics->horiAdvance * coord_scale);
|
||||||
glyph->setVerticalBearing(osg::Vec2((float)metrics->vertBearingX * coord_scale,(float)(metrics->vertBearingY-metrics->height) * coord_scale)); // top middle.
|
glyph->setVerticalBearing(osg::Vec2((float)metrics->vertBearingX * coord_scale,(float)(metrics->vertBearingY-metrics->height) * coord_scale)); // top middle.
|
||||||
glyph->setVerticalAdvance((float)metrics->vertAdvance * coord_scale);
|
glyph->setVerticalAdvance((float)metrics->vertAdvance * coord_scale);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
OSG_NOTICE<<"getGlyph("<<charcode<<", "<<char(charcode)<<")"<<std::endl;
|
||||||
|
OSG_NOTICE<<" height="<<glyph->getHeight()<<std::endl;
|
||||||
|
OSG_NOTICE<<" width="<<glyph->getWidth()<<std::endl;
|
||||||
|
OSG_NOTICE<<" horizontalBearing="<<glyph->getHorizontalBearing()<<std::endl;
|
||||||
|
OSG_NOTICE<<" horizontalAdvance="<<glyph->getHorizontalAdvance()<<std::endl;
|
||||||
|
OSG_NOTICE<<" verticalBearing="<<glyph->getHorizontalBearing()<<std::endl;
|
||||||
|
OSG_NOTICE<<" verticalAdvance="<<glyph->getVerticalAdvance()<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// cout << " in getGlyph() implementation="<<this<<" "<<_filename<<" facade="<<_facade<<endl;
|
// cout << " in getGlyph() implementation="<<this<<" "<<_filename<<" facade="<<_facade<<endl;
|
||||||
|
|
||||||
return glyph.release();
|
return glyph.release();
|
||||||
@ -453,9 +413,6 @@ osgText::Glyph3D * FreeTypeFont::getGlyph3D(unsigned int charcode)
|
|||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
||||||
|
|
||||||
FT_Set_Char_Size( _face, 64*64, 64*64, 600, 600);
|
|
||||||
_currentRes = osgText::FontResolution(0,0);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being
|
// GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being
|
||||||
// returned, for symbol fonts in windows (FT_ENCONDING_MS_SYMBOL in freetype) the correct
|
// returned, for symbol fonts in windows (FT_ENCONDING_MS_SYMBOL in freetype) the correct
|
||||||
@ -483,7 +440,9 @@ osgText::Glyph3D * FreeTypeFont::getGlyph3D(unsigned int charcode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float coord_scale = _freetype_scale/64.0f;
|
//float coord_scale = _freetype_scale/64.0f;
|
||||||
|
//float coord_scale = (1.0f/float(fontDPI))/64.0f;
|
||||||
|
float coord_scale = 1.0f/(float(_currentRes.second)*64.0f);
|
||||||
|
|
||||||
// ** init FreeType to describe the glyph
|
// ** init FreeType to describe the glyph
|
||||||
FreeType::Char3DInfo char3d(_facade->getNumberCurveSamples());
|
FreeType::Char3DInfo char3d(_facade->getNumberCurveSamples());
|
||||||
@ -519,36 +478,39 @@ osgText::Glyph3D * FreeTypeFont::getGlyph3D(unsigned int charcode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ** save vertices and PrimitiveSetList of each face in the Glyph3D PrimitiveSet face list
|
// ** save vertices and PrimitiveSetList of each face in the Glyph3D PrimitiveSet face list
|
||||||
osg::ref_ptr<osgText::Glyph3D> glyph3D = new osgText::Glyph3D(_facade, charcode);
|
osg::ref_ptr<osgText::Glyph3D> glyph = new osgText::Glyph3D(_facade, charcode);
|
||||||
|
|
||||||
// copy the raw primitive set list before we tessellate it.
|
// copy the raw primitive set list before we tessellate it.
|
||||||
glyph3D->getRawFacePrimitiveSetList() = rawPrimitives;
|
glyph->getRawFacePrimitiveSetList() = rawPrimitives;
|
||||||
glyph3D->setRawVertexArray(rawVertices.get());
|
glyph->setRawVertexArray(rawVertices.get());
|
||||||
|
|
||||||
|
|
||||||
FT_Glyph_Metrics* metrics = &(_face->glyph->metrics);
|
FT_Glyph_Metrics* metrics = &(_face->glyph->metrics);
|
||||||
|
|
||||||
glyph3D->setHorizontalBearing(osg::Vec2((float)metrics->horiBearingX * coord_scale,(float)(metrics->horiBearingY-metrics->height) * coord_scale)); // bottom left.
|
glyph->setWidth((float)metrics->width * coord_scale);
|
||||||
glyph3D->setHorizontalAdvance((float)metrics->horiAdvance * coord_scale);
|
glyph->setHeight((float)metrics->height * coord_scale);
|
||||||
glyph3D->setVerticalBearing(osg::Vec2((float)metrics->vertBearingX * coord_scale,(float)(metrics->vertBearingY-metrics->height) * coord_scale)); // top middle.
|
glyph->setHorizontalBearing(osg::Vec2((float)metrics->horiBearingX * coord_scale,(float)(metrics->horiBearingY-metrics->height) * coord_scale)); // bottom left.
|
||||||
glyph3D->setVerticalAdvance((float)metrics->vertAdvance * coord_scale);
|
glyph->setHorizontalAdvance((float)metrics->horiAdvance * coord_scale);
|
||||||
|
glyph->setVerticalBearing(osg::Vec2((float)metrics->vertBearingX * coord_scale,(float)(metrics->vertBearingY-metrics->height) * coord_scale)); // top middle.
|
||||||
|
glyph->setVerticalAdvance((float)metrics->vertAdvance * coord_scale);
|
||||||
|
|
||||||
glyph3D->setWidth((float)metrics->width * coord_scale);
|
#if 0
|
||||||
glyph3D->setHeight((float)metrics->height * coord_scale);
|
OSG_NOTICE<<"getGlyph3D("<<charcode<<", "<<char(charcode)<<")"<<std::endl;
|
||||||
|
OSG_NOTICE<<" height="<<glyph->getHeight()<<std::endl;
|
||||||
|
OSG_NOTICE<<" width="<<glyph->getWidth()<<std::endl;
|
||||||
|
OSG_NOTICE<<" horizontalBearing="<<glyph->getHorizontalBearing()<<std::endl;
|
||||||
|
OSG_NOTICE<<" horizontalAdvance="<<glyph->getHorizontalAdvance()<<std::endl;
|
||||||
|
OSG_NOTICE<<" verticalBearing="<<glyph->getHorizontalBearing()<<std::endl;
|
||||||
|
OSG_NOTICE<<" verticalAdvance="<<glyph->getVerticalAdvance()<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
FT_BBox ftbb;
|
FT_BBox ftbb;
|
||||||
FT_Outline_Get_BBox(&outline, &ftbb);
|
FT_Outline_Get_BBox(&outline, &ftbb);
|
||||||
|
osg::BoundingBox bb(float(ftbb.xMin) * coord_scale, float(ftbb.yMin) * coord_scale, 0.0f, float(ftbb.xMax) * coord_scale, float(ftbb.yMax) * coord_scale, 0.0f);
|
||||||
|
|
||||||
long xmin = ft_floor( ftbb.xMin );
|
glyph->setBoundingBox(bb);
|
||||||
long xmax = ft_ceiling( ftbb.xMax );
|
|
||||||
long ymin = ft_floor( ftbb.yMin );
|
|
||||||
long ymax = ft_ceiling( ftbb.yMax );
|
|
||||||
|
|
||||||
osg::BoundingBox bb(xmin * coord_scale, ymin * coord_scale, 0.0f, xmax * coord_scale, ymax * coord_scale, 0.0f);
|
return glyph.release();
|
||||||
|
|
||||||
glyph3D->setBoundingBox(bb);
|
|
||||||
|
|
||||||
return glyph3D.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec2 FreeTypeFont::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType)
|
osg::Vec2 FreeTypeFont::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType)
|
||||||
@ -578,7 +540,11 @@ osg::Vec2 FreeTypeFont::getKerning(unsigned int leftcharcode,unsigned int rightc
|
|||||||
return osg::Vec2(0.0f,0.0f);
|
return osg::Vec2(0.0f,0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return osg::Vec2((float)kerning.x/64.0f,(float)kerning.y/64.0f);
|
//float coord_scale = _freetype_scale/64.0f;
|
||||||
|
//float coord_scale = 1.0f/64.0f;
|
||||||
|
float coord_scale = 1.0f/(float(_currentRes.second)*64.0f);
|
||||||
|
|
||||||
|
return osg::Vec2((float)kerning.x*coord_scale,(float)kerning.y*coord_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FreeTypeFont::hasVertical() const
|
bool FreeTypeFont::hasVertical() const
|
||||||
|
@ -55,7 +55,6 @@ protected:
|
|||||||
FT_Byte* _buffer;
|
FT_Byte* _buffer;
|
||||||
FT_Face _face;
|
FT_Face _face;
|
||||||
unsigned int _flags;
|
unsigned int _flags;
|
||||||
float _freetype_scale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -387,6 +387,8 @@ void GlyphTexture::resizeGLObjectBuffers(unsigned int maxSize)
|
|||||||
Glyph::Glyph(Font* font, unsigned int glyphCode):
|
Glyph::Glyph(Font* font, unsigned int glyphCode):
|
||||||
_font(font),
|
_font(font),
|
||||||
_glyphCode(glyphCode),
|
_glyphCode(glyphCode),
|
||||||
|
_width(1.0f),
|
||||||
|
_height(1.0f),
|
||||||
_horizontalBearing(0.0f,0.f),
|
_horizontalBearing(0.0f,0.f),
|
||||||
_horizontalAdvance(0.f),
|
_horizontalAdvance(0.f),
|
||||||
_verticalBearing(0.0f,0.f),
|
_verticalBearing(0.0f,0.f),
|
||||||
@ -477,6 +479,8 @@ Glyph3D::Glyph3D(Font* font, unsigned int glyphCode):
|
|||||||
osg::Referenced(true),
|
osg::Referenced(true),
|
||||||
_font(font),
|
_font(font),
|
||||||
_glyphCode(glyphCode),
|
_glyphCode(glyphCode),
|
||||||
|
_width(1.0f),
|
||||||
|
_height(1.0f),
|
||||||
_horizontalBearing(0,0),
|
_horizontalBearing(0,0),
|
||||||
_horizontalAdvance(0),
|
_horizontalAdvance(0),
|
||||||
_verticalBearing(0,0),
|
_verticalBearing(0,0),
|
||||||
|
@ -64,6 +64,21 @@ Text::~Text()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Text::setFont(osg::ref_ptr<Font> font)
|
||||||
|
{
|
||||||
|
if (_font==font) return;
|
||||||
|
|
||||||
|
osg::StateSet* previousFontStateSet = _font.valid() ? _font->getStateSet() : Font::getDefaultFont()->getStateSet();
|
||||||
|
osg::StateSet* newFontStateSet = font.valid() ? font->getStateSet() : Font::getDefaultFont()->getStateSet();
|
||||||
|
|
||||||
|
if (getStateSet() == previousFontStateSet)
|
||||||
|
{
|
||||||
|
setStateSet( newFontStateSet );
|
||||||
|
}
|
||||||
|
|
||||||
|
TextBase::setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Font* Text::getActiveFont()
|
Font* Text::getActiveFont()
|
||||||
{
|
{
|
||||||
@ -80,7 +95,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite
|
|||||||
Font* activefont = getActiveFont();
|
Font* activefont = getActiveFont();
|
||||||
if (!activefont) return last;
|
if (!activefont) return last;
|
||||||
|
|
||||||
float hr = _characterHeight/getFontHeight();
|
float hr = _characterHeight;
|
||||||
float wr = hr/getCharacterAspectRatio();
|
float wr = hr/getCharacterAspectRatio();
|
||||||
|
|
||||||
bool kerning = true;
|
bool kerning = true;
|
||||||
@ -101,12 +116,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite
|
|||||||
if (glyph)
|
if (glyph)
|
||||||
{
|
{
|
||||||
|
|
||||||
float width = (float)(glyph->s()) * wr;
|
float width = (float)(glyph->getWidth()) * wr;
|
||||||
//float height = (float)(glyph->t()) * hr;
|
|
||||||
#ifdef TREES_CODE_FOR_MAKING_SPACES_EDITABLE
|
|
||||||
if (width == 0.0f) width = glyph->getHorizontalAdvance() * wr;
|
|
||||||
//if (height == 0.0f) height = glyph->getVerticalAdvance() * hr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (_layout==RIGHT_TO_LEFT)
|
if (_layout==RIGHT_TO_LEFT)
|
||||||
{
|
{
|
||||||
@ -167,7 +177,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite
|
|||||||
case RIGHT_TO_LEFT: break; // nop.
|
case RIGHT_TO_LEFT: break; // nop.
|
||||||
}
|
}
|
||||||
|
|
||||||
previous_charcode = charcode;
|
previous_charcode = charcode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +253,7 @@ void Text::computeGlyphRepresentation()
|
|||||||
|
|
||||||
unsigned int lineNumber = 0;
|
unsigned int lineNumber = 0;
|
||||||
|
|
||||||
float hr = _characterHeight/getFontHeight();
|
float hr = _characterHeight;
|
||||||
float wr = hr/getCharacterAspectRatio();
|
float wr = hr/getCharacterAspectRatio();
|
||||||
|
|
||||||
for(String::iterator itr=_text.begin();
|
for(String::iterator itr=_text.begin();
|
||||||
@ -369,13 +379,8 @@ void Text::computeGlyphRepresentation()
|
|||||||
Glyph* glyph = activefont->getGlyph(_fontSize, charcode);
|
Glyph* glyph = activefont->getGlyph(_fontSize, charcode);
|
||||||
if (glyph)
|
if (glyph)
|
||||||
{
|
{
|
||||||
float width = (float)(glyph->s()) * wr;
|
float width = (float)(glyph->getWidth()) * wr;
|
||||||
float height = (float)(glyph->t()) * hr;
|
float height = (float)(glyph->getHeight()) * hr;
|
||||||
|
|
||||||
#ifdef TREES_CODE_FOR_MAKING_SPACES_EDITABLE
|
|
||||||
if (width == 0.0f) width = glyph->getHorizontalAdvance() * wr;
|
|
||||||
if (height == 0.0f) height = glyph->getVerticalAdvance() * hr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (_layout==RIGHT_TO_LEFT)
|
if (_layout==RIGHT_TO_LEFT)
|
||||||
{
|
{
|
||||||
@ -421,10 +426,12 @@ void Text::computeGlyphRepresentation()
|
|||||||
osg::Vec2 mintc = glyph->getMinTexCoord();
|
osg::Vec2 mintc = glyph->getMinTexCoord();
|
||||||
osg::Vec2 maxtc = glyph->getMaxTexCoord();
|
osg::Vec2 maxtc = glyph->getMaxTexCoord();
|
||||||
osg::Vec2 vDiff = maxtc - mintc;
|
osg::Vec2 vDiff = maxtc - mintc;
|
||||||
|
|
||||||
float fHorizTCMargin = 1.0f / glyph->getTexture()->getTextureWidth();
|
float fHorizTCMargin = 1.0f / glyph->getTexture()->getTextureWidth();
|
||||||
float fVertTCMargin = 1.0f / glyph->getTexture()->getTextureHeight();
|
float fVertTCMargin = 1.0f / glyph->getTexture()->getTextureHeight();
|
||||||
float fHorizQuadMargin = vDiff.x() == 0.0f ? 0.0f : width * fHorizTCMargin / vDiff.x();
|
float fHorizQuadMargin = vDiff.x() == 0.0f ? 0.0f : width * fHorizTCMargin / vDiff.x();
|
||||||
float fVertQuadMargin = vDiff.y() == 0.0f ? 0.0f : height * fVertTCMargin / vDiff.y();
|
float fVertQuadMargin = vDiff.y() == 0.0f ? 0.0f : height * fVertTCMargin / vDiff.y();
|
||||||
|
|
||||||
mintc.x() -= fHorizTCMargin;
|
mintc.x() -= fHorizTCMargin;
|
||||||
mintc.y() -= fVertTCMargin;
|
mintc.y() -= fVertTCMargin;
|
||||||
maxtc.x() += fHorizTCMargin;
|
maxtc.x() += fHorizTCMargin;
|
||||||
@ -1202,10 +1209,10 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
|||||||
unsigned int contextID = state.getContextID();
|
unsigned int contextID = state.getContextID();
|
||||||
|
|
||||||
state.applyMode(GL_BLEND,true);
|
state.applyMode(GL_BLEND,true);
|
||||||
#if 1
|
#if 1
|
||||||
state.applyTextureMode(0,GL_TEXTURE_2D,true);
|
state.applyTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||||
#else
|
#else
|
||||||
state.applyTextureMode(0,GL_TEXTURE_2D,false);
|
state.applyTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OFF);
|
||||||
#endif
|
#endif
|
||||||
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE)
|
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE)
|
||||||
state.applyTextureAttribute(0,getActiveFont()->getTexEnv());
|
state.applyTextureAttribute(0,getActiveFont()->getTexEnv());
|
||||||
@ -1341,10 +1348,10 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
state.applyTextureMode(0,GL_TEXTURE_2D,true);
|
state.applyTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||||
#else
|
#else
|
||||||
state.applyTextureMode(0,GL_TEXTURE_2D,false);
|
state.applyTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OFF);
|
||||||
#endif
|
#endif
|
||||||
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE)
|
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE)
|
||||||
state.applyTextureAttribute(0,getActiveFont()->getTexEnv());
|
state.applyTextureAttribute(0,getActiveFont()->getTexEnv());
|
||||||
|
@ -124,7 +124,7 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i
|
|||||||
float maximumWidth = _maximumWidth;
|
float maximumWidth = _maximumWidth;
|
||||||
|
|
||||||
float hr = 1.0f;
|
float hr = 1.0f;
|
||||||
float wr = 1.0f/getCharacterAspectRatio();
|
float wr = 1.0f;
|
||||||
|
|
||||||
for(bool outOfSpace=false;lastChar!=last;++lastChar)
|
for(bool outOfSpace=false;lastChar!=last;++lastChar)
|
||||||
{
|
{
|
||||||
@ -140,76 +140,53 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i
|
|||||||
{
|
{
|
||||||
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
||||||
|
|
||||||
|
if (_layout==RIGHT_TO_LEFT)
|
||||||
|
{
|
||||||
|
cursor.x() -= glyph->getHorizontalAdvance() * wr;
|
||||||
|
}
|
||||||
|
|
||||||
// adjust cursor position w.r.t any kerning.
|
// adjust cursor position w.r.t any kerning.
|
||||||
if (previous_charcode)
|
if (kerning && previous_charcode)
|
||||||
{
|
{
|
||||||
|
switch(_layout)
|
||||||
if (_layout == RIGHT_TO_LEFT)
|
|
||||||
{
|
{
|
||||||
cursor.x() -= glyph->getHorizontalAdvance() * wr;
|
case LEFT_TO_RIGHT:
|
||||||
}
|
{
|
||||||
|
osg::Vec2 delta(_font->getKerning(previous_charcode,charcode,_kerningType));
|
||||||
if (kerning)
|
cursor.x() += delta.x() * wr;
|
||||||
{
|
cursor.y() += delta.y() * hr;
|
||||||
switch (_layout)
|
break;
|
||||||
{
|
}
|
||||||
case LEFT_TO_RIGHT:
|
case RIGHT_TO_LEFT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(_font->getKerning(previous_charcode,charcode,_kerningType));
|
osg::Vec2 delta(_font->getKerning(charcode,previous_charcode,_kerningType));
|
||||||
cursor.x() += delta.x() * wr;
|
cursor.x() -= delta.x() * wr;
|
||||||
cursor.y() += delta.y() * hr;
|
cursor.y() -= delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RIGHT_TO_LEFT:
|
case VERTICAL:
|
||||||
{
|
break; // no kerning when vertical.
|
||||||
osg::Vec2 delta(_font->getKerning(charcode,previous_charcode,_kerningType));
|
|
||||||
cursor.x() -= delta.x() * wr;
|
|
||||||
cursor.y() -= delta.y() * hr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case VERTICAL:
|
|
||||||
break; // no kerning when vertical.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (_layout)
|
|
||||||
{
|
|
||||||
case LEFT_TO_RIGHT:
|
|
||||||
{
|
|
||||||
cursor.x() -= glyph->getHorizontalBearing().x() * wr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RIGHT_TO_LEFT:
|
|
||||||
{
|
|
||||||
cursor.x() -= bb.xMax() * wr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case VERTICAL:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
osg::Vec2 local = cursor;
|
||||||
|
|
||||||
switch(_layout)
|
switch(_layout)
|
||||||
{
|
{
|
||||||
case LEFT_TO_RIGHT:
|
case LEFT_TO_RIGHT:
|
||||||
{
|
{
|
||||||
if (maximumWidth>0.0f && cursor.x()+bb.xMax()>maximumWidth) outOfSpace=true;
|
if (maximumWidth>0.0f && local.x()+bb.xMax()>maximumWidth) outOfSpace=true;
|
||||||
if(maximumHeight>0.0f && cursor.y()<-maximumHeight) outOfSpace=true;
|
if(maximumHeight>0.0f && local.y()<-maximumHeight) outOfSpace=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RIGHT_TO_LEFT:
|
case RIGHT_TO_LEFT:
|
||||||
{
|
{
|
||||||
if (maximumWidth>0.0f && cursor.x()+bb.xMin()<-maximumWidth) outOfSpace=true;
|
if (maximumWidth>0.0f && local.x()+bb.xMin()<-maximumWidth) outOfSpace=true;
|
||||||
if(maximumHeight>0.0f && cursor.y()<-maximumHeight) outOfSpace=true;
|
if(maximumHeight>0.0f && local.y()<-maximumHeight) outOfSpace=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VERTICAL:
|
case VERTICAL:
|
||||||
if (maximumHeight>0.0f && cursor.y()<-maximumHeight) outOfSpace=true;
|
if (maximumHeight>0.0f && local.y()<-maximumHeight) outOfSpace=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +264,7 @@ void Text3D::computeGlyphRepresentation()
|
|||||||
|
|
||||||
|
|
||||||
float hr = 1.0f;
|
float hr = 1.0f;
|
||||||
float wr = 1.0f/getCharacterAspectRatio();
|
float wr = 1.0f;
|
||||||
|
|
||||||
osg::Vec2 startOfLine_coords(0.0f,0.0f);
|
osg::Vec2 startOfLine_coords(0.0f,0.0f);
|
||||||
osg::Vec2 cursor(startOfLine_coords);
|
osg::Vec2 cursor(startOfLine_coords);
|
||||||
@ -300,8 +277,6 @@ void Text3D::computeGlyphRepresentation()
|
|||||||
|
|
||||||
unsigned int lineNumber = 0;
|
unsigned int lineNumber = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(String::iterator itr=_text.begin(); itr!=_text.end(); )
|
for(String::iterator itr=_text.begin(); itr!=_text.end(); )
|
||||||
{
|
{
|
||||||
_textRenderInfo.resize(lineNumber + 1);
|
_textRenderInfo.resize(lineNumber + 1);
|
||||||
@ -329,70 +304,37 @@ void Text3D::computeGlyphRepresentation()
|
|||||||
{
|
{
|
||||||
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
||||||
|
|
||||||
// adjust cursor position w.r.t any kerning.
|
if (_layout==RIGHT_TO_LEFT)
|
||||||
if (previous_charcode)
|
|
||||||
{
|
{
|
||||||
if (_layout == RIGHT_TO_LEFT)
|
cursor.x() -= glyph->getHorizontalAdvance() * wr;
|
||||||
{
|
|
||||||
cursor.x() -= glyph->getHorizontalAdvance() * wr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kerning)
|
|
||||||
{
|
|
||||||
switch (_layout)
|
|
||||||
{
|
|
||||||
case LEFT_TO_RIGHT:
|
|
||||||
{
|
|
||||||
osg::Vec2 delta(_font->getKerning(previous_charcode,charcode,_kerningType));
|
|
||||||
cursor.x() += delta.x() * wr;
|
|
||||||
cursor.y() += delta.y() * hr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RIGHT_TO_LEFT:
|
|
||||||
{
|
|
||||||
osg::Vec2 delta(_font->getKerning(charcode,previous_charcode,_kerningType));
|
|
||||||
cursor.x() -= delta.x() * wr;
|
|
||||||
cursor.y() -= delta.y() * hr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case VERTICAL:
|
|
||||||
break; // no kerning when vertical.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (_layout)
|
|
||||||
{
|
|
||||||
case LEFT_TO_RIGHT:
|
|
||||||
{
|
|
||||||
cursor.x() -= glyph->getHorizontalBearing().x() * wr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RIGHT_TO_LEFT:
|
|
||||||
{
|
|
||||||
cursor.x() -= bb.xMax() * wr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case VERTICAL:
|
|
||||||
{
|
|
||||||
// cursor.y() += glyph->getVerticalBearing().y();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// adjust cursor position w.r.t any kerning.
|
||||||
|
if (kerning && previous_charcode)
|
||||||
|
{
|
||||||
|
switch(_layout)
|
||||||
|
{
|
||||||
|
case LEFT_TO_RIGHT:
|
||||||
|
{
|
||||||
|
osg::Vec2 delta(_font->getKerning(previous_charcode,charcode,_kerningType));
|
||||||
|
cursor.x() += delta.x() * wr;
|
||||||
|
cursor.y() += delta.y() * hr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RIGHT_TO_LEFT:
|
||||||
|
{
|
||||||
|
osg::Vec2 delta(_font->getKerning(charcode,previous_charcode,_kerningType));
|
||||||
|
cursor.x() -= delta.x() * wr;
|
||||||
|
cursor.y() -= delta.y() * hr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VERTICAL:
|
||||||
|
break; // no kerning when vertical.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local = cursor;
|
local = cursor;
|
||||||
|
|
||||||
if (_layout==VERTICAL)
|
|
||||||
{
|
|
||||||
local.x() += -glyph->getVerticalBearing().x() * wr;
|
|
||||||
local.y() += -glyph->getVerticalBearing().y() * hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// move the cursor onto the next character.
|
// move the cursor onto the next character.
|
||||||
// also expand bounding box
|
// also expand bounding box
|
||||||
switch (_layout)
|
switch (_layout)
|
||||||
@ -400,12 +342,12 @@ void Text3D::computeGlyphRepresentation()
|
|||||||
case LEFT_TO_RIGHT:
|
case LEFT_TO_RIGHT:
|
||||||
_textBB.expandBy(osg::Vec3(cursor.x() + bb.xMin()*wr, cursor.y() + bb.yMin()*hr, 0.0f)); //lower left corner
|
_textBB.expandBy(osg::Vec3(cursor.x() + bb.xMin()*wr, cursor.y() + bb.yMin()*hr, 0.0f)); //lower left corner
|
||||||
_textBB.expandBy(osg::Vec3(cursor.x() + bb.xMax()*wr, cursor.y() + bb.yMax()*hr, 0.0f)); //upper right corner
|
_textBB.expandBy(osg::Vec3(cursor.x() + bb.xMax()*wr, cursor.y() + bb.yMax()*hr, 0.0f)); //upper right corner
|
||||||
cursor.x() += glyph->getHorizontalAdvance();
|
cursor.x() += glyph->getHorizontalAdvance() * wr;
|
||||||
break;
|
break;
|
||||||
case VERTICAL:
|
case VERTICAL:
|
||||||
_textBB.expandBy(osg::Vec3(cursor.x(), cursor.y(), 0.0f)); //upper left corner
|
_textBB.expandBy(osg::Vec3(cursor.x(), cursor.y(), 0.0f)); //upper left corner
|
||||||
_textBB.expandBy(osg::Vec3(cursor.x() + glyph->getWidth()*wr, cursor.y() - glyph->getHeight()*hr, 0.0f)); //lower right corner
|
_textBB.expandBy(osg::Vec3(cursor.x() + glyph->getWidth()*wr, cursor.y() - glyph->getHeight()*hr, 0.0f)); //lower right corner
|
||||||
cursor.y() -= glyph->getVerticalAdvance();
|
cursor.y() -= glyph->getVerticalAdvance() * hr;
|
||||||
break;
|
break;
|
||||||
case RIGHT_TO_LEFT:
|
case RIGHT_TO_LEFT:
|
||||||
_textBB.expandBy(osg::Vec3(cursor.x()+bb.xMax()*wr, cursor.y() + bb.yMax()*hr, 0.0f)); //upper right corner
|
_textBB.expandBy(osg::Vec3(cursor.x()+bb.xMax()*wr, cursor.y() + bb.yMax()*hr, 0.0f)); //upper right corner
|
||||||
@ -534,9 +476,6 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
|
|||||||
osg::State & state = *renderInfo.getState();
|
osg::State & state = *renderInfo.getState();
|
||||||
unsigned int contextID = state.getContextID();
|
unsigned int contextID = state.getContextID();
|
||||||
|
|
||||||
state.disableColorPointer();
|
|
||||||
state.Color(_color.r(),_color.g(),_color.b(),_color.a());
|
|
||||||
|
|
||||||
// ** save the previous modelview matrix
|
// ** save the previous modelview matrix
|
||||||
osg::Matrix previous(state.getModelViewMatrix());
|
osg::Matrix previous(state.getModelViewMatrix());
|
||||||
|
|
||||||
@ -555,6 +494,8 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
|
|||||||
{
|
{
|
||||||
if (_textBB.valid())
|
if (_textBB.valid())
|
||||||
{
|
{
|
||||||
|
gl.Color4fv(_color.ptr());
|
||||||
|
|
||||||
osg::Vec3 c000(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMax()));
|
osg::Vec3 c000(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMax()));
|
||||||
osg::Vec3 c100(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMax()));
|
osg::Vec3 c100(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMax()));
|
||||||
osg::Vec3 c110(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax()));
|
osg::Vec3 c110(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax()));
|
||||||
@ -604,6 +545,8 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
|
|||||||
osg::Vec3 vt(osg::Vec3(_offset.x(),_offset.y()-cursorsize,_offset.z()));
|
osg::Vec3 vt(osg::Vec3(_offset.x(),_offset.y()-cursorsize,_offset.z()));
|
||||||
osg::Vec3 vb(osg::Vec3(_offset.x(),_offset.y()+cursorsize,_offset.z()));
|
osg::Vec3 vb(osg::Vec3(_offset.x(),_offset.y()+cursorsize,_offset.z()));
|
||||||
|
|
||||||
|
gl.Color4fv(_color.ptr());
|
||||||
|
|
||||||
gl.Begin(GL_LINES);
|
gl.Begin(GL_LINES);
|
||||||
gl.Vertex3fv(hl.ptr());
|
gl.Vertex3fv(hl.ptr());
|
||||||
gl.Vertex3fv(hr.ptr());
|
gl.Vertex3fv(hr.ptr());
|
||||||
@ -615,6 +558,9 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
|
|||||||
|
|
||||||
if (_drawMode & TEXT)
|
if (_drawMode & TEXT)
|
||||||
{
|
{
|
||||||
|
state.disableColorPointer();
|
||||||
|
state.Color(_color.r(),_color.g(),_color.b(),_color.a());
|
||||||
|
|
||||||
renderInfo.getState()->disableAllVertexArrays();
|
renderInfo.getState()->disableAllVertexArrays();
|
||||||
|
|
||||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||||
|
@ -93,14 +93,6 @@ void TextBase::setFont(osg::ref_ptr<Font> font)
|
|||||||
{
|
{
|
||||||
if (_font==font) return;
|
if (_font==font) return;
|
||||||
|
|
||||||
osg::StateSet* previousFontStateSet = _font.valid() ? _font->getStateSet() : Font::getDefaultFont()->getStateSet();
|
|
||||||
osg::StateSet* newFontStateSet = font.valid() ? font->getStateSet() : Font::getDefaultFont()->getStateSet();
|
|
||||||
|
|
||||||
if (getStateSet() == previousFontStateSet)
|
|
||||||
{
|
|
||||||
setStateSet( newFontStateSet );
|
|
||||||
}
|
|
||||||
|
|
||||||
_font = font;
|
_font = font;
|
||||||
|
|
||||||
computeGlyphRepresentation();
|
computeGlyphRepresentation();
|
||||||
|
Loading…
Reference in New Issue
Block a user