aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
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
parent52cb3758861117dbd30c63fd2e24fad5e9900742 (diff)
downloadfluxbox-41249b77fb4db6041d53447ffdb49bfb4dd34ce8.zip
fluxbox-41249b77fb4db6041d53447ffdb49bfb4dd34ce8.tar.bz2
utf-8 fix, a fixed patch from Sergey Kuleshov
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/XftFontImp.cc62
-rw-r--r--src/FbTk/XmbFontImp.cc20
2 files changed, 48 insertions, 34 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
diff --git a/src/FbTk/XmbFontImp.cc b/src/FbTk/XmbFontImp.cc
index 9f47d6e..d06f05d 100644
--- a/src/FbTk/XmbFontImp.cc
+++ b/src/FbTk/XmbFontImp.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: XmbFontImp.cc,v 1.7 2004/02/10 19:03:42 fluxgen Exp $ 22// $Id: XmbFontImp.cc,v 1.8 2004/08/10 11:57:35 fluxgen Exp $
23 23
24#include "XmbFontImp.hh" 24#include "XmbFontImp.hh"
25 25
@@ -186,13 +186,6 @@ XFontSet createFontSet(const char *fontname) {
186namespace FbTk { 186namespace FbTk {
187 187
188XmbFontImp::XmbFontImp(const char *filename, bool utf8):m_fontset(0), m_utf8mode(utf8) { 188XmbFontImp::XmbFontImp(const char *filename, bool utf8):m_fontset(0), m_utf8mode(utf8) {
189#ifdef DEBUG
190#ifdef X_HAVE_UTF8_STRING
191 cerr<<"Using utf8 = "<<utf8<<endl;
192#else // X_HAVE_UTF8_STRING
193 cerr<<"Using uft8 = false"<<endl;
194#endif //X_HAVE_UTF8_STRING
195#endif // DEBUG
196 if (filename != 0) 189 if (filename != 0)
197 load(filename); 190 load(filename);
198} 191}
@@ -238,18 +231,19 @@ void XmbFontImp::drawText(Drawable w, int screen, GC gc, const char *text,
238unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const { 231unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const {
239 if (m_fontset == 0) 232 if (m_fontset == 0)
240 return 0; 233 return 0;
234
241 XRectangle ink, logical; 235 XRectangle ink, logical;
242#ifdef X_HAVE_UTF8_STRING 236#ifdef X_HAVE_UTF8_STRING
243 if (m_utf8mode) { 237 if (m_utf8mode) {
244 Xutf8TextExtents(m_fontset, text, len, 238 Xutf8TextExtents(m_fontset, text, len,
245 &ink, &logical); 239 &ink, &logical);
246 } else 240 if (logical.width != 0)
241 return logical.width;
242 }
247#endif // X_HAVE_UTF8_STRING 243#endif // X_HAVE_UTF8_STRING
248 {
249 XmbTextExtents(m_fontset, text, len,
250 &ink, &logical);
251 }
252 244
245 XmbTextExtents(m_fontset, text, len,
246 &ink, &logical);
253 return logical.width; 247 return logical.width;
254} 248}
255 249