Gizmo3D

gzFont.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File         : gzFont.h
00003 // Module       : 
00004 // Description  : Class definition of the gzFont class
00005 // Author       : Anders Modén      
00006 // Product      : Gizmo3D 2.1.1
00007 //      
00008 // Copyright © 2003- Saab Training Systems AB, Sweden
00009 //          
00010 // NOTE:    Gizmo3D is a high performance 3D Scene Graph and effect visualisation 
00011 //          C++ toolkit for Linux, Mac OS X, Windows (Win32) and IRIX® for  
00012 //          usage in Game or VisSim development.
00013 //
00014 //
00015 // Revision History...                          
00016 //                                  
00017 // Who  Date    Description                     
00018 //                                  
00019 // AMO  001016  Created file    
00020 //
00021 //******************************************************************************
00022 #ifndef __GZ_FONT_H__
00023 #define __GZ_FONT_H__
00024 
00031 #include "gzObject.h"
00032 #include "gzDisplayList.h"
00033 
00034 const gzString  GZ_FONT_DEFAULT_NAME        =   "courier";
00035 const gzInt     GZ_FONT_DEFAULT_COUNT       =   256;
00036 const gzInt     GZ_FONT_DEFAULT_HEIGHT      =   11;
00037 const gzInt     GZ_FONT_DEFAULT_WIDTH       =   0;
00038 
00039 // Built in fonts
00040 
00041 #define GZ_FONT_ARIAL_24            "arial",256,24,0,FALSE,FALSE,FALSE,FALSE,TRUE
00042 #define GZ_FONT_ARIAL_24_UNDERLINE  "arial",256,24,0,FALSE,FALSE,TRUE,FALSE,TRUE
00043 #define GZ_FONT_ARIAL_24_BOLD       "arial",256,24,0,FALSE,TRUE,FALSE,FALSE,TRUE
00044 #define GZ_FONT_ARIAL_24_ITALIC     "arial",256,24,0,TRUE,FALSE,FALSE,FALSE,TRUE
00045 
00046 #define GZ_FONT_DOM_CASUAL_24       "dom casual",256,24,0,FALSE,FALSE,FALSE,FALSE,TRUE
00047 #define GZ_FONT_SYMBOL_24           "symbol",256,24,0,FALSE,FALSE,FALSE,FALSE,TRUE
00048 #define GZ_FONT_PALACE_SRIPT_24     "palace script mt",256,24,0,FALSE,FALSE,FALSE,FALSE,TRUE
00049 
00050 class GZ_GRAPH_EXPORT gzFontInfo 
00051 {
00052 public:
00053 
00054     gzFontInfo( const gzString &    fontName        = GZ_FONT_DEFAULT_NAME , 
00055                 const gzUShort      characterCount  = GZ_FONT_DEFAULT_COUNT,
00056                 const gzInt         genericHeight   = GZ_FONT_DEFAULT_HEIGHT,
00057                 const gzInt         genericWidth    = GZ_FONT_DEFAULT_WIDTH,
00058                 gzBool              italic          = FALSE,
00059                 gzBool              bold            = FALSE,
00060                 gzBool              underline       = FALSE,
00061                 gzBool              strikeout       = FALSE,
00062                 gzBool              antialias       = FALSE ); 
00063 
00064     gzBool operator ==(const gzFontInfo &) const;
00065 
00066     gzULong hash() const ;
00067 
00068     //--- public attributes -------------------
00069 
00070     gzString    fontName;
00071     gzUShort    characterCount;
00072     gzInt       genericHeight;
00073     gzInt       genericWidth;
00074     gzInt       completeHeight;
00075 
00076     gzBool      italic;
00077     gzBool      bold;
00078     gzBool      underline;
00079     gzBool      strikeout;
00080     gzBool      antialias;
00081 };
00082 
00083 class GZ_GRAPH_EXPORT gzGlyphInfo 
00084 {
00085 public:
00086 
00087     gzGlyphInfo(gzFloat sizeX=0,gzFloat sizeY=0,gzFloat offsetX=0,gzFloat offsetY=0,gzFloat stepX=0,gzFloat stepY=0,gzFloat originX=0,gzFloat originY=0);
00088 
00089     gzFloat size_x;
00090     gzFloat size_y;
00091 
00092     gzFloat offset_x;
00093     gzFloat offset_y;
00094 
00095     gzFloat step_x;
00096     gzFloat step_y;
00097 
00098     gzFloat origin_x;
00099     gzFloat origin_y;
00100 };
00101 
00102 
00103 //******************************************************************************
00104 // Class    : gzFont
00105 //                                  
00106 // Purpose  : -
00107 //                                  
00108 // Notes    : - 
00109 //                                  
00110 // Revision History...                          
00111 //                                  
00112 // Who  Date    Description                     
00113 //                                  
00114 // AMO  001016  Created 
00115 //                                  
00116 //******************************************************************************
00117 class gzFont : public gzObject , public gzNameInterface
00118 {
00119 public:
00120     GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);  // typed interface
00121 
00122     GZ_GRAPH_EXPORT gzFont( const gzFontInfo & fontInfo=gzFontInfo() , gzBool createFromSystem=TRUE);
00123 
00124     GZ_GRAPH_EXPORT virtual ~gzFont();
00125 
00126     // ---------- Clone interface ---------------------------------------
00127     GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00128     GZ_GRAPH_EXPORT virtual gzBool  useDeepCopy();
00129 
00130     // ---------- Font interface ----------------------------------------
00131 
00132     GZ_GRAPH_EXPORT virtual gzVoid renderChar( gzContext *context , gzUShort index,gzFloat x,gzFloat y,gzFloat z);
00133 
00134     GZ_GRAPH_EXPORT virtual gzVoid beginRenderText(gzContext *context);
00135 
00136     GZ_GRAPH_EXPORT virtual gzVoid endRenderText(gzContext *context);
00137 
00138     GZ_GRAPH_EXPORT gzVec2      getSize( gzUShort index );
00139 
00140     GZ_GRAPH_EXPORT gzVec2      getStep( gzUShort index );
00141 
00142     GZ_GRAPH_EXPORT gzUShort    getCharacterCount();
00143 
00144     GZ_GRAPH_EXPORT gzFloat     getRowHeight();
00145 
00146     GZ_GRAPH_EXPORT gzFloat     getBaseOffset();
00147 
00148     GZ_GRAPH_EXPORT gzFontInfo  getFontInfo();
00149 
00150     GZ_GRAPH_EXPORT gzVoid      disposeImageData();
00151 
00152     // ---------- Global fonts ------------------------------------------
00153 
00154     GZ_GRAPH_EXPORT static gzFont *getFont( const gzFontInfo & fontInfo=gzFontInfo() , gzBool useBuiltIn=TRUE);
00155 
00156     GZ_GRAPH_EXPORT static gzVoid setFont(  const gzFontInfo & fontInfo , gzFont *font);
00157 
00158     GZ_GRAPH_EXPORT static gzVoid clearFontDictionary();
00159 
00160     // ---------- Serializing -------------------------------------------
00161 
00162     GZ_GRAPH_EXPORT virtual gzVoid  write(gzSerializeAdapter *adapter);
00163     GZ_GRAPH_EXPORT virtual gzVoid  read(gzSerializeAdapter *adapter);
00164     GZ_GRAPH_EXPORT virtual gzULong getDataSize(gzSerializeAdapter *adapter=NULL) const;
00165 
00166     // ---------- properties --------------------------------------------
00167 
00168     GZ_PROPERTY_EXPORT(gzTexturePtr,    FontTexture,    GZ_GRAPH_EXPORT);
00169 
00170 protected:
00171 
00172     gzArray<gzGlyphInfo>                        m_fontItems;
00173 
00174     gzFontInfo                                  m_fontInfo;
00175 
00176     gzULong                                     m_texWidth;
00177 
00178     gzULong                                     m_texHeight;
00179 
00180     gzFloat                                     m_baseOffset;
00181     
00182 private:
00183 
00184     static gzRefDict<gzFontInfo,gzFont>         s_fontDictionary;
00185     
00186 };
00187 
00188 
00189 #endif

Documentation for Gizmo3D generated at Wed Feb 20 11:54:04 2008 by   Saab Training Systems AB, ¸ (c) 2003-and beyond