aboutsummaryrefslogtreecommitdiff
path: root/src/Font.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Font.hh')
-rw-r--r--src/Font.hh68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/Font.hh b/src/Font.hh
new file mode 100644
index 0000000..04318ba
--- /dev/null
+++ b/src/Font.hh
@@ -0,0 +1,68 @@
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.1 2002/03/21 10:51:48 fluxgen Exp $
23
24#ifndef FBTK_FONT_HH
25#define FBTK_FONT_HH
26
27#include <X11/Xresource.h>
28namespace FbTk
29{
30
31class Font
32{
33public:
34 Font(Display *display, const char *name=0);
35 virtual ~Font();
36 //manipulators
37 bool load(const char *name);
38 bool loadFromDatabase(XrmDatabase &database, const char *rname, const char *rclass);
39 //accessors
40 inline bool isLoaded() const { return m_loaded; }
41 inline XFontStruct *getFontStruct() const { return m_font.fontstruct; }
42 inline XFontSet &getFontSet() { return m_font.set; }
43 inline XFontSetExtents *getFontSetExtents() const { return m_font.set_extents; }
44 static inline bool multibyte() { return m_multibyte; }
45 unsigned int getTextWidth(const char *text, unsigned int size) const;
46 unsigned int getHeight() const;
47 Display *getDisplay() const { return m_display; }
48private:
49 void freeFont();
50 static XFontSet createFontSet(Display *display, const char *fontname);
51 static const char *getFontSize(const char *pattern, int *size);
52 static const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...);
53
54 struct FontType
55 {
56 XFontSet set;
57 XFontSetExtents *set_extents;
58 XFontStruct *fontstruct;
59 } m_font;
60
61 bool m_loaded;
62 static bool m_multibyte;
63 Display *m_display;
64};
65
66}; //end namespace FbTk
67
68#endif //FBTK_FONT_HH