- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

ugl_builtinfontrenderer.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/gl/ugl_builtinfontrenderer.hpp 00008 begin : Sat Jun 5 2004 00009 $Id: ugl_builtinfontrenderer.hpp,v 1.7 2005/09/04 14:52:12 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UGL_BUILTINFONTRENDERER_HPP 00029 #define UGL_BUILTINFONTRENDERER_HPP 00030 00031 #include "../font/ufontrenderer.hpp" 00032 00033 #include <vector> 00034 00035 #include "../font/ufontinfo.hpp" 00036 #include "../font/ufontmetrics.hpp" 00037 00038 00039 namespace ufo { 00040 00041 class UImageIO; 00042 00043 class UFontPlugin; 00044 class UPluginBase; 00045 class UGL_BuiltinFontMetrics; 00046 00047 // damn ms vc6 00048 struct UBuiltinFontStruct { 00049 const char * m_systemName; 00050 int m_ascent; 00051 int m_descent; 00052 int m_maxAscent; 00053 int m_maxDescent; 00054 int m_maxWidth; 00055 const uint8_t ** m_characters; 00056 }; 00057 00058 extern const UBuiltinFontStruct s_font_fixed8x13; 00059 //extern UBuiltinFontStruct s_font_fixed9x15; 00060 extern const UBuiltinFontStruct s_font_helvetica10; 00061 extern const UBuiltinFontStruct s_font_helvetica12; 00062 //extern UBuiltinFontStruct s_font_helvetica18; 00063 extern const UBuiltinFontStruct s_font_timesRoman10; 00064 //extern UBuiltinFontStruct s_font_timesRoman24; 00065 00066 00076 class UFO_EXPORT UGL_BuiltinFontRenderer : public UFontRenderer { 00077 UFO_DECLARE_ABSTRACT_CLASS(UGL_BuiltinFontRenderer) 00078 private: 00079 friend class UGL_BuiltinFontMetrics; 00080 public: 00084 UGL_BuiltinFontRenderer(const UFontInfo & fontInfo); 00085 ~UGL_BuiltinFontRenderer(); 00086 00087 public: // Implements UFontRenderer 00088 int drawString(UGraphics * g, const char * text, unsigned int nChar, 00089 int xA = 0, int yA = 0); 00090 00091 void beginDrawing(UGraphics * g); 00092 void endDrawing(UGraphics * g); 00093 00094 void refresh(); 00095 00096 const UFontMetrics * getFontMetrics() const; 00097 00098 UFontInfo getFontInfo() const; 00099 00100 std::string getSystemName() const; 00101 00102 public: // 00103 UBuiltinFontStruct getFontStruct() const; 00104 00105 private: // Private methods 00106 void createTexture(UImageIO * imageIO); 00107 UImageIO * loadImageFile(); 00108 void genGlyphMetrics(UImageIO * imageIO); 00109 00110 public: // plugin methods 00111 static UPluginBase * createPlugin(); 00112 static void destroyPlugin(UPluginBase * plugin); 00113 00114 private: // Private attributes 00115 UFontInfo m_fontInfo; 00116 UGL_BuiltinFontMetrics * m_fontMetrics; 00117 00118 UBuiltinFontStruct m_fontStruct; 00120 float m_xorig; 00122 float m_yorig; 00123 00124 float m_raster_position[4]; 00125 }; // UGL_BuiltinFontRenderer 00126 00127 } // namespac ufo 00128 00129 #endif // UGL_BUILTINFONTRENDERER_HPP

The libUFO Project - written by Johannes Schmidt