Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 36004 | Differences between
and this patch

Collapse All | Expand All

(-)fluxbox-0.9.7-orig/src/FbTk/StringUtil.cc (+30 lines)
Lines 31-36 Link Here
31
#include <memory>
31
#include <memory>
32
#include <algorithm>
32
#include <algorithm>
33
33
34
#include <langinfo.h>  
35
#include <iconv.h>
36
#include <errno.h>
37
38
34
using namespace std;
39
using namespace std;
35
40
36
namespace FbTk {
41
namespace FbTk {
Lines 199-204 Link Here
199
    return first_pos;
204
    return first_pos;
200
}
205
}
201
206
207
char *locale_to_utf8(const char *text)
208
{      
209
    static iconv_t conv = (iconv_t)-1;
210
    char *utf_str, *from, *to;
211
    size_t from_len, to_len;
212
    size_t r;
213
    if (conv == (iconv_t)-1) {
214
        char *loc = strdup(nl_langinfo(CODESET));
215
        conv = iconv_open("UTF-8", loc);
216
        delete [] loc;
217
    }
218
    from = (char *)text;
219
    from_len = strlen(text);
220
    to_len = from_len * 6 + 1;
221
    utf_str = to = new char[to_len];
222
    r = iconv (conv, &from, &from_len, &to, &to_len);
223
    // success or incomplete sequence
224
    if (r != (size_t)-1 || errno == EINVAL) {
225
        *to = '\0';
226
        return utf_str;
227
    }
228
    delete [] utf_str;
229
    return strdup(text);
230
}
231
202
}; // end namespace StringUtil
232
}; // end namespace StringUtil
203
233
204
}; // end namespace FbTk
234
}; // end namespace FbTk
(-)fluxbox-0.9.7-orig/src/FbTk/StringUtil.hh (+2 lines)
Lines 89-94 Link Here
89
    }
89
    }
90
}
90
}
91
91
92
char *locale_to_utf8(const char *text);
93
92
} // end namespace StringUtil
94
} // end namespace StringUtil
93
95
94
} // end namespace FbTk
96
} // end namespace FbTk
(-)fluxbox-0.9.7-orig/src/FbTk/XftFontImp.cc (-15 / +31 lines)
Lines 22-27 Link Here
22
//$Id: XftFontImp.cc,v 1.2 2002/12/01 13:42:15 rathnor Exp $
22
//$Id: XftFontImp.cc,v 1.2 2002/12/01 13:42:15 rathnor Exp $
23
23
24
#include "XftFontImp.hh"
24
#include "XftFontImp.hh"
25
#include "StringUtil.hh"
25
#include "App.hh"
26
#include "App.hh"
26
27
27
#ifdef HAVE_CONFIG_H
28
#ifdef HAVE_CONFIG_H
Lines 98-112 Link Here
98
                          m_xftfont,
99
                          m_xftfont,
99
                          x, y,
100
                          x, y,
100
                          (XftChar8 *)(text), len);
101
                          (XftChar8 *)(text), len);
101
    } else 
102
    } else {
103
    	char *utf8_text = StringUtil::locale_to_utf8(text);
104
    	int utf8_len = strlen(utf8_text);
105
        XftDrawStringUtf8(draw,
106
                          &xftcolor,
107
                          m_xftfont,
108
                          x, y,
109
                          (XftChar8 *)(utf8_text), utf8_len);
110
	delete [] utf8_text;
111
    }
112
#else
113
    XftDrawString8(draw,
114
                   &xftcolor,
115
                   m_xftfont,
116
                   x, y,
117
                   (XftChar8 *)(text), len);
102
#endif // HAVE_XFT_UTF8_STRING
118
#endif // HAVE_XFT_UTF8_STRING
103
	{
104
            XftDrawString8(draw,
105
                           &xftcolor,
106
                           m_xftfont,
107
                           x, y,
108
                           (XftChar8 *)(text), len);
109
	}
110
119
111
    XftColorFree(disp, DefaultVisual(disp, screen), 
120
    XftColorFree(disp, DefaultVisual(disp, screen), 
112
                 DefaultColormap(disp, screen), &xftcolor);
121
                 DefaultColormap(disp, screen), &xftcolor);
Lines 123-136 Link Here
123
                           m_xftfont,
132
                           m_xftfont,
124
                           (XftChar8 *)text, len,
133
                           (XftChar8 *)text, len,
125
                           &ginfo);
134
                           &ginfo);
126
    } else 
135
    } else {
136
	char *utf8_text = StringUtil::locale_to_utf8(text);
137
	len = strlen(utf8_text);
138
        XftTextExtentsUtf8(App::instance()->display(),
139
                           m_xftfont,
140
                           (XftChar8 *)utf8_text, len,
141
                           &ginfo);
142
	delete [] utf8_text;
143
    }
144
#else
145
    XftTextExtents8(App::instance()->display(),
146
                    m_xftfont,
147
                    (XftChar8 *)text, len,
148
                    &ginfo);
127
#endif  //HAVE_XFT_UTF8_STRING
149
#endif  //HAVE_XFT_UTF8_STRING
128
	{
129
            XftTextExtents8(App::instance()->display(),
130
                            m_xftfont,
131
                            (XftChar8 *)text, len,
132
                            &ginfo);
133
	}
134
    return ginfo.xOff;
150
    return ginfo.xOff;
135
}
151
}
136
152

Return to bug 36004