00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#ifndef UFONTINFO_HPP
00029
#define UFONTINFO_HPP
00030
00031
00032
#include "../uobject.hpp"
00033
#include "../util/ustring.hpp"
00034
00035
namespace ufo {
00036
00052 class UFontInfo {
00053
public:
00055 static const UFontInfo nullFont;
00056
00060 enum Family {
00062
DefaultFamily = 0,
00064
Decorative,
00066
Serif,
00068
SansSerif,
00069
00071
00073
Script,
00075
MonoSpaced
00076
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,
00106 Encoding_ISO8859_2,
00107 Encoding_ISO8859_3,
00108 Encoding_ISO8859_4,
00109 Encoding_ISO8859_5,
00110 Encoding_ISO8859_6,
00111 Encoding_ISO8859_7,
00112 Encoding_ISO8859_8,
00113 Encoding_ISO8859_9,
00114 Encoding_ISO8859_10,
00115 Encoding_ISO8859_11,
00116 Encoding_ISO8859_12,
00117 Encoding_ISO8859_13,
00118 Encoding_ISO8859_14,
00119 Encoding_ISO8859_15,
00120 Encoding_ISO8859_MAX,
00121 Encoding_UTF8,
00122 Encoding_Unicode
00123 };
00124
00125
public:
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:
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
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
00208
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 }
00256
00257
#endif // UFONTINFO_HPP