From bee545b82d6e406561d136e44325b760b2b78dc2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 2 Feb 2007 16:51:59 +0000 Subject: [PATCH] From Eric Sokolowski, added support for the new Text line spacing parameter to the .osg and .ive formats. --- examples/osgtext/osgtext.cpp | 2 ++ src/osgPlugins/ive/IveVersion.h | 3 ++- src/osgPlugins/ive/Text.cpp | 8 ++++++++ src/osgPlugins/osgText/IO_Text.cpp | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/examples/osgtext/osgtext.cpp b/examples/osgtext/osgtext.cpp index a2ae3d752..67713cb67 100644 --- a/examples/osgtext/osgtext.cpp +++ b/examples/osgtext/osgtext.cpp @@ -501,6 +501,8 @@ int main(int , char **) viewer.setSceneData(group); } + osgDB::writeNodeFile(*viewer.getSceneData(),"text.osg"); + return viewer.run(); } diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index 951cc0c42..6fdabbe35 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -28,8 +28,9 @@ #define VERSION_0017 17 #define VERSION_0018 18 #define VERSION_0019 19 +#define VERSION_0020 20 -#define VERSION VERSION_0019 +#define VERSION VERSION_0020 /* The BYTE_SEX tag is used to check the endian of the IVE file being read in. The IVE format diff --git a/src/osgPlugins/ive/Text.cpp b/src/osgPlugins/ive/Text.cpp index cebed1174..66de59743 100644 --- a/src/osgPlugins/ive/Text.cpp +++ b/src/osgPlugins/ive/Text.cpp @@ -62,6 +62,9 @@ void Text::write(DataOutputStream* out){ out->writeUInt(getCharacterSizeMode()); out->writeFloat(getMaximumWidth()); out->writeFloat(getMaximumHeight()); + + out->writeFloat(getLineSpacing()); + out->writeUInt(getAlignment()); out->writeQuat(getRotation()); //FIXME: controllare che ci sia @@ -151,6 +154,11 @@ void Text::read(DataInputStream* in){ setMaximumWidth(in->readFloat()); setMaximumHeight(in->readFloat()); + if ( in->getVersion() >= VERSION_0020 ) + { + setLineSpacing(in->readFloat()); + } + setAlignment((osgText::Text::AlignmentType) in->readUInt()); //Nothing to do... diff --git a/src/osgPlugins/osgText/IO_Text.cpp b/src/osgPlugins/osgText/IO_Text.cpp index f14c9c1a1..c1e37f7e7 100644 --- a/src/osgPlugins/osgText/IO_Text.cpp +++ b/src/osgPlugins/osgText/IO_Text.cpp @@ -94,6 +94,17 @@ bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr) } } + if (fr[0].matchWord("lineSpacing")) + { + float height; + if (fr[1].getFloat(height)) + { + text.setLineSpacing(height); + fr += 2; + itAdvanced = true; + } + } + if (fr.matchSequence("alignment %w")) { std::string str = fr[1].getStr(); @@ -278,6 +289,11 @@ bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw) { fw.indent() << "maximumHeight " << text.getMaximumHeight() << std::endl; } + + if (text.getLineSpacing()>0.0f) + { + fw.indent() << "lineSpacing " << text.getLineSpacing() << std::endl; + } // alignment fw.indent() << "alignment ";