00001 #ifndef KDE__FONTMANAGER_H
00002 #define KDE__FONTMANAGER_H
00003
00004 #include <faith/application.h>
00005 #include <faith/string.h>
00006
00007
00008 namespace Faith
00009 {
00010 class FontMetrics;
00011
00012 namespace Internal
00013 {
00014 class FontBackend;
00015 }
00016
00020 class FAITH_CORE_EXPORT Font
00021 {
00022 friend class FontMetrics;
00023 #ifndef WIN32
00024 mutable Internal::FontBackend *backend;
00025 #else
00026 struct FontPrivate;
00027 mutable FontPrivate *d;
00028 #endif
00029
00030 public:
00034 enum Weight
00035 {
00036 Light=25,
00037 Normal=50,
00038 DemiBold=63,
00039 Bold=75,
00040 Black = 87
00041 };
00042
00046 Font();
00050 Font(const Font ©);
00051
00055 Font(const String &family, int points=12, int weight=Normal, bool oblique=false);
00056 ~Font();
00060 Font& operator=(const Font ©);
00061
00066 bool operator ==(const Font &other) const;
00067
00068 #ifdef WIN32
00069 Handle handle() const;
00070 #else
00071 Handle x11Handle();
00072 void *xftHandle();
00073 #endif
00074
00080 String filename() const;
00081
00085 String family() const;
00086
00090 int pointSize() const;
00091
00092 private:
00093 void deref();
00094 };
00095
00096
00105 class FAITH_CORE_EXPORT FontMetrics
00106 {
00107 Font mFont;
00108 struct FontMetricsPrivate;
00109 FontMetricsPrivate *d;
00110
00111 FontMetrics();
00112 public:
00116 FontMetrics(const Font &f);
00120 FontMetrics(const FontMetrics &font);
00121 ~FontMetrics();
00122
00123 FontMetrics &operator=(const FontMetrics &font);
00124
00136 Faith::Rect boundingRect(const String &str, int len=-1) const;
00137
00141 Faith::Size size(const String &str, int len=-1) const;
00142 Faith::Size size(const String &str, int pos, int len) const;
00143
00151 int width(const String &str, int len=-1) const;
00152 int width(const String &str, int pos, int len) const;
00153
00158 int ascent(const Char &ch) const;
00159
00163 int ascent() const;
00164
00169 int descent(const Char &ch) const;
00170
00174 int descent() const;
00175
00181 int height() const;
00182
00186 bool inFont(const Char &ch) const;
00187
00193 int underlinePos() const;
00198 int overlinePos() const;
00203 int strikeOutPos() const;
00204
00209 int lineWidth() const;
00210
00211 private:
00212 void reset();
00213 void init();
00214 };
00215
00216
00217 }
00218 #endif
00219