Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGTextFace.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
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     /*==========================  PUBLIC  =================================*/
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 &param,
00141                         TextLayoutResult &result);
00142 
00149     virtual void layout(const std::wstring &text, 
00150                         const TextLayoutParam &param,
00151                         TextLayoutResult &result) = 0;
00152 
00159     virtual void layout(const std::vector<std::string> &lines, 
00160                         const TextLayoutParam &param,
00161                         TextLayoutResult &result);
00162 
00169     virtual void layout(const std::vector<std::wstring> &lines,
00170                         const TextLayoutParam &param,
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     /*=========================  PROTECTED  ===============================*/
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 &param,
00228                      const std::vector<UInt32> &spaceIndices,
00229                      Vec2f &currPos, TextLayoutResult &layoutResult) const;
00230 
00239     void adjustLineOrigin(const TextLayoutParam &param,
00240                           const Vec2f &currPos,
00241                           TextLayoutResult &layoutResult) const;
00242 
00243     /*==========================  PRIVATE  ================================*/
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 /* _OSGTEXTFACE_H_ */

Generated on Thu Aug 25 04:11:18 2005 for OpenSG by  doxygen 1.4.3