aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XftFontImp.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-08-10 11:57:35 (GMT)
committerfluxgen <fluxgen>2004-08-10 11:57:35 (GMT)
commit41249b77fb4db6041d53447ffdb49bfb4dd34ce8 (patch)
tree3a24477f278a93dc0edfda5f728483abdf1e37d3 /src/FbTk/XftFontImp.cc
parent52cb3758861117dbd30c63fd2e24fad5e9900742 (diff)
downloadfluxbox-41249b77fb4db6041d53447ffdb49bfb4dd34ce8.zip
fluxbox-41249b77fb4db6041d53447ffdb49bfb4dd34ce8.tar.bz2
utf-8 fix, a fixed patch from Sergey Kuleshov
Diffstat (limited to 'src/FbTk/XftFontImp.cc')
-rw-r--r--src/FbTk/XftFontImp.cc62
1 files changed, 41 insertions, 21 deletions
diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc
index 59f8440..c698238 100644
--- a/src/FbTk/XftFontImp.cc
+++ b/src/FbTk/XftFontImp.cc
@@ -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.cc,v 1.2 2002/12/01 13:42:15 rathnor Exp $ 22//$Id: XftFontImp.cc,v 1.3 2004/08/10 11:57:35 fluxgen Exp $
23 23
24#include "XftFontImp.hh" 24#include "XftFontImp.hh"
25#include "App.hh" 25#include "App.hh"
@@ -27,6 +27,7 @@
27#ifdef HAVE_CONFIG_H 27#ifdef HAVE_CONFIG_H
28#include "config.h" 28#include "config.h"
29#endif //HAVE_CONFIG_H 29#endif //HAVE_CONFIG_H
30
30namespace FbTk { 31namespace FbTk {
31 32
32XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), 33XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0),
@@ -93,20 +94,33 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
93 // draw string 94 // draw string
94#ifdef HAVE_XFT_UTF8_STRING 95#ifdef HAVE_XFT_UTF8_STRING
95 if (m_utf8mode) { 96 if (m_utf8mode) {
96 XftDrawStringUtf8(draw, 97 // check the string size,
97 &xftcolor, 98 // if the size is zero we use the XftDrawString8 function instead.
98 m_xftfont, 99 XGlyphInfo ginfo;
99 x, y, 100 XftTextExtentsUtf8(App::instance()->display(),
100 (XftChar8 *)(text), len);
101 } else
102#endif // HAVE_XFT_UTF8_STRING
103 {
104 XftDrawString8(draw,
105 &xftcolor,
106 m_xftfont, 101 m_xftfont,
107 x, y, 102 (XftChar8 *)text, len,
108 (XftChar8 *)(text), len); 103 &ginfo);
109 } 104 if (ginfo.xOff != 0) {
105 XftDrawStringUtf8(draw,
106 &xftcolor,
107 m_xftfont,
108 x, y,
109 (XftChar8 *)(text), len);
110 XftColorFree(disp, DefaultVisual(disp, screen),
111 DefaultColormap(disp, screen), &xftcolor);
112 XftDrawDestroy(draw);
113 return;
114 }
115 }
116#endif // HAVE_XFT_UTF8_STRING
117
118 XftDrawString8(draw,
119 &xftcolor,
120 m_xftfont,
121 x, y,
122 (XftChar8 *)(text), len);
123
110 124
111 XftColorFree(disp, DefaultVisual(disp, screen), 125 XftColorFree(disp, DefaultVisual(disp, screen),
112 DefaultColormap(disp, screen), &xftcolor); 126 DefaultColormap(disp, screen), &xftcolor);
@@ -116,21 +130,27 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
116unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const { 130unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const {
117 if (m_xftfont == 0) 131 if (m_xftfont == 0)
118 return 0; 132 return 0;
133
119 XGlyphInfo ginfo; 134 XGlyphInfo ginfo;
135
120#ifdef HAVE_XFT_UTF8_STRING 136#ifdef HAVE_XFT_UTF8_STRING
121 if (m_utf8mode) { 137 if (m_utf8mode) {
122 XftTextExtentsUtf8(App::instance()->display(), 138 XftTextExtentsUtf8(App::instance()->display(),
123 m_xftfont, 139 m_xftfont,
124 (XftChar8 *)text, len, 140 (XftChar8 *)text, len,
125 &ginfo); 141 &ginfo);
126 } else 142 if (ginfo.xOff != 0)
143 return ginfo.xOff;
144
145 // the utf8 failed, try normal extents
146 }
127#endif //HAVE_XFT_UTF8_STRING 147#endif //HAVE_XFT_UTF8_STRING
128 { 148
129 XftTextExtents8(App::instance()->display(), 149 XftTextExtents8(App::instance()->display(),
130 m_xftfont, 150 m_xftfont,
131 (XftChar8 *)text, len, 151 (XftChar8 *)text, len,
132 &ginfo); 152 &ginfo);
133 } 153
134 return ginfo.xOff; 154 return ginfo.xOff;
135} 155}
136 156