00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSGTEXTTXFFACE_H_
00040 #define _OSGTEXTTXFFACE_H_
00041
00042 #ifdef _MSC_VER
00043 # pragma once
00044 #endif
00045
00046
00047 #include <OSGConfig.h>
00048 #include <OSGSystemDef.h>
00049 #include <OSGBaseTypes.h>
00050 #include <OSGGeometry.h>
00051 #include <OSGNode.h>
00052 #include <OSGImage.h>
00053
00054 #include "OSGTextFace.h"
00055 #include "OSGTextGlyph.h"
00056 #include "OSGTextTXFParam.h"
00057
00058 #include <string>
00059 #include <map>
00060 #include <iosfwd>
00061
00062
00063 OSG_BEGIN_NAMESPACE
00064
00065
00066 class TextTXFGlyph;
00067 class TextLayoutParam;
00068 class TextLayoutResult;
00069
00070
00120 class OSG_SYSTEMLIB_DLLMAPPING TextTXFFace: public TextFace
00121 {
00122
00123 public:
00124
00129 inline Real32 getScale() const;
00130
00135 inline const TextTXFParam &getParam() const;
00136
00142 inline ImagePtr getTexture() const;
00143
00150 virtual const TextGlyph &getGlyph(TextGlyph::Index glyphIndex);
00151
00158 const TextTXFGlyph &getTXFGlyph(TextGlyph::Index glyphIndex);
00159
00166 virtual void layout(const std::string &utf8Text,
00167 const TextLayoutParam ¶m,
00168 TextLayoutResult &result);
00169
00176 virtual void layout(const std::wstring &text,
00177 const TextLayoutParam ¶m,
00178 TextLayoutResult &result);
00179
00186 virtual void layout(const std::vector<std::string> &lines,
00187 const TextLayoutParam ¶m,
00188 TextLayoutResult &result);
00189
00196 virtual void layout(const std::vector<std::wstring> &lines,
00197 const TextLayoutParam ¶m,
00198 TextLayoutResult &result);
00199
00208 void fillGeo(GeometryPtr &geoPtr, const TextLayoutResult &layoutResult, Real32 scale = 1.f,
00209 Vec2f offset = Vec2f(0,0), Color3f color = Color3f(-1,-1,-1));
00210
00220 void addToGeom(GeometryPtr &geoPtr, const TextLayoutResult &layoutResult, Real32 scale = 1.f,
00221 Vec2f offset = Vec2f(0,0), Color3f color = Color3f(-1,-1,-1));
00222
00231 GeometryPtr makeGeo(const TextLayoutResult &layoutResult, Real32 scale = 1.f,
00232 Vec2f offset = Vec2f(0,0), Color3f color = Color3f(-1,-1,-1));
00233
00242 NodePtr makeNode(const TextLayoutResult &layoutResult, Real32 scale = 1.f,
00243 Vec2f offset = Vec2f(0,0), Color3f color = Color3f(-1,-1,-1));
00244
00253 static TextTXFFace *create(const std::string &family, Style style = STYLE_PLAIN,
00254 const TextTXFParam ¶m = TextTXFParam());
00255
00261 static TextTXFFace *createFromStream(std::istream &is,
00262 const std::string &family = std::string(),
00263 Style style = STYLE_PLAIN);
00264
00270 static TextTXFFace *createFromFile(const std::string &filename);
00271
00277 bool writeToStream(std::ostream &os) const;
00278
00284 bool writeToFile(const std::string &filename) const;
00285
00286
00287 protected:
00288
00290 inline TextTXFFace();
00291
00293 virtual ~TextTXFFace();
00294
00296 void prepareTexture(const TextTXFParam ¶m);
00297
00299 Real32 _scale;
00300
00302 TextTXFParam _param;
00303
00305 ImagePtr _texture;
00306
00308 typedef std::map<TextGlyph::Index, TextTXFGlyph*> GlyphMap;
00309
00311 GlyphMap _glyphMap;
00312
00313
00314 private:
00315
00317 TextTXFFace(const TextTXFFace &);
00318
00320 const TextTXFFace &operator=(const TextTXFFace &);
00321
00323 static TextTXFGlyph _emptyGlyph;
00324 };
00325
00326
00327 OSG_END_NAMESPACE
00328
00329
00330 #include <OSGTextTXFFace.inl>
00331
00332 #define OSGTEXTTXFFACE_HEADER_CVSID "@(#)$Id: OSGTextTXFFace.h,v 1.4 2005/07/05 16:25:15 dirk Exp $"
00333
00334 #endif