From 8f6db66e597be1a025d0873c0f0b2edae33fa127 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 14 Jan 2010 15:15:42 +0000 Subject: [PATCH] Added setting of the charcode during construction of osgText::Font::Glyph() --- include/osgText/Font | 4 ++-- src/osgPlugins/freetype/FreeTypeFont.cpp | 2 +- src/osgPlugins/txf/TXFFont.cpp | 4 ++-- src/osgText/DefaultFont.cpp | 2 +- src/osgText/Font.cpp | 9 ++------- src/osgWrappers/osgText/Font.cpp | 4 +++- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/include/osgText/Font b/include/osgText/Font index 8dcbb7ef3..abf96f475 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -278,9 +278,9 @@ public: { public: - Glyph(); + Glyph(unsigned int glyphCode); - unsigned int getGlyphCode() const; + unsigned int getGlyphCode() const { return _glyphCode; } void setHorizontalBearing(const osg::Vec2& bearing); const osg::Vec2& getHorizontalBearing() const; diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index c727ce220..30e5618b1 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -135,7 +135,7 @@ osgText::Font::Glyph* FreeTypeFont::getGlyph(const osgText::FontResolution& font unsigned int width = sourceWidth; unsigned int height = sourceHeight; - osg::ref_ptr glyph = new osgText::Font::Glyph; + osg::ref_ptr glyph = new osgText::Font::Glyph(charcode); unsigned int dataSize = width*height; unsigned char* data = new unsigned char[dataSize]; diff --git a/src/osgPlugins/txf/TXFFont.cpp b/src/osgPlugins/txf/TXFFont.cpp index ad79eb073..f15430abe 100644 --- a/src/osgPlugins/txf/TXFFont.cpp +++ b/src/osgPlugins/txf/TXFFont.cpp @@ -230,7 +230,7 @@ TXFFont::loadFont(std::istream& stream) continue; // add the characters ... - osgText::Font::Glyph* glyph = new osgText::Font::Glyph; + osgText::Font::Glyph* glyph = new osgText::Font::Glyph(glyphs[i].ch); unsigned sourceWidth = glyphs[i].width; unsigned sourceHeight = glyphs[i].height; @@ -271,7 +271,7 @@ TXFFont::loadFont(std::istream& stream) } // insert a trivial blank character - osgText::Font::Glyph* glyph = new osgText::Font::Glyph; + osgText::Font::Glyph* glyph = new osgText::Font::Glyph(' '); unsigned width = 1; unsigned height = 1; diff --git a/src/osgText/DefaultFont.cpp b/src/osgText/DefaultFont.cpp index a6f531548..debc05095 100644 --- a/src/osgText/DefaultFont.cpp +++ b/src/osgText/DefaultFont.cpp @@ -205,7 +205,7 @@ void DefaultFont::constructGlyphs() // populate the glyph mp for(unsigned int i=32;i<127;i++) { - osg::ref_ptr glyph = new Glyph; + osg::ref_ptr glyph = new Glyph(i); unsigned int dataSize = sourceWidth*sourceHeight; unsigned char* data = new unsigned char[dataSize]; diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index 2bfe5c24e..1e00ba935 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -804,9 +804,9 @@ void Font::GlyphTexture::resizeGLObjectBuffers(unsigned int maxSize) // all the methods in Font::Glyph have been made non inline because VisualStudio6.0 is STUPID, STUPID, STUPID PILE OF JUNK. -Font::Glyph::Glyph(): +Font::Glyph::Glyph(unsigned int glyphCode): _font(0), - _glyphCode(0), + _glyphCode(glyphCode), _horizontalBearing(0.0f,0.f), _horizontalAdvance(0.f), _verticalBearing(0.0f,0.f), @@ -824,11 +824,6 @@ Font::Glyph::~Glyph() { } -unsigned int Font::Glyph::getGlyphCode() const { return _glyphCode; } - -// void Font::Glyph::setFont(Font* font) { _font = font; } -// Font* Font::Glyph::getFont() const { return _font; } - void Font::Glyph::setHorizontalBearing(const osg::Vec2& bearing) { _horizontalBearing=bearing; } const osg::Vec2& Font::Glyph::getHorizontalBearing() const { return _horizontalBearing; } diff --git a/src/osgWrappers/osgText/Font.cpp b/src/osgWrappers/osgText/Font.cpp index a7c6a65f5..74c8a1925 100644 --- a/src/osgWrappers/osgText/Font.cpp +++ b/src/osgWrappers/osgText/Font.cpp @@ -280,7 +280,9 @@ END_REFLECTOR BEGIN_OBJECT_REFLECTOR(osgText::Font::Glyph) I_DeclaringFile("osgText/Font"); I_BaseType(osg::Image); - I_Constructor0(____Glyph, + I_Constructor1(IN, unsigned int, glyphCode, + Properties::NON_EXPLICIT, + ____Glyph__unsigned_int, "", ""); I_Method0(unsigned int, getGlyphCode,