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

ufont.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/font/ufont.hpp 00008 begin : Mon Oct 1 2001 00009 $Id: ufont.hpp,v 1.14 2005/07/12 13:29:06 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 UFONT_HPP 00029 #define UFONT_HPP 00030 00031 #include "../uobject.hpp" 00032 00033 #include <map> 00034 00035 #include "ufontinfo.hpp" 00036 #include "ufontrenderer.hpp" 00037 00038 namespace ufo { 00039 00040 class UFontMetrics; 00041 class UDisplay; 00042 00059 class UFO_EXPORT UFont : public UObject { 00060 UFO_DECLARE_DYNAMIC_CLASS(UFont) 00061 public: // Public c'tors 00063 UFont(); 00072 UFont(UFontInfo::Family family, float pointSize, int weight = UFontInfo::Normal, 00073 int style = UFontInfo::Plain, UFontInfo::Encoding encoding = UFontInfo::Encoding_Default); 00081 UFont(const std::string & face, float pointSize, int weight = UFontInfo::Normal, 00082 int style = UFontInfo::Plain, UFontInfo::Encoding encoding = UFontInfo::Encoding_Default); 00087 UFont(const UFontInfo & fontInfo); 00091 UFont(UFontRenderer * renderer); 00092 00094 UFont(const UFont & font); 00095 UFont& operator=(const UFont & font); 00096 00097 virtual ~UFont(); 00098 00099 public: // Public methods 00101 UFontRenderer * getRenderer() const; 00103 const UFontMetrics * getFontMetrics() const; 00104 00108 void setFamiliy(UFontInfo::Family family); 00109 00110 void setFontFace(const std::string & face); 00114 std::string getFontFace() const; 00115 00119 void setPointSize(float pointSize); 00122 float getPointSize() const; 00123 00124 void setWeight(int weight); 00125 int getWeight() const; 00126 00127 void setStyle(int flag); 00132 int getStyle() const; 00133 00138 void setEncoding(UFontInfo::Encoding encoding); 00139 UFontInfo::Encoding getEncoding() const; 00140 00141 public: // Public static methods 00142 static void clearCache(); 00143 00144 protected: // Private methods 00148 void queryAndLoad(const UFontInfo & info); 00150 void dispose(); 00151 00152 private: // Private static attributes 00153 typedef std::map<UFontInfo, UFontRenderer*> fontCache_t; 00154 typedef std::map<UDisplay*, fontCache_t> displayCache_t; 00155 //static fontCache_t sm_fontCache; 00156 static displayCache_t sm_fontCache; 00157 00158 private: // Private attributes 00160 UFontRenderer * m_renderer; 00162 UFontInfo m_infoCache; 00163 }; 00164 00165 } // namespace ufo 00166 00167 #endif // UFONT_HPP

The libUFO Project - written by Johannes Schmidt