diff options
Diffstat (limited to 'src/Font.hh')
-rw-r--r-- | src/Font.hh | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/src/Font.hh b/src/Font.hh index 66cd6cf..0fa1b0e 100644 --- a/src/Font.hh +++ b/src/Font.hh | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | //$Id: Font.hh,v 1.4 2002/08/04 15:55:13 fluxgen Exp $ | 22 | //$Id: Font.hh,v 1.5 2002/10/13 22:24:14 fluxgen Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_FONT_HH | 24 | #ifndef FBTK_FONT_HH |
25 | #define FBTK_FONT_HH | 25 | #define FBTK_FONT_HH |
@@ -27,16 +27,19 @@ | |||
27 | #include <X11/Xlib.h> | 27 | #include <X11/Xlib.h> |
28 | #include <X11/Xresource.h> | 28 | #include <X11/Xresource.h> |
29 | 29 | ||
30 | namespace FbTk | 30 | #include <string> |
31 | { | 31 | #include <memory> |
32 | |||
33 | namespace FbTk { | ||
34 | |||
35 | class FontImp; | ||
32 | 36 | ||
33 | /** | 37 | /** |
34 | Handles loading of font. | 38 | Handles the client to fontimp bridge. |
35 | */ | 39 | */ |
36 | class Font | 40 | class Font { |
37 | { | ||
38 | public: | 41 | public: |
39 | Font(Display *display, const char *name=0); | 42 | Font(const char *name=0, bool antialias = false); |
40 | virtual ~Font(); | 43 | virtual ~Font(); |
41 | /** | 44 | /** |
42 | Load a font | 45 | Load a font |
@@ -44,23 +47,12 @@ public: | |||
44 | loaded font | 47 | loaded font |
45 | */ | 48 | */ |
46 | bool load(const char *name); | 49 | bool load(const char *name); |
47 | /** | 50 | |
48 | Loads a font from database | ||
49 | @return true on success, else false and it'll fall back on the last | ||
50 | loaded font | ||
51 | @see load(const char *name) | ||
52 | */ | ||
53 | bool loadFromDatabase(XrmDatabase &database, const char *rname, const char *rclass); | ||
54 | /// @return true if a font is loaded, else false | ||
55 | inline bool isLoaded() const { return m_loaded; } | ||
56 | /// @return XFontStruct of font, note: can be 0 | ||
57 | inline const XFontStruct *fontStruct() const { return m_font.fontstruct; } | ||
58 | /// @return XFontSet of font, note: check isLoaded | ||
59 | inline const XFontSet &fontSet() const { return m_font.set; } | ||
60 | /// @return XFontSetExtents of font, note: can be 0 | ||
61 | inline const XFontSetExtents *fontSetExtents() const { return m_font.set_extents; } | ||
62 | /// @return true if multibyte is enabled, else false | 51 | /// @return true if multibyte is enabled, else false |
63 | static inline bool multibyte() { return m_multibyte; } | 52 | static bool multibyte() { return m_multibyte; } |
53 | /// @return true if utf-8 mode is enabled, else false | ||
54 | static bool utf8() { return m_utf8mode; } | ||
55 | void setAntialias(bool flag); | ||
64 | /** | 56 | /** |
65 | @param text text to check size | 57 | @param text text to check size |
66 | @param size length of text in bytes | 58 | @param size length of text in bytes |
@@ -68,24 +60,13 @@ public: | |||
68 | */ | 60 | */ |
69 | unsigned int textWidth(const char *text, unsigned int size) const; | 61 | unsigned int textWidth(const char *text, unsigned int size) const; |
70 | unsigned int height() const; | 62 | unsigned int height() const; |
71 | /// @return display connection | 63 | void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; |
72 | Display *display() const { return m_display; } | ||
73 | private: | 64 | private: |
74 | void freeFont(); | 65 | |
75 | static XFontSet createFontSet(Display *display, const char *fontname); | 66 | std::auto_ptr<FontImp> m_fontimp; |
76 | static const char *getFontSize(const char *pattern, int *size); | 67 | std::string m_fontstr; |
77 | static const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...); | ||
78 | |||
79 | struct FontType | ||
80 | { | ||
81 | XFontSet set; | ||
82 | XFontSetExtents *set_extents; | ||
83 | XFontStruct *fontstruct; | ||
84 | } m_font; | ||
85 | |||
86 | bool m_loaded; | ||
87 | static bool m_multibyte; | 68 | static bool m_multibyte; |
88 | Display *m_display; | 69 | static bool m_utf8mode; |
89 | }; | 70 | }; |
90 | 71 | ||
91 | }; //end namespace FbTk | 72 | }; //end namespace FbTk |