aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-10-16 23:13:54 (GMT)
committerfluxgen <fluxgen>2002-10-16 23:13:54 (GMT)
commit460d3850919831c107b28c09881f857647444745 (patch)
tree538bbce57aada7c85820ac04b2ffc0d6390be9b3 /src
parent0ea4319159dbe49d67b83c93dce745b9c2772404 (diff)
downloadfluxbox-460d3850919831c107b28c09881f857647444745.zip
fluxbox-460d3850919831c107b28c09881f857647444745.tar.bz2
utf8
Diffstat (limited to 'src')
-rw-r--r--src/XftFontImp.cc48
-rw-r--r--src/XftFontImp.hh9
2 files changed, 40 insertions, 17 deletions
diff --git a/src/XftFontImp.cc b/src/XftFontImp.cc
index d31a74e..619b791 100644
--- a/src/XftFontImp.cc
+++ b/src/XftFontImp.cc
@@ -19,12 +19,13 @@
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: XftFontImp.cc,v 1.1 2002/10/14 18:14:20 fluxgen Exp $ 22//$Id: XftFontImp.cc,v 1.2 2002/10/16 23:13:15 fluxgen Exp $
23 23
24#include "XftFontImp.hh" 24#include "XftFontImp.hh"
25#include "BaseDisplay.hh" 25#include "BaseDisplay.hh"
26 26
27XftFontImp::XftFontImp(const char *name):m_xftfont(0) { 27XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0),
28m_utf8mode(utf8) {
28 if (name != 0) 29 if (name != 0)
29 load(name); 30 load(name);
30} 31}
@@ -83,30 +84,51 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
83 &rendcol, &xftcolor); 84 &rendcol, &xftcolor);
84 85
85 // draw string 86 // draw string
86 XftDrawString8 (draw, 87#ifdef X_HAVE_UTF8_STRING
87 &xftcolor, 88 if (m_utf8mode) {
88 m_xftfont, 89 XftDrawStringUtf8(draw,
89 x, y, 90 &xftcolor,
90 (XftChar8 *)(text), len); 91 m_xftfont,
92 x, y,
93 (XftChar8 *)(text), len);
94 } else
95#endif // X_HAVE_UTF8_STRING
96 {
97 XftDrawString8(draw,
98 &xftcolor,
99 m_xftfont,
100 x, y,
101 (XftChar8 *)(text), len);
102 }
91 103
92 XftColorFree(disp, DefaultVisual(disp, screen), 104 XftColorFree(disp, DefaultVisual(disp, screen),
93 DefaultColormap(disp, screen), &xftcolor); 105 DefaultColormap(disp, screen), &xftcolor);
94 XftDrawDestroy(draw); 106 XftDrawDestroy(draw);
95} 107}
96 108
97unsigned int XftFontImp::textWidth(const char *text, unsigned int len) const { 109unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const {
98 if (m_xftfont == 0) 110 if (m_xftfont == 0)
99 return 0; 111 return 0;
100 XGlyphInfo ginfo; 112 XGlyphInfo ginfo;
101 XftTextExtents8(BaseDisplay::getXDisplay(), 113#ifdef X_HAVE_UTF8_STRING
102 m_xftfont, 114 if (m_utf8mode) {
103 (XftChar8 *)text, len, 115 XftTextExtentsUtf8(BaseDisplay::getXDisplay(),
104 &ginfo); 116 m_xftfont,
117 (XftChar8 *)text, len,
118 &ginfo);
119 } else
120#endif //X_HAVE_UTF8_STRING
121 {
122 XftTextExtents8(BaseDisplay::getXDisplay(),
123 m_xftfont,
124 (XftChar8 *)text, len,
125 &ginfo);
126 }
105 return ginfo.xOff; 127 return ginfo.xOff;
106} 128}
107 129
108unsigned int XftFontImp::height() const { 130unsigned int XftFontImp::height() const {
109 if (m_xftfont == 0) 131 if (m_xftfont == 0)
110 return 0; 132 return 0;
111 return m_xftfont->ascent + m_xftfont->descent; 133 return m_xftfont->height;
112} 134}
diff --git a/src/XftFontImp.hh b/src/XftFontImp.hh
index 5cfc6ee..d03e65a 100644
--- a/src/XftFontImp.hh
+++ b/src/XftFontImp.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: XftFontImp.hh,v 1.2 2002/10/15 16:44:26 fluxgen Exp $ 22//$Id: XftFontImp.hh,v 1.3 2002/10/16 23:13:54 fluxgen Exp $
23 23
24#ifndef XFTFONTIMP_HH 24#ifndef XFTFONTIMP_HH
25#define XFTFONTIMP_HH 25#define XFTFONTIMP_HH
@@ -29,15 +29,16 @@
29 29
30class XftFontImp:public FbTk::FontImp { 30class XftFontImp:public FbTk::FontImp {
31public: 31public:
32 explicit XftFontImp(const char *fontname=0); 32 XftFontImp(const char *fontname, bool utf8);
33 ~XftFontImp(); 33 ~XftFontImp();
34 bool load(const std::string &name); 34 bool load(const std::string &name);
35 void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; 35 void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
36 unsigned int textWidth(const char *text, unsigned int len) const; 36 unsigned int textWidth(const char * const text, unsigned int len) const;
37 unsigned int height() const; 37 unsigned int height() const;
38 bool loaded() const { return m_xftfont != 0; } 38 bool loaded() const { return m_xftfont != 0; }
39private: 39private:
40 XftFont *m_xftfont; 40 XftFont *m_xftfont;
41 bool m_utf8mode;
41}; 42};
42 43
43#endif // XFTFONTIMP_HH 44#endif // XFTFONTIMP_HH