#include <OSGTextTXFFace.h>
Inheritance diagram for osg::TextTXFFace:

Public Types | |
| enum | Style { STYLE_PLAIN, STYLE_BOLD, STYLE_ITALIC, STYLE_BOLDITALIC } |
Public Member Functions | |
| Real32 | getScale () const |
| const TextTXFParam & | getParam () const |
| ImagePtr | getTexture () const |
| virtual const TextGlyph & | getGlyph (TextGlyph::Index glyphIndex) |
| const TextTXFGlyph & | getTXFGlyph (TextGlyph::Index glyphIndex) |
| virtual void | layout (const std::string &utf8Text, const TextLayoutParam ¶m, TextLayoutResult &result) |
| virtual void | layout (const std::wstring &text, const TextLayoutParam ¶m, TextLayoutResult &result) |
| virtual void | layout (const std::vector< std::string > &lines, const TextLayoutParam ¶m, TextLayoutResult &result) |
| virtual void | layout (const std::vector< std::wstring > &lines, const TextLayoutParam ¶m, TextLayoutResult &result) |
| void | fillGeo (GeometryPtr &geoPtr, const TextLayoutResult &layoutResult, Real32 scale=1.f, Vec2f offset=Vec2f(0, 0), Color3f color=Color3f(-1,-1,-1)) |
| void | addToGeom (GeometryPtr &geoPtr, const TextLayoutResult &layoutResult, Real32 scale=1.f, Vec2f offset=Vec2f(0, 0), Color3f color=Color3f(-1,-1,-1)) |
| GeometryPtr | makeGeo (const TextLayoutResult &layoutResult, Real32 scale=1.f, Vec2f offset=Vec2f(0, 0), Color3f color=Color3f(-1,-1,-1)) |
| NodePtr | makeNode (const TextLayoutResult &layoutResult, Real32 scale=1.f, Vec2f offset=Vec2f(0, 0), Color3f color=Color3f(-1,-1,-1)) |
| bool | writeToStream (std::ostream &os) const |
| bool | writeToFile (const std::string &filename) const |
| const std::string | getFamily () const |
| Style | getStyle () const |
| Real32 | getHoriAscent () const |
| Real32 | getVertAscent () const |
| Real32 | getHoriDescent () const |
| Real32 | getVertDescent () const |
| void | calculateBoundingBox (const TextLayoutResult &layoutResult, Vec2f &lowerLeft, Vec2f &upperRight) |
Reference Counting | |
| *void | addRef (void) |
| void | subRef (void) |
| Int32 | getRefCount (void) |
Static Public Member Functions | |
| static TextTXFFace * | create (const std::string &family, Style style=STYLE_PLAIN, const TextTXFParam ¶m=TextTXFParam()) |
| static TextTXFFace * | createFromStream (std::istream &is, const std::string &family=std::string(), Style style=STYLE_PLAIN) |
| static TextTXFFace * | createFromFile (const std::string &filename) |
| static void | convertUTF8ToUnicode (const std::string &utf8Text, std::wstring &text) |
Protected Types | |
| typedef std::map< TextGlyph::Index, TextTXFGlyph * > | GlyphMap |
Protected Member Functions | |
| TextTXFFace () | |
| virtual | ~TextTXFFace () |
| void | prepareTexture (const TextTXFParam ¶m) |
| void | justifyLine (const TextLayoutParam ¶m, const std::vector< UInt32 > &spaceIndices, Vec2f &currPos, TextLayoutResult &layoutResult) const |
| void | adjustLineOrigin (const TextLayoutParam ¶m, const Vec2f &currPos, TextLayoutResult &layoutResult) const |
Protected Attributes | |
| Real32 | _scale |
| TextTXFParam | _param |
| ImagePtr | _texture |
| GlyphMap | _glyphMap |
| std::string | _family |
| Style | _style |
| Real32 | _horiAscent |
| Real32 | _vertAscent |
| Real32 | _horiDescent |
| Real32 | _vertDescent |
Private Member Functions | |
| TextTXFFace (const TextTXFFace &) | |
| const TextTXFFace & | operator= (const TextTXFFace &) |
Static Private Attributes | |
| static TextTXFGlyph | _emptyGlyph |
// Includes #include "OSGTextTXFFace.h" #include "OSGTextLayoutParam.h" #include "OSGTextLayoutResult.h" // Try to create a new %TextTXFFace object. The create // method returns 0 in case of an error TextTXFFace *face = TextTXFFace::create("SANS"); if (face == 0) ; // error handling // Increment the reference counter of the face object. // Faces are cached, and we might not be the only one // using the face object addRefP(face); // Lay out a single line of text. There are lots of parameters // you can set in the layoutParam object, but for now we are // satisfied with the default values. See the documentation // of the TextLayoutParam class for more information. TextLayoutParam layoutParam; TextLayoutResult layoutResult; face->layout("Hello World!", layoutParam, layoutResult); // Create the geometry using the layout information returned // from the previous call to the layout method. Real32 scale = 2.f; // This is the height of the glyphs GeometryPtr geo = face->makeGeo(layoutResult, scale); // Get the texture. You have to map this texture onto the // geometry we created above. ImagePtr img = face->getTexture(); // We do not need the TXF face anymore, so decrement // the reference counter. Do not use the face object anymore! subRefP(face);
Definition at line 120 of file OSGTextTXFFace.h.
|
|
Defines a map of glyphs Definition at line 308 of file OSGTextTXFFace.h. |
|
|
Defines the styles of a face Definition at line 75 of file OSGTextFace.h. 00076 { 00077 STYLE_PLAIN, 00078 STYLE_BOLD, 00079 STYLE_ITALIC, 00080 STYLE_BOLDITALIC 00081 };
|
|
|
Creates a new TextTXFFace object. Definition at line 52 of file OSGTextTXFFace.inl.
|
|
|
Destroys the TextTXFFace object. Definition at line 74 of file OSGTextTXFFace.cpp. References _glyphMap, _texture, and osg::subRefCP(). 00075 { 00076 // Delete all glyphs in the glyph cache 00077 GlyphMap::iterator it; 00078 for (it = _glyphMap.begin(); it != _glyphMap.end(); ++it) 00079 { 00080 assert(it->second != 0); 00081 delete it->second; 00082 } 00083 00084 // Delete the texture 00085 subRefCP(_texture); 00086 }
|
|
|
Copy constructor (not implemented!) |
|
|
Returns the scaling factor.
Definition at line 43 of file OSGTextTXFFace.inl. References _scale. 00043 { return _scale; }
|
|
|
Returns the parameters of the face.
Definition at line 46 of file OSGTextTXFFace.inl. References _param. 00046 { return _param; }
|
|
|
Returns the texture that contains all glyphs.
Definition at line 49 of file OSGTextTXFFace.inl. References _texture. Referenced by osg::SimpleStatisticsForeground::initText(), and osg::GraphicStatisticsForeground::initText(). 00049 { return _texture; }
|
|
|
Returns information about a glyph.
Implements osg::TextFace. Definition at line 93 of file OSGTextTXFFace.cpp. References getTXFGlyph(). 00094 { 00095 return getTXFGlyph(glyphIndex); 00096 }
|
|
|
Returns information about a glyph.
Definition at line 103 of file OSGTextTXFFace.cpp. References _emptyGlyph, _glyphMap, and osg::TextGlyph::INVALID_INDEX. Referenced by addToGeom(), osg::SimpleStatisticsForeground::draw(), osg::GraphicStatisticsForeground::drawString(), and getGlyph(). 00104 { 00105 // Try to find the glyph in the map of glyphs 00106 GlyphMap::const_iterator it = _glyphMap.find(glyphIndex); 00107 if (it != _glyphMap.end()) 00108 { 00109 assert(it->second != 0); 00110 return *(it->second); 00111 } 00112 00113 // We did not find the glyph in the map of glyphs, 00114 // so try to convert uppercase letters to lowercase 00115 // letters and vice versa 00116 if (glyphIndex > 255) 00117 glyphIndex = TextGlyph::INVALID_INDEX; 00118 else if (isupper(glyphIndex)) 00119 glyphIndex = tolower(glyphIndex); 00120 else if (islower(glyphIndex)) 00121 glyphIndex = toupper(glyphIndex); 00122 else 00123 glyphIndex = TextGlyph::INVALID_INDEX; 00124 it = _glyphMap.find(glyphIndex); 00125 if (it != _glyphMap.end()) 00126 { 00127 assert(it->second != 0); 00128 return *(it->second); 00129 } 00130 00131 return _emptyGlyph; 00132 }
|
|
||||||||||||||||
|
Lays out one line of text.
Reimplemented from osg::TextFace. Referenced by osg::SimpleStatisticsForeground::draw(), and osg::GraphicStatisticsForeground::drawString(). |
|
||||||||||||||||
|
Lays out one line of text.
Implements osg::TextFace. |
|
||||||||||||||||
|
Lays out multiple lines of text.
Reimplemented from osg::TextFace. |
|
||||||||||||||||
|
Lays out multiple lines of text.
Reimplemented from osg::TextFace. |
|
||||||||||||||||||||||||
|
Fills a geometry with a new text.
Definition at line 139 of file OSGTextTXFFace.cpp. References addToGeom(), and osg::NullFC. Referenced by makeGeo(). 00141 { 00142 // cast the field containers down to the needed type and create them 00143 // when they have the wrong type 00144 GeoPositions3fPtr posPtr = GeoPositions3fPtr::dcast(geoPtr->getPositions()); 00145 if (posPtr != NullFC) 00146 posPtr->clear(); 00147 00148 // Clear out any existing data and then add to the geom 00149 GeoNormals3fPtr normalPtr = GeoNormals3fPtr::dcast(geoPtr->getNormals()); 00150 if (normalPtr != NullFC) 00151 normalPtr->clear(); 00152 00153 GeoTexCoords2fPtr texPtr = GeoTexCoords2fPtr::dcast(geoPtr->getTexCoords()); 00154 if (texPtr != NullFC) 00155 texPtr->clear(); 00156 00157 GeoColors3fPtr colorPtr = GeoColors3fPtr::dcast(geoPtr->getColors()); 00158 if (NullFC != colorPtr) 00159 colorPtr->clear(); 00160 00161 GeoPLengthsUI32Ptr lensPtr = GeoPLengthsUI32Ptr::dcast(geoPtr->getLengths()); 00162 if (lensPtr != NullFC) 00163 lensPtr->clear(); 00164 00165 GeoPTypesUI8Ptr typesPtr = GeoPTypesUI8Ptr::dcast(geoPtr->getTypes()); 00166 if (typesPtr != NullFC) 00167 typesPtr->clear(); 00168 00169 geoPtr->setIndices(NullFC); 00170 geoPtr->setSecondaryColors(NullFC); 00171 geoPtr->setTexCoords1(NullFC); 00172 geoPtr->setTexCoords2(NullFC); 00173 geoPtr->setTexCoords3(NullFC); 00174 geoPtr->getIndexMapping().clear(); 00175 00176 addToGeom(geoPtr,layoutResult,scale,offset,color); 00177 }
|
|
||||||||||||||||||||||||
|
Adds geometry for new text to an existing text geometry.
Definition at line 179 of file OSGTextTXFFace.cpp. References osg::beginEditCP(), osg::TextTXFGlyph::COORD_BOTTOM, osg::TextTXFGlyph::COORD_LEFT, osg::TextTXFGlyph::COORD_RIGHT, osg::TextTXFGlyph::COORD_TOP, osg::GeoProperty< GeoPropertyDesc >::create(), osg::endEditCP(), osg::GeoProperty< GeoPropertyDesc >::GeoPropDataFieldMask, osg::TextTXFGlyph::getHeight(), osg::TextLayoutResult::getNumGlyphs(), osg::TextTXFGlyph::getTexCoord(), getTXFGlyph(), osg::TextTXFGlyph::getWidth(), osg::TextLayoutResult::indices, osg::NullFC, osg::TextLayoutResult::positions, osg::VecStorage2< ValueTypeT >::x(), and osg::VecStorage2< ValueTypeT >::y(). Referenced by fillGeo(). 00181 { 00182 beginEditCP(geoPtr); 00183 00184 // cast the field containers down to the needed type and create them 00185 // when they have the wrong type 00186 GeoPositions3fPtr posPtr = GeoPositions3fPtr::dcast(geoPtr->getPositions()); 00187 GeoNormals3fPtr normalPtr = GeoNormals3fPtr::dcast(geoPtr->getNormals()); 00188 GeoTexCoords2fPtr texPtr = GeoTexCoords2fPtr::dcast(geoPtr->getTexCoords()); 00189 GeoColors3fPtr colorPtr = GeoColors3fPtr::dcast(geoPtr->getColors()); 00190 GeoPLengthsUI32Ptr lensPtr = GeoPLengthsUI32Ptr::dcast(geoPtr->getLengths()); 00191 GeoPTypesUI8Ptr typesPtr = GeoPTypesUI8Ptr::dcast(geoPtr->getTypes()); 00192 00193 // Create color buffer: If Null container AND color is set && we have not potentially added text before 00194 if ((NullFC == colorPtr) && (color != OSG::Color3f(-1,-1,-1)) && 00195 ((NullFC == posPtr) && (NullFC == texPtr)) ) 00196 { 00197 colorPtr = GeoColors3f::create(); 00198 geoPtr->setColors(colorPtr); 00199 } 00200 bool use_colors(NullFC != colorPtr); 00201 00202 if (posPtr == NullFC) 00203 { 00204 posPtr = GeoPositions3f::create(); 00205 geoPtr->setPositions(posPtr); 00206 } 00207 00208 if (normalPtr == NullFC) 00209 { 00210 normalPtr = GeoNormals3f::create(); 00211 geoPtr->setNormals(normalPtr); 00212 } 00213 00214 if (texPtr == NullFC) 00215 { 00216 texPtr = GeoTexCoords2f::create(); 00217 geoPtr->setTexCoords(texPtr); 00218 } 00219 00220 if (lensPtr == NullFC) 00221 { 00222 lensPtr = GeoPLengthsUI32::create(); 00223 geoPtr->setLengths(lensPtr); 00224 } 00225 00226 if (typesPtr == NullFC) 00227 { 00228 typesPtr = GeoPTypesUI8::create(); 00229 geoPtr->setTypes(typesPtr); 00230 } 00231 00232 UInt32 numGlyphs = layoutResult.getNumGlyphs(); 00233 if (numGlyphs == 0) 00234 { 00235 endEditCP(geoPtr); 00236 return; 00237 } 00238 00239 beginEditCP(posPtr, GeoPositions3f::GeoPropDataFieldMask); 00240 beginEditCP(normalPtr, GeoNormals3f::GeoPropDataFieldMask); 00241 beginEditCP(texPtr, GeoTexCoords2f::GeoPropDataFieldMask); 00242 if(NullFC != colorPtr) 00243 { beginEditCP(colorPtr, GeoIndicesUI32::GeoPropDataFieldMask); } 00244 beginEditCP(lensPtr, GeoPLengthsUI32::GeoPropDataFieldMask); 00245 beginEditCP(typesPtr, GeoPTypesUI8::GeoPropDataFieldMask); 00246 00247 OSG::Vec3f normal(0.0, 0.0, 0.0); // normal to use for each glyph 00248 00249 typesPtr->push_back(GL_QUADS); 00250 unsigned num_glyphs_added(0); 00251 00252 for (UInt32 i = 0; i < numGlyphs; ++i) 00253 { 00254 TextGlyph::Index glyphIndex = layoutResult.indices[i]; 00255 const TextTXFGlyph &glyph = getTXFGlyph(glyphIndex); 00256 Real32 width = glyph.getWidth(); 00257 Real32 height = glyph.getHeight(); 00258 // No need to draw invisible glyphs 00259 if ((width <= 0.f) || (height <= 0.f)) 00260 continue; 00261 else 00262 num_glyphs_added += 1; 00263 00264 // Calculate coordinates 00265 Vec2f pos = layoutResult.positions[i]; 00266 Real32 posLeft = (pos.x() * scale) + offset.x(); 00267 Real32 posTop = (pos.y() * scale) + offset.y(); 00268 Real32 posRight = ((pos.x() + width) * scale) + offset.x(); 00269 Real32 posBottom = ((pos.y() - height) * scale) + offset.y(); 00270 00271 // Calculate texture coordinates 00272 Real32 texCoordLeft = glyph.getTexCoord(TextTXFGlyph::COORD_LEFT); 00273 Real32 texCoordTop = glyph.getTexCoord(TextTXFGlyph::COORD_TOP); 00274 Real32 texCoordRight = glyph.getTexCoord(TextTXFGlyph::COORD_RIGHT); 00275 Real32 texCoordBottom = glyph.getTexCoord(TextTXFGlyph::COORD_BOTTOM); 00276 00277 // lower left corner 00278 posPtr->push_back(Vec3f(posLeft, posBottom, 0.f)); 00279 texPtr->push_back(Vec2f(texCoordLeft, texCoordBottom)); 00280 normalPtr->push_back(normal); 00281 if(use_colors) colorPtr->push_back(color); 00282 00283 // lower right corner 00284 posPtr->push_back(Vec3f(posRight, posBottom, 0.f)); 00285 texPtr->push_back(Vec2f(texCoordRight, texCoordBottom)); 00286 normalPtr->push_back(normal); 00287 if(use_colors) colorPtr->push_back(color); 00288 00289 // upper right corner 00290 posPtr->push_back(Vec3f(posRight, posTop, 0.f)); 00291 texPtr->push_back(Vec2f(texCoordRight, texCoordTop)); 00292 normalPtr->push_back(normal); 00293 if(use_colors) colorPtr->push_back(color); 00294 00295 // upper left corner 00296 posPtr->push_back(Vec3f(posLeft, posTop, 0.f)); 00297 texPtr->push_back(Vec2f(texCoordLeft, texCoordTop)); 00298 normalPtr->push_back(normal); 00299 if(use_colors) colorPtr->push_back(color); 00300 } 00301 lensPtr->push_back(num_glyphs_added*4); 00302 00303 endEditCP(typesPtr, GeoPTypesUI8::GeoPropDataFieldMask); 00304 endEditCP(lensPtr, GeoPLengthsUI32::GeoPropDataFieldMask); 00305 endEditCP(texPtr, GeoTexCoords2f::GeoPropDataFieldMask); 00306 endEditCP(normalPtr, GeoNormals3f::GeoPropDataFieldMask); 00307 endEditCP(posPtr, GeoPositions3f::GeoPropDataFieldMask); 00308 if(NullFC != colorPtr) 00309 { endEditCP(colorPtr, GeoIndicesUI32::GeoPropDataFieldMask); } 00310 00311 endEditCP(geoPtr); 00312 }
|
|
||||||||||||||||||||
|
Creates a new text geometry.
Definition at line 319 of file OSGTextTXFFace.cpp. References osg::GeometryBase::create(), and fillGeo(). Referenced by makeNode(). 00321 { 00322 GeometryPtr geo = Geometry::create(); 00323 fillGeo(geo, layoutResult, scale, offset, color); 00324 return geo; 00325 }
|
|
||||||||||||||||||||
|
Creates a new node with a text geometry.
Definition at line 332 of file OSGTextTXFFace.cpp. References osg::beginEditCP(), osg::Node::CoreFieldMask, osg::Node::create(), osg::endEditCP(), and makeGeo(). 00334 { 00335 GeometryPtr geo = makeGeo(layoutResult, scale, offset, color); 00336 NodePtr node = Node::create(); 00337 beginEditCP(node, Node::CoreFieldMask); 00338 node->setCore(geo); 00339 endEditCP(node, Node::CoreFieldMask); 00340 return node; 00341 }
|
|
||||||||||||||||
|
Tries to create a TXF face.
|
|
||||||||||||||||
|
Reads a TXF face from an input stream.
Referenced by osg::SimpleStatisticsForeground::initText(), and osg::GraphicStatisticsForeground::initText(). |
|
|
Reads a TXF face from a file.
|
|
|
Writes a TXF face to an output stream.
|
|
|
Writes a TXF face to a TXF file.
|
|
|
Calculates the positions of the glyphs on the texture Definition at line 792 of file OSGTextTXFFace.cpp. References _glyphMap, _texture, osg::addRefCP(), osg::beginEditCP(), osg::ImageBase::create(), osg::endEditCP(), osg::TextTXFParam::gap, osg::TextTXFGlyph::getPixmapHeight(), osg::TextTXFGlyph::getPixmapWidth(), osg::Image::OSG_I_PF, osg::osgnextpower2(), and osg::TextTXFParam::textureWidth. 00793 { 00794 // Sort characters by height and calculate the area necessary 00795 // to keep all characters 00796 typedef multimap<UInt32, TextTXFGlyph*, greater<UInt32> > HeightMap; 00797 HeightMap heightMap; 00798 UInt32 area = 0, maxWidth = 0; 00799 GlyphMap::iterator gmIt; 00800 for (gmIt = _glyphMap.begin(); gmIt != _glyphMap.end(); ++gmIt) 00801 { 00802 TextTXFGlyph *glyph = gmIt->second; 00803 heightMap.insert(HeightMap::value_type(glyph->getPixmapHeight(), glyph)); 00804 if (maxWidth < glyph->getPixmapWidth()) 00805 maxWidth = glyph->getPixmapWidth(); 00806 area += (glyph->getPixmapWidth() + param.gap) * (glyph->getPixmapHeight() + param.gap); 00807 } 00808 00809 UInt32 textureSize; 00810 if (param.textureWidth == 0) 00811 { 00812 // Try to make a good guess about the optimal width of the texture 00813 textureSize = static_cast<UInt32>(ceil(sqrt(static_cast<Real32>(area)))); 00814 } 00815 else 00816 textureSize = param.textureWidth; 00817 maxWidth += param.gap << 1; 00818 if (textureSize < maxWidth) 00819 textureSize = maxWidth; 00820 UInt32 textureWidth = osgnextpower2(textureSize); 00821 00822 // Calculate the positions of the glyphs in the texture 00823 HeightMap::iterator hmIt = heightMap.begin(); 00824 UInt32 xpos = param.gap, ypos = param.gap, heightOfRow = 0; 00825 while (hmIt != heightMap.end()) 00826 { 00827 HeightMap::iterator hmIt3; 00828 // Does the next glyph fit into the line? 00829 if (xpos + hmIt->second->getPixmapWidth() + param.gap > textureWidth) 00830 { 00831 // No, so lets try to find another glyph 00832 HeightMap::iterator hmIt2 = hmIt; 00833 ++hmIt2; 00834 for (++hmIt2; hmIt2 != heightMap.end(); ++hmIt2) 00835 { 00836 if (xpos + hmIt2->second->getPixmapWidth() + param.gap <= textureWidth) 00837 break; 00838 } 00839 if (hmIt2 == heightMap.end()) 00840 { 00841 // There no other glyph 00842 xpos = param.gap; 00843 ypos += heightOfRow + param.gap; 00844 heightOfRow = 0; 00845 hmIt3 = hmIt; 00846 ++hmIt; 00847 } 00848 else // There is another glyph that fits 00849 hmIt3 = hmIt2; 00850 } 00851 else 00852 { 00853 // Yes, the glyph fits into the line 00854 hmIt3 = hmIt; 00855 ++hmIt; 00856 } 00857 hmIt3->second->_x = xpos; 00858 hmIt3->second->_y = ypos; 00859 xpos += hmIt3->second->getPixmapWidth() + param.gap; 00860 if (hmIt3->second->getPixmapHeight() > heightOfRow) 00861 heightOfRow = hmIt3->second->getPixmapHeight(); 00862 heightMap.erase(hmIt3); 00863 } 00864 ypos += heightOfRow; 00865 00866 // Calculate the height of the texture 00867 UInt32 textureHeight = osgnextpower2(static_cast<UInt32>(ypos)); 00868 00869 // Create the texture 00870 _texture = Image::create(); 00871 addRefCP(_texture); 00872 beginEditCP(_texture); 00873 { 00874 _texture->set(Image::OSG_I_PF, textureWidth, textureHeight); 00875 _texture->clear(); 00876 } 00877 endEditCP(_texture); 00878 00879 // Calculate the coordinates of all glyphs 00880 for (gmIt = _glyphMap.begin(); gmIt != _glyphMap.end(); ++gmIt) 00881 gmIt->second->calculateCoordinates(textureWidth, textureHeight); 00882 }
|
|
|
Copy operator (not implemented!) |
|
|
Returns the actual font family of the face.
Definition at line 43 of file OSGTextFace.inl. References osg::TextFace::_family. 00043 { return _family; }
|
|
|
Returns the actual style of the face.
Definition at line 46 of file OSGTextFace.inl. References osg::TextFace::_style. 00046 { return _style; }
|
|
|
Returns the ascent of the face for horizontal layout. The ascent is the distance from the baseline to the top of the face.
Definition at line 49 of file OSGTextFace.inl. References osg::TextFace::_horiAscent. 00049 { return _horiAscent; }
|
|
|
Returns the ascent of the face for vertical layout. The ascent is the distance from the baseline to the left side of the face. This value is usually negative!
Definition at line 52 of file OSGTextFace.inl. References osg::TextFace::_vertAscent. 00052 { return _vertAscent; }
|
|
|
Returns the descent of the face for horizontal layout. The descent is the distance from the baseline to the bottom of the face. This value is usually negative!
Definition at line 55 of file OSGTextFace.inl. References osg::TextFace::_horiDescent. 00055 { return _horiDescent; }
|
|
|
Returns the descent of the face for vertical layout. The descent is the distance from the baseline to the right side of the face.
Definition at line 58 of file OSGTextFace.inl. References osg::TextFace::_vertDescent. 00058 { return _vertDescent; }
|
|
||||||||||||||||
|
Calculates the bounding box of a text after layout.
Definition at line 243 of file OSGTextFace.cpp. References osg::TextFace::getGlyph(), osg::TextGlyph::getHeight(), osg::TextLayoutResult::getNumGlyphs(), osg::TextGlyph::getWidth(), osg::TextLayoutResult::indices, osg::TextLayoutResult::positions, osg::VecStorage2< ValueTypeT >::setValues(), osg::VecStorage2< ValueTypeT >::x(), and osg::VecStorage2< ValueTypeT >::y(). Referenced by osg::TextPixmapFace::makeImage(). 00244 { 00245 // Initialize bounding box 00246 lowerLeft.setValues(FLT_MAX, FLT_MAX); 00247 upperRight.setValues(-FLT_MAX, -FLT_MAX); 00248 00249 UInt32 i, numGlyphs = layoutResult.getNumGlyphs(); 00250 for (i = 0; i < numGlyphs; ++i) 00251 { 00252 const TextGlyph &glyph = getGlyph(layoutResult.indices[i]); 00253 Real32 width = glyph.getWidth(); 00254 Real32 height = glyph.getHeight(); 00255 // Don't handle invisible glyphs 00256 if ((width <= 0.f) || (height <= 0.f)) 00257 continue; 00258 00259 // Calculate coodinates 00260 const Vec2f &pos = layoutResult.positions[i]; 00261 Real32 left = pos.x(); 00262 Real32 right = left + glyph.getWidth(); 00263 Real32 top = pos.y(); 00264 Real32 bottom = top - glyph.getHeight(); 00265 00266 // Adjust bounding box 00267 if (lowerLeft[0] > left) 00268 lowerLeft[0] = left; 00269 if (upperRight[0] < right) 00270 upperRight[0] = right; 00271 if (upperRight[1] < top) 00272 upperRight[1] = top; 00273 if (lowerLeft[1] > bottom) 00274 lowerLeft[1] = bottom; 00275 } 00276 }
|
|
||||||||||||
|
Converts a UTF8 encoded string to a unicode string.
Referenced by osg::TextTXFParam::setCharacters(). |
|
||||||||||||||||||||
|
Justifies one line of text.
|