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

ufontinfo.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/ufontinfo.hpp 00008 begin : Sat May 3 2003 00009 $Id: ufontinfo.hpp,v 1.6 2005/05/21 15:17:23 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 UFONTINFO_HPP 00029 #define UFONTINFO_HPP 00030 00031 //#include "ufont.hpp" 00032 #include "../uobject.hpp" 00033 #include "../util/ustring.hpp" 00034 00035 namespace ufo { 00036 00052 class UFontInfo /*: public UObject*/ { 00053 public: // Public types 00055 static const UFontInfo nullFont; 00056 00060 enum Family { 00062 DefaultFamily = 0, 00064 Decorative, 00066 Serif, 00068 SansSerif, 00069 //Swiss = SansSerif, 00071 //Roman = Serif, 00073 Script, 00075 MonoSpaced 00076 //Modern = Courier 00077 }; 00079 enum Weight { 00080 AnyWeight = 0, 00081 Light = 250, 00082 Normal = 400, 00083 DemiBold = 600, 00084 Bold = 700, 00085 Black = 900 00086 }; 00087 00089 enum Style { 00090 AnyStyle = 0, 00091 Plain = 1 << 0, 00092 Italic = 1 << 1, 00093 Underline = 1 << 2, 00094 StrikeOut = 1 << 3, 00095 AntiAliased = 1 << 4, 00096 NotAntiAliased = 1 << 5 00097 }; 00098 00100 enum Encoding { 00102 Encoding_System = 0, 00104 Encoding_Default, 00105 Encoding_ISO8859_1, // West European (Latin1) 00106 Encoding_ISO8859_2, // Central and East European (Latin2) 00107 Encoding_ISO8859_3, // Esperanto (Latin3) 00108 Encoding_ISO8859_4, // Baltic (old) (Latin4) 00109 Encoding_ISO8859_5, // Cyrillic 00110 Encoding_ISO8859_6, // Arabic 00111 Encoding_ISO8859_7, // Greek 00112 Encoding_ISO8859_8, // Hebrew 00113 Encoding_ISO8859_9, // Turkish (Latin5) 00114 Encoding_ISO8859_10, // Variation of Latin4 (Latin6) 00115 Encoding_ISO8859_11, // Thai 00116 Encoding_ISO8859_12, // Unused 00117 Encoding_ISO8859_13, // Baltic (Latin7) 00118 Encoding_ISO8859_14, // Latin8 00119 Encoding_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro) 00120 Encoding_ISO8859_MAX, 00121 Encoding_UTF8, 00122 Encoding_Unicode 00123 }; 00124 00125 public: // Public attributes 00126 Family family; 00127 std::string face; 00128 float pointSize; 00129 int weight; 00130 int style; 00131 Encoding encoding; 00132 00133 public: 00135 UFontInfo(); 00136 00137 UFontInfo(const std::string & face, float pointSize, int weight, 00138 int style = Plain, Encoding encoding = Encoding_Default); 00139 UFontInfo(Family family, float pointSize, int weight, 00140 int style = Plain, Encoding encoding = Encoding_Default); 00141 UFontInfo(Family family, const std::string & face, float pointSize, int weight, 00142 int style, Encoding encoding); 00143 00145 unsigned int hashCode() const; 00146 00147 public: // Public operators 00148 friend std::ostream & operator<<(std::ostream & os, const UFontInfo & info); 00149 }; 00150 00151 00153 UFO_EXPORT bool operator==(const UFontInfo & info1,const UFontInfo & info2); 00154 UFO_EXPORT bool operator!=(const UFontInfo & info1,const UFontInfo & info2); 00155 00156 UFO_EXPORT bool operator<(const UFontInfo & info1,const UFontInfo & info2); 00157 00158 // 00159 // inline implementation 00160 // 00161 00162 inline 00163 UFontInfo::UFontInfo() 00164 : family(DefaultFamily) 00165 , face("") 00166 , pointSize(0) 00167 , weight(AnyWeight) 00168 , style(AnyStyle) 00169 , encoding(Encoding_Default) 00170 {} 00171 00172 inline 00173 UFontInfo::UFontInfo(const std::string & face, float pointSize, int weight, 00174 int style, Encoding encoding) 00175 : family(DefaultFamily) 00176 , face(face) 00177 , pointSize(pointSize) 00178 , weight(weight) 00179 , style(style) 00180 , encoding(encoding) 00181 {} 00182 00183 inline 00184 UFontInfo::UFontInfo(Family family, float pointSize, int weight, 00185 int style, Encoding encoding) 00186 : family(family) 00187 , face("") 00188 , pointSize(pointSize) 00189 , weight(weight) 00190 , style(style) 00191 , encoding(encoding) 00192 {} 00193 00194 inline 00195 UFontInfo::UFontInfo(Family family, const std::string & face, float pointSize, int weight, 00196 int style, Encoding encoding) 00197 : family(family) 00198 , face(face) 00199 , pointSize(pointSize) 00200 , weight(weight) 00201 , style(style) 00202 , encoding(encoding) 00203 {} 00204 00205 inline unsigned int 00206 UFontInfo::hashCode() const { 00207 // FIXME ! 00208 // quick and dirty, probably even stupid 00209 unsigned int ret = UString::hash(face.c_str()); 00210 ret = ret << encoding; 00211 ret |= int(pointSize * 10); 00212 ret += weight; 00213 ret += style; 00214 return ret; 00215 } 00216 00217 inline std::ostream & 00218 operator<<(std::ostream & os, const UFontInfo & info) { 00219 return os << "UFontInfo[" 00220 << "family " << info.family 00221 << "; face " << info.face 00222 << "; point size " << info.pointSize 00223 << "; weight " << info.weight 00224 << "; style " << info.style 00225 << "; encoding " << info.encoding 00226 << "]"; 00227 } 00228 00229 inline bool operator==(const UFontInfo & info1,const UFontInfo & info2) { 00230 return ( 00231 (info1.face == info2.face) && 00232 (info1.family == info2.family) && 00233 (info1.pointSize == info2.pointSize) && 00234 (info1.weight == info2.weight) && 00235 (info1.style == info2.style) && 00236 (info1.encoding == info2.encoding) 00237 ); 00238 } 00239 00240 inline bool operator!=(const UFontInfo & info1,const UFontInfo & info2) { 00241 return ( 00242 (info1.face != info2.face) || 00243 (info1.family != info2.family) || 00244 (info1.pointSize != info2.pointSize) || 00245 (info1.weight != info2.weight) || 00246 (info1.style != info2.style) || 00247 (info1.encoding != info2.encoding) 00248 ); 00249 } 00250 00251 inline bool operator<(const UFontInfo & info1,const UFontInfo & info2) { 00252 return info1.hashCode() < info2.hashCode(); 00253 } 00254 00255 } // namespace ufo 00256 00257 #endif // UFONTINFO_HPP

The libUFO Project - written by Johannes Schmidt