#include <OSGTextFace.h>
Inheritance diagram for osg::TextFace:

Public Types | |
| enum | Style { STYLE_PLAIN, STYLE_BOLD, STYLE_ITALIC, STYLE_BOLDITALIC } |
Public Member Functions | |
| const std::string | getFamily () const |
| Style | getStyle () const |
| Real32 | getHoriAscent () const |
| Real32 | getVertAscent () const |
| Real32 | getHoriDescent () const |
| Real32 | getVertDescent () const |
| virtual const TextGlyph & | getGlyph (TextGlyph::Index glyphIndex)=0 |
| virtual void | layout (const std::string &utf8Text, const TextLayoutParam ¶m, TextLayoutResult &result) |
| virtual void | layout (const std::wstring &text, const TextLayoutParam ¶m, TextLayoutResult &result)=0 |
| 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 | calculateBoundingBox (const TextLayoutResult &layoutResult, Vec2f &lowerLeft, Vec2f &upperRight) |
Reference Counting | |
| *void | addRef (void) |
| void | subRef (void) |
| Int32 | getRefCount (void) |
Static Public Member Functions | |
| static void | convertUTF8ToUnicode (const std::string &utf8Text, std::wstring &text) |
Protected Member Functions | |
| TextFace () | |
| virtual | ~TextFace () |
| 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 | |
| std::string | _family |
| Style | _style |
| Real32 | _horiAscent |
| Real32 | _vertAscent |
| Real32 | _horiDescent |
| Real32 | _vertDescent |
Private Member Functions | |
| TextFace (const TextFace &) | |
| const TextFace & | operator= (const TextFace &) |
Definition at line 69 of file OSGTextFace.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 TextFace object. Definition at line 61 of file OSGTextFace.inl. 00062 : _family(), _style(STYLE_PLAIN), 00063 _horiAscent(0.f), _vertAscent(0.f), 00064 _horiDescent(0.f), _vertDescent(0.f) 00065 {}
|
|
|
Destroys the TextFace object. Definition at line 65 of file OSGTextFace.cpp.
|
|
|
Copy constructor (not implemented!) |
|
|
Returns the actual font family of the face.
Definition at line 43 of file OSGTextFace.inl. References _family. 00043 { return _family; }
|
|
|
Returns the actual style of the face.
Definition at line 46 of file OSGTextFace.inl. References _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 _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 _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 _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 _vertDescent. 00058 { return _vertDescent; }
|
|
|
Returns information about a glyph.
Implemented in osg::TextPixmapFace, osg::TextTXFFace, and osg::TextVectorFace. Referenced by calculateBoundingBox(). |
|
||||||||||||||||
|
Lays out one line of text.
Reimplemented in osg::TextTXFFace. |
|
||||||||||||||||
|
Lays out one line of text.
Implemented in osg::TextTXFFace. |
|
||||||||||||||||
|
Lays out multiple lines of text.
Reimplemented in osg::TextTXFFace. |
|
||||||||||||||||
|
Lays out multiple lines of text.
Reimplemented in osg::TextTXFFace. |
|
||||||||||||||||
|
Calculates the bounding box of a text after layout.
Definition at line 243 of file OSGTextFace.cpp. References 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.
|
|
||||||||||||||||
|
Adjusts the positions of glyphs, depending on the alignment.
Definition at line 402 of file OSGTextFace.cpp. References _horiAscent, _vertDescent, osg::TextLayoutParam::ALIGN_BEGIN, osg::TextLayoutParam::ALIGN_END, osg::TextLayoutParam::ALIGN_FIRST, osg::TextLayoutParam::ALIGN_MIDDLE, osg::TextLayoutParam::horizontal, osg::TextLayoutParam::leftToRight, osg::TextLayoutParam::majorAlignment, osg::TextLayoutParam::minorAlignment, osg::TextLayoutResult::positions, osg::TextLayoutParam::topToBottom, osg::VecStorage2< ValueTypeT >::x(), and osg::VecStorage2< ValueTypeT >::y(). 00405 { 00406 Vec2f offset; 00407 if (param.horizontal == true) 00408 { 00409 switch (param.minorAlignment) 00410 { 00411 default: 00412 case TextLayoutParam::ALIGN_FIRST: offset[1] = 0.f; break; 00413 case TextLayoutParam::ALIGN_BEGIN: offset[1] = -_horiAscent; break; 00414 case TextLayoutParam::ALIGN_MIDDLE: offset[1] = -(_horiAscent + _horiDescent) / 2.f; break; 00415 case TextLayoutParam::ALIGN_END: offset[1] = -_horiDescent; break; 00416 } 00417 if (param.leftToRight == true) 00418 { 00419 switch (param.majorAlignment) 00420 { 00421 default: 00422 case TextLayoutParam::ALIGN_FIRST: 00423 case TextLayoutParam::ALIGN_BEGIN: 00424 if (currPos.x() < 0) 00425 offset[0] = -currPos.x(); 00426 break; 00427 case TextLayoutParam::ALIGN_MIDDLE: 00428 offset[0] = -currPos.x() / 2.f; 00429 break; 00430 case TextLayoutParam::ALIGN_END: 00431 if (currPos.x() > 0) 00432 offset[0] = -currPos.x(); 00433 break; 00434 } 00435 } 00436 else // leftToRight == false 00437 { 00438 switch (param.majorAlignment) 00439 { 00440 default: 00441 case TextLayoutParam::ALIGN_FIRST: 00442 case TextLayoutParam::ALIGN_BEGIN: 00443 if (currPos.x() > 0) 00444 offset[0] = -currPos.x(); 00445 break; 00446 case TextLayoutParam::ALIGN_MIDDLE: 00447 offset[0] = -currPos.x() / 2.f; 00448 break; 00449 case TextLayoutParam::ALIGN_END: 00450 if (currPos.x() < 0) 00451 offset[0] = -currPos.x(); 00452 break; 00453 } 00454 } 00455 } 00456 else // param.horizontal == false 00457 { 00458 switch (param.minorAlignment) 00459 { 00460 default: 00461 case TextLayoutParam::ALIGN_FIRST: offset[0] = 0.f; break; 00462 case TextLayoutParam::ALIGN_BEGIN: offset[0] = -_vertAscent; break; 00463 case TextLayoutParam::ALIGN_MIDDLE: offset[0] = -(_vertAscent + _vertDescent) / 2.f; break; 00464 case TextLayoutParam::ALIGN_END: offset[0] = -_vertDescent; break; 00465 } 00466 if (param.topToBottom == true) 00467 { 00468 switch (param.majorAlignment) 00469 { 00470 default: 00471 case TextLayoutParam::ALIGN_FIRST: 00472 case TextLayoutParam::ALIGN_BEGIN: 00473 if (currPos.y() > 0) 00474 offset[1] = -currPos.y(); 00475 break; 00476 case TextLayoutParam::ALIGN_MIDDLE: 00477 offset[1] = -currPos.y() / 2.f; 00478 break; 00479 case TextLayoutParam::ALIGN_END: 00480 if (currPos.y() < 0) 00481 offset[1] = -currPos.y(); 00482 break; 00483 } 00484 } 00485 else // TopToBottom == false 00486 { 00487 switch (param.majorAlignment) 00488 { 00489 default: 00490 case TextLayoutParam::ALIGN_FIRST: 00491 case TextLayoutParam::ALIGN_BEGIN: 00492 if (currPos.y() < 0) 00493 offset[1] = -currPos.y(); 00494 break; 00495 case TextLayoutParam::ALIGN_MIDDLE: 00496 offset[1] = -currPos.y() / 2.f; 00497 break; 00498 case TextLayoutParam::ALIGN_END: 00499 if (currPos.y() > 0) 00500 offset[1] = -currPos.y(); 00501 break; 00502 } 00503 } 00504 } 00505 00506 // Adjust all glyph positions 00507 if ((offset.x() != 0.f) || (offset.y() != 0.f)) 00508 { 00509 vector<Vec2f>::iterator it; 00510 for (it = layoutResult.positions.begin(); it != layoutResult.positions.end(); ++it) 00511 *it += offset; 00512 } 00513 }
|
|
|
Copy operator (not implemented!) |
|
|
Definition at line 64 of file OSGMemoryObject.cpp. References osg::MemoryObject::_refCount. Referenced by osg::SharedObjectHandler::getSharedObject(), and osg::SharedObjectHandler::initialize(). 00065 { 00066 _refCount++; 00067 }
|
|
|
Definition at line 69 of file OSGMemoryObject.cpp. References osg::MemoryObject::_refCount.
|
|
|
Definition at line 77 of file OSGMemoryObject.cpp. References osg::MemoryObject::_refCount. 00078 { 00079 return _refCount; 00080 }
|
|
|
The font family of the face Definition at line 201 of file OSGTextFace.h. Referenced by getFamily(). |
|
|
The style of the face Definition at line 204 of file OSGTextFace.h. Referenced by getStyle(). |
|
|
The ascent of the font for horizontal layout Definition at line 207 of file OSGTextFace.h. Referenced by adjustLineOrigin(), and getHoriAscent(). |
|
|
The ascent of the font for vertical layout Definition at line 210 of file OSGTextFace.h. Referenced by getVertAscent(). |
|
|
The descent of the font for horizontal layout Definition at line 213 of file OSGTextFace.h. Referenced by getHoriDescent(). |
|
|
The descent of the font for vertical layout Definition at line 216 of file OSGTextFace.h. Referenced by adjustLineOrigin(), and getVertDescent(). |
1.4.3