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 _OSGTEXTFACE_H_
00040 #define _OSGTEXTFACE_H_
00041
00042 #ifdef _MSC_VER
00043 # pragma once
00044 #endif
00045
00046 #include <OSGConfig.h>
00047 #include <OSGSystemDef.h>
00048 #include <OSGBaseTypes.h>
00049 #include <OSGVector.h>
00050 #include <OSGMemoryObject.h>
00051
00052 #include "OSGTextGlyph.h"
00053
00054 #include <string>
00055 #include <vector>
00056
00057
00058 OSG_BEGIN_NAMESPACE
00059
00060
00061 class TextLayoutParam;
00062 class TextLayoutResult;
00063
00064
00069 class OSG_SYSTEMLIB_DLLMAPPING TextFace: public MemoryObject
00070 {
00071
00072 public:
00073
00075 enum Style
00076 {
00077 STYLE_PLAIN,
00078 STYLE_BOLD,
00079 STYLE_ITALIC,
00080 STYLE_BOLDITALIC
00081 };
00082
00087 inline const std::string getFamily() const;
00088
00093 inline Style getStyle() const;
00094
00100 inline Real32 getHoriAscent() const;
00101
00108 inline Real32 getVertAscent() const;
00109
00116 inline Real32 getHoriDescent() const;
00117
00123 inline Real32 getVertDescent() const;
00124
00131 virtual const TextGlyph &getGlyph(TextGlyph::Index glyphIndex) = 0;
00132
00139 virtual void layout(const std::string &utf8Text,
00140 const TextLayoutParam ¶m,
00141 TextLayoutResult &result);
00142
00149 virtual void layout(const std::wstring &text,
00150 const TextLayoutParam ¶m,
00151 TextLayoutResult &result) = 0;
00152
00159 virtual void layout(const std::vector<std::string> &lines,
00160 const TextLayoutParam ¶m,
00161 TextLayoutResult &result);
00162
00169 virtual void layout(const std::vector<std::wstring> &lines,
00170 const TextLayoutParam ¶m,
00171 TextLayoutResult &result);
00172
00181 void calculateBoundingBox(const TextLayoutResult &layoutResult, Vec2f &lowerLeft, Vec2f &upperRight);
00182
00189 static void convertUTF8ToUnicode(const std::string &utf8Text, std::wstring &text);
00190
00191
00192 protected:
00193
00195 inline TextFace();
00196
00198 virtual ~TextFace();
00199
00201 std::string _family;
00202
00204 Style _style;
00205
00207 Real32 _horiAscent;
00208
00210 Real32 _vertAscent;
00211
00213 Real32 _horiDescent;
00214
00216 Real32 _vertDescent;
00217
00227 void justifyLine(const TextLayoutParam ¶m,
00228 const std::vector<UInt32> &spaceIndices,
00229 Vec2f &currPos, TextLayoutResult &layoutResult) const;
00230
00239 void adjustLineOrigin(const TextLayoutParam ¶m,
00240 const Vec2f &currPos,
00241 TextLayoutResult &layoutResult) const;
00242
00243
00244 private:
00245
00247 TextFace(const TextFace &);
00248
00250 const TextFace &operator=(const TextFace &);
00251 };
00252
00253
00254 OSG_END_NAMESPACE
00255
00256
00257 #include <OSGTextFace.inl>
00258
00259 #define OSGTEXTFACE_HEADER_CVSID "@(#)$Id: OSGTextFace.h,v 1.1 2005/03/03 13:43:06 a-m-z Exp $"
00260
00261 #endif