From Eric Sokolwsky, "osgText is a useful node kit, but when longer paragraphs are displayed
on the screen, it looks more aesthetically pleasing to have a larger gap between lines than is given by default. I added a new parameter, lineSpacing, in the Text class to allow the line spacing to be adjustable by the application. The default value is 0 meaning there is no extra spacing given. The value should be given as a percentage of the character height. A good value for longer paragraphs is 0.25 (25%) or more."
This commit is contained in:
@@ -39,6 +39,7 @@ Text::Text():
|
||||
_characterSizeMode(OBJECT_COORDS),
|
||||
_maximumWidth(0.0f),
|
||||
_maximumHeight(0.0f),
|
||||
_lineSpacing(0.0f),
|
||||
_alignment(BASE_LINE),
|
||||
_autoRotateToScreen(false),
|
||||
_layout(LEFT_TO_RIGHT),
|
||||
@@ -72,6 +73,7 @@ Text::Text(const Text& text,const osg::CopyOp& copyop):
|
||||
_characterSizeMode(text._characterSizeMode),
|
||||
_maximumWidth(text._maximumWidth),
|
||||
_maximumHeight(text._maximumHeight),
|
||||
_lineSpacing(text._lineSpacing),
|
||||
_text(text._text),
|
||||
_position(text._position),
|
||||
_alignment(text._alignment),
|
||||
@@ -147,6 +149,12 @@ void Text::setMaximumHeight(float maximumHeight)
|
||||
_maximumHeight = maximumHeight;
|
||||
computeGlyphRepresentation();
|
||||
}
|
||||
|
||||
void Text::setLineSpacing(float lineSpacing)
|
||||
{
|
||||
_lineSpacing = lineSpacing;
|
||||
computeGlyphRepresentation();
|
||||
}
|
||||
|
||||
|
||||
void Text::setText(const String& text)
|
||||
@@ -693,7 +701,7 @@ void Text::computeGlyphRepresentation()
|
||||
{
|
||||
case LEFT_TO_RIGHT:
|
||||
{
|
||||
startOfLine_coords.y() -= _characterHeight;
|
||||
startOfLine_coords.y() -= _characterHeight * (1.0 + _lineSpacing);
|
||||
cursor = startOfLine_coords;
|
||||
previous_charcode = 0;
|
||||
_lineCount++;
|
||||
@@ -701,7 +709,7 @@ void Text::computeGlyphRepresentation()
|
||||
}
|
||||
case RIGHT_TO_LEFT:
|
||||
{
|
||||
startOfLine_coords.y() -= _characterHeight;
|
||||
startOfLine_coords.y() -= _characterHeight * (1.0 + _lineSpacing);
|
||||
cursor = startOfLine_coords;
|
||||
previous_charcode = 0;
|
||||
_lineCount++;
|
||||
@@ -709,7 +717,7 @@ void Text::computeGlyphRepresentation()
|
||||
}
|
||||
case VERTICAL:
|
||||
{
|
||||
startOfLine_coords.x() += _characterHeight/_characterAspectRatio;
|
||||
startOfLine_coords.x() += _characterHeight/_characterAspectRatio * (1.0 + _lineSpacing);
|
||||
cursor = startOfLine_coords;
|
||||
previous_charcode = 0;
|
||||
// because _lineCount is the max vertical no. of characters....
|
||||
|
||||
Reference in New Issue
Block a user