Changeset 9881 for OpenSceneGraph/trunk/include/osgText/Font3D
- Timestamp:
- 03/10/09 11:56:00 (4 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgText/Font3D (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgText/Font3D
r7874 r9881 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 32 32 33 33 /** Read a font from specified file. The filename may contain a path. 34 * It will search for the font file in the following places in this order: 34 * It will search for the font file in the following places in this order: 35 35 * - In the current directory 36 36 * - All paths defined in OSG_FILE_PATH or OSGFILEPATH environment variable … … 46 46 * - Other OS: In /usr/share/fonts/ttf/western 47 47 * - Other OS: In /usr/share/fonts/ttf/decoratives 48 * 48 * 49 49 * If the given file could not be found, the path part will be stripped and 50 50 * the file will be searched again in the OS specific directories. … … 68 68 // declare the interface to a font. 69 69 public: 70 70 71 71 // forward declare nested classes. 72 72 class Glyph3D; … … 93 93 /** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/ 94 94 virtual Glyph3D* getGlyph(unsigned int charcode); 95 95 96 96 /** Return true if this font provides vertical alignments and spacing or glyphs.*/ 97 97 virtual bool hasVertical() const; … … 99 99 /** Return the scale to apply on the glyph to have a charactere size equal to 1 */ 100 100 virtual float getScale() const { return _implementation->getScale(); }; 101 101 102 102 // make Text a friend to allow it add and remove its entry in the Font's _textList. 103 103 friend class Font3DImplementation; … … 110 110 /** Set whether to use a mutex to ensure ref() and unref() */ 111 111 virtual void setThreadSafeRefUnref(bool threadSafe); 112 112 113 113 typedef OpenThreads::Mutex Font3DMutex; 114 114 … … 116 116 117 117 virtual ~Font3D(); 118 118 119 119 // void addGlyph(unsigned int width, unsigned int height, unsigned int charcode, Glyph* glyph); 120 120 void addGlyph(unsigned int charcode, Glyph3D* glyph); 121 121 122 122 // current active size of font 123 123 unsigned int _depth; … … 128 128 129 129 typedef std::map<char, osg::ref_ptr<Glyph3D> > Glyph3DMap; 130 Glyph3DMap _glyph3DMap; 131 130 Glyph3DMap _glyph3DMap; 131 132 132 osg::ref_ptr<Font3DImplementation> _implementation; 133 133 134 134 135 135 // declare the nested classes. 136 136 public: … … 139 139 { 140 140 public: 141 141 142 142 Font3DImplementation(): 143 143 osg::Referenced(true), 144 144 _facade(0) {} 145 145 146 146 virtual std::string getFileName() const = 0; 147 147 … … 154 154 /** Return true if this font provides vertical alignments and spacing or glyphs.*/ 155 155 virtual bool hasVertical() const = 0; 156 156 157 157 virtual float getScale() const = 0; 158 158 159 159 void setFontWidth(unsigned int width) { _facade->_width = width; } 160 160 161 161 void setFontHeight(unsigned int height) { _facade->_height = height; } 162 162 163 163 void setFontDepth(unsigned int depth) { _facade->_depth = depth; } 164 164 165 165 // void addGlyph(unsigned int width, unsigned int height, unsigned int charcode, Glyph3D* glyph) 166 166 // { 167 167 // _facade->addGlyph(width, height, charcode, glyph); 168 168 // } 169 // 169 // 170 170 // void addGlyph(unsigned int charcode, Glyph3D* glyph) 171 171 // { … … 182 182 Glyph3D(unsigned int glyphCode): 183 183 osg::Referenced(true), 184 _glyphCode(glyphCode), 184 _glyphCode(glyphCode), 185 185 _horizontalBearing(0,0), 186 186 _horizontalAdvance(0), … … 188 188 _verticalAdvance(0) 189 189 {} 190 190 191 191 192 192 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ 193 193 // virtual int compare(const osg::StateAttribute& rhs) const; 194 // 194 // 195 195 // virtual void apply(osg::State& state) const; 196 196 197 198 197 198 199 199 unsigned int getGlyphCode() const { return _glyphCode; } 200 200 201 201 void setHorizontalBearing(const osg::Vec2& bearing) { _horizontalBearing=bearing; } 202 202 const osg::Vec2 & getHorizontalBearing() const { return _horizontalBearing; } 203 203 204 204 void setHorizontalAdvance(float advance) { _horizontalAdvance=advance; } 205 205 float getHorizontalAdvance() const { return _horizontalAdvance; } … … 210 210 void setVerticalAdvance(float advance) { _verticalAdvance=advance; } 211 211 float getVerticalAdvance() const { return _verticalAdvance; } 212 212 213 213 void setBoundingBox(osg::BoundingBox & bb) { _bb=bb; } 214 214 const osg::BoundingBox & getBoundingBox() const { return _bb; } 215 216 215 216 217 217 /** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/ 218 218 virtual void setThreadSafeRefUnref(bool threadSafe); 219 219 220 220 221 221 /** Get the PrimitiveSetList for the front face. */ 222 222 osg::Geometry::PrimitiveSetList & getFrontPrimitiveSetList() { return _frontPrimitiveSetList; } … … 225 225 /** Get et the PrimitiveSetList for the back face. */ 226 226 osg::Geometry::PrimitiveSetList & getBackPrimitiveSetList() { return _backPrimitiveSetList; } 227 227 228 228 /** Set the VertexArray of the glyph. */ 229 229 void setVertexArray(osg::Vec3Array * va) { _vertexArray = va; } 230 230 /** Get the VertexArray of the glyph. */ 231 231 osg::Vec3Array * getVertexArray() { return _vertexArray.get(); } 232 /** Set the VertexArray of the glyph. */ 233 void setNormalArray(osg::Vec3Array * na) { _normalArray = na; } 232 234 /** Get the NormalArray for the wall face. */ 233 235 osg::Vec3Array * getNormalArray() { return _normalArray.get(); } 234 236 235 237 float getHorizontalWidth() { return (-_horizontalBearing.x() + _horizontalAdvance); } 236 238 float getHorizontalHeight() { return (-_horizontalBearing.y() + _bb.yMax()); } 237 239 float getVerticalWidth() { return (-_verticalBearing.x() + _bb.xMax()); } 238 240 float getVerticalHeight() { return (-_verticalBearing.y() + _verticalAdvance); } 239 241 240 242 void setWidth(float width) { _width = width; } 241 243 float getWidth() { return _width; } 242 244 243 245 void setHeight(float height) { _height = height; } 244 246 float getHeight() { return _height; } 245 247 246 248 protected: 247 249 248 250 virtual ~Glyph3D() {} 249 251 … … 256 258 float _verticalAdvance; 257 259 258 osg::BoundingBox _bb; 260 osg::BoundingBox _bb; 259 261 // osg::Vec2 _advance; 260 262 261 263 float _width; 262 264 float _height; 263 264 265 266 265 267 osg::ref_ptr<osg::Vec3Array> _vertexArray; 266 268 osg::ref_ptr<osg::Vec3Array> _normalArray; 267 269 268 270 osg::Geometry::PrimitiveSetList _frontPrimitiveSetList; 269 271 osg::Geometry::PrimitiveSetList _wallPrimitiveSetList; 270 272 osg::Geometry::PrimitiveSetList _backPrimitiveSetList; 271 272 273 274 273 275 }; 274 276
