diff options
Diffstat (limited to 'src/Font.hh')
-rw-r--r-- | src/Font.hh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/Font.hh b/src/Font.hh new file mode 100644 index 0000000..6c1d95e --- /dev/null +++ b/src/Font.hh | |||
@@ -0,0 +1,70 @@ | |||
1 | // Font.cc | ||
2 | // Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | //$Id: Font.hh,v 1.3 2002/05/15 09:36:57 fluxgen Exp $ | ||
23 | |||
24 | #ifndef FBTK_FONT_HH | ||
25 | #define FBTK_FONT_HH | ||
26 | |||
27 | #include <X11/Xlib.h> | ||
28 | #include <X11/Xresource.h> | ||
29 | |||
30 | namespace FbTk | ||
31 | { | ||
32 | |||
33 | class Font | ||
34 | { | ||
35 | public: | ||
36 | Font(Display *display, const char *name=0); | ||
37 | virtual ~Font(); | ||
38 | //manipulators | ||
39 | bool load(const char *name); | ||
40 | bool loadFromDatabase(XrmDatabase &database, const char *rname, const char *rclass); | ||
41 | //accessors | ||
42 | inline bool isLoaded() const { return m_loaded; } | ||
43 | inline const XFontStruct *getFontStruct() const { return m_font.fontstruct; } | ||
44 | inline const XFontSet &getFontSet() const { return m_font.set; } | ||
45 | inline const XFontSetExtents *getFontSetExtents() const { return m_font.set_extents; } | ||
46 | static inline bool multibyte() { return m_multibyte; } | ||
47 | unsigned int getTextWidth(const char *text, unsigned int size) const; | ||
48 | unsigned int getHeight() const; | ||
49 | Display *getDisplay() const { return m_display; } | ||
50 | private: | ||
51 | void freeFont(); | ||
52 | static XFontSet createFontSet(Display *display, const char *fontname); | ||
53 | static const char *getFontSize(const char *pattern, int *size); | ||
54 | static const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...); | ||
55 | |||
56 | struct FontType | ||
57 | { | ||
58 | XFontSet set; | ||
59 | XFontSetExtents *set_extents; | ||
60 | XFontStruct *fontstruct; | ||
61 | } m_font; | ||
62 | |||
63 | bool m_loaded; | ||
64 | static bool m_multibyte; | ||
65 | Display *m_display; | ||
66 | }; | ||
67 | |||
68 | }; //end namespace FbTk | ||
69 | |||
70 | #endif //FBTK_FONT_HH | ||