From fd1493e14bf39c52f4d222368472103208533e24 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 25 Aug 2010 11:06:10 +0000 Subject: [PATCH] Added support for controlling the number of curves samples to generate on Glyph3D's. Set via Font3D::setNumberCurveSamples(num). --- include/osgText/Font3D | 6 ++++++ src/osgPlugins/freetype/FreeTypeFont3D.cpp | 6 +++--- src/osgPlugins/freetype/FreeTypeFont3D.h | 2 -- src/osgText/Font3D.cpp | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/osgText/Font3D b/include/osgText/Font3D index 03b35ad67..bac559add 100644 --- a/include/osgText/Font3D +++ b/include/osgText/Font3D @@ -87,6 +87,9 @@ public: unsigned int getFontHeight() const { return _height; } unsigned int getFontDepth() const { return _depth; } + void setNumberCurveSamples(unsigned int numSamples) { _numCurveSamples = numSamples; } + unsigned int getNumberCurveSamples() const { return _numCurveSamples; } + /** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/ virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType); @@ -123,6 +126,9 @@ protected: unsigned int _depth; unsigned int _width; unsigned int _height; + + unsigned int _numCurveSamples; + // unsigned int _margin; // float _marginRatio; diff --git a/src/osgPlugins/freetype/FreeTypeFont3D.cpp b/src/osgPlugins/freetype/FreeTypeFont3D.cpp index 1b4ac9683..292188175 100644 --- a/src/osgPlugins/freetype/FreeTypeFont3D.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont3D.cpp @@ -39,7 +39,7 @@ namespace struct Char3DInfo { - Char3DInfo(int numSteps=50): + Char3DInfo(int numSteps): _verts( new osg::Vec3Array ), _geometry( new osg::Geometry ), _idx(0), @@ -243,7 +243,7 @@ void FreeTypeFont3D::init() } { - Char3DInfo char3d; + Char3DInfo char3d(10); FT_Outline outline = _face->glyph->outline; FT_Outline_Funcs funcs; @@ -344,7 +344,7 @@ osgText::Font3D::Glyph3D * FreeTypeFont3D::getGlyph(unsigned int charcode) } // ** init FreeType to describe the glyph - Char3DInfo char3d; + Char3DInfo char3d(_facade->getNumberCurveSamples()); FT_Outline outline = _face->glyph->outline; FT_Outline_Funcs funcs; diff --git a/src/osgPlugins/freetype/FreeTypeFont3D.h b/src/osgPlugins/freetype/FreeTypeFont3D.h index a6c9c8317..f6c2abda9 100644 --- a/src/osgPlugins/freetype/FreeTypeFont3D.h +++ b/src/osgPlugins/freetype/FreeTypeFont3D.h @@ -29,8 +29,6 @@ public: virtual std::string getFileName() const { return _filename; } -// virtual void setFontResolution(unsigned int width, unsigned int height, unsigned int depth); - virtual osgText::Font3D::Glyph3D * getGlyph(unsigned int charcode); virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType _kerningType); diff --git a/src/osgText/Font3D.cpp b/src/osgText/Font3D.cpp index 33b2d482c..88737fc84 100644 --- a/src/osgText/Font3D.cpp +++ b/src/osgText/Font3D.cpp @@ -243,7 +243,8 @@ Font3D::Font3D(Font3DImplementation* implementation): osg::Object(true), _depth(1), _width(64), - _height(64) + _height(64), + _numCurveSamples(10) { setImplementation(implementation); }