diff options
author | Ken Bloom <kbloom at gmail com> | 2010-09-04 13:01:33 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2010-09-04 13:01:33 (GMT) |
commit | ea98db414033aa17aee720135e2f9ee0a08696cc (patch) | |
tree | 40f0f68ee4a86289d832713890c226f31cdf853a /src/FbTk/FbString.cc | |
parent | b1b2f47e7dd185fef88a44a318a9b374083ecb40 (diff) | |
download | fluxbox-ea98db414033aa17aee720135e2f9ee0a08696cc.zip fluxbox-ea98db414033aa17aee720135e2f9ee0a08696cc.tar.bz2 |
added support for bidirectional text
Diffstat (limited to 'src/FbTk/FbString.cc')
-rw-r--r-- | src/FbTk/FbString.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/FbTk/FbString.cc b/src/FbTk/FbString.cc index 0164afd..1cef002 100644 --- a/src/FbTk/FbString.cc +++ b/src/FbTk/FbString.cc | |||
@@ -45,6 +45,11 @@ | |||
45 | 45 | ||
46 | #include <iostream> | 46 | #include <iostream> |
47 | 47 | ||
48 | #ifdef HAVE_FRIBIDI | ||
49 | #include <fribidi/fribidi.h> | ||
50 | #endif | ||
51 | |||
52 | |||
48 | using std::string; | 53 | using std::string; |
49 | 54 | ||
50 | #ifdef DEBUG | 55 | #ifdef DEBUG |
@@ -239,6 +244,37 @@ bool haveUTF8() { | |||
239 | } | 244 | } |
240 | 245 | ||
241 | 246 | ||
247 | #ifdef HAVE_FRIBIDI | ||
248 | |||
249 | FbString BidiLog2Vis (const FbString& src){ | ||
250 | FriBidiChar * us, * out_us; | ||
251 | FriBidiCharType base; | ||
252 | FbString r; | ||
253 | char * out; | ||
254 | |||
255 | us = new FriBidiChar[src.size()+1]; | ||
256 | out_us = new FriBidiChar[src.size()+1]; | ||
257 | |||
258 | unsigned int len = fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, const_cast<char *>(src.c_str()), src.length(), us); | ||
259 | |||
260 | base = FRIBIDI_TYPE_N; | ||
261 | fribidi_log2vis(us, len, &base, out_us, NULL, NULL, NULL); | ||
262 | |||
263 | out = new char[4*src.size()+1]; | ||
264 | |||
265 | fribidi_unicode_to_charset(FRIBIDI_CHAR_SET_UTF8, out_us, len, out); | ||
266 | |||
267 | r = out; | ||
268 | |||
269 | delete[] out_us; | ||
270 | delete[] us; | ||
271 | delete[] out; | ||
272 | |||
273 | return r; | ||
274 | } | ||
275 | |||
276 | #endif | ||
277 | |||
242 | } // end namespace StringUtil | 278 | } // end namespace StringUtil |
243 | 279 | ||
244 | StringConvertor::StringConvertor(EncodingTarget target): | 280 | StringConvertor::StringConvertor(EncodingTarget target): |
@@ -289,4 +325,5 @@ string StringConvertor::recode(const string &src) { | |||
289 | #endif | 325 | #endif |
290 | } | 326 | } |
291 | 327 | ||
328 | |||
292 | } // end namespace FbTk | 329 | } // end namespace FbTk |