Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

font.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: font.h,v 1.5 2004/03/04 16:11:56 rollmark Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 #ifndef KEROSIN_FONT_H
00023 #define KEROSIN_FONT_H
00024 
00025 #include <string>
00026 #include <salt/vector.h>
00027 #include "glyph.h"
00028 
00029 namespace kerosin
00030 {
00031 
00032 class FontServer;
00033 
00063 class Font
00064 {
00065 private:
00066     struct GlyphMetric
00067     {
00068         unsigned int   mByteWidth;
00069         unsigned int   mByteHeight;
00070         unsigned int   mXOffset;
00071         unsigned int   mYOffset;
00072         unsigned int   mAdvance;
00073         salt::Vector2f mTC1;
00074         salt::Vector2f mTC2;
00075     };
00076 public:
00077     Font(FontServer &fontServer);
00078     ~Font();
00079 
00080     bool    Init(const std::string &name, unsigned int size, FT_Face face);
00081     bool    Bind(int vRows = -1);
00082     void    Dump();
00083     void    DrawString(float x, float y, const char *string);
00084     void    Printf(float x, float y, const char *format, ...);
00085     void    RowPrintf(float x, float row, const char *format, ...);
00086 
00093     float   GetStringWidth(const char* string, int numChar = -1);
00094 
00096     float GetRowHeight();
00097 
00099     const std::string& GetName() const;
00100 
00102     unsigned int GetSize() const;
00103 
00104 private:
00106     GlyphMetric  mMetrics[96];
00107 
00109     unsigned int mTexID;
00110 
00112     unsigned int mRowHeight;
00113 
00115     std::string mName;
00116 
00118     unsigned int mSize;
00119 
00121     FontServer& mFontServer;
00122 };
00123 
00124 } // namespace kerosin
00125 
00126 #endif //KEROSIN_FONT_H

Generated on Thu Apr 6 15:25:37 2006 for rcssserver3d by  doxygen 1.4.4