You need at least FLTK 1.3.0 to render UTF-8. Also, as Nikita said, some 
compilers do not like UTF-8, so make sure that yours does . Last but not least, 
right-to-left scripts do not always render correctly on all platforms. There is 
not much FLTK can do about it, but we have added a function that may help you: 
void rtl_draw(const char* str, int n, int x, int y)

That would look something like this:

#include <FL/Fl_Box.h>
#include <FL/draw.h>

class RTLBox : public Fl_Box
{
public:
  RTLBox(int x, int y, int w, int h, const char *l=0)
  :  Fl_Box(x, y, w, h, l) { }
  void draw() {
    draw_box();
    rtl_draw(label(), strlen(label()), x(), y()+h()/2);
  } 
};

...and then the rest of your code, using RTLBox instead of Fl_Box.

Let me know if that worked. Also, a screenshot would be very helpful.



On 10.07.2012, at 09:34, Nikita Egorov wrote:

> Hi. First, what are your OS and compiler/IDE?
> 
>> I need to display the hindi word "हिंदी" in a Fl_Box label. That hindi word 
>> gets altered while displaying.
> 
>> Fl_Double_Window* make_window() {
>>  Fl_Double_Window* w;
>>  {
>>    Fl_Double_Window* o = new Fl_Double_Window(500, 500);
>>    w = o;
>>    {
>>      Fl_Box *box = new Fl_Box(25, 25, 400, 400, "हिंदी");
> I think your problem is here                       ^
> 
> Many compilers don't like such UTF8 strings in text of program.
> Try to use instead wide char string and convert it to UTF8 via some system 
> calls or via fl_utf8fromwc().
> 
> Simple example:
> 
> #include "FL/fl_utf8.h"
> ..
>   char dst[32];
>   fl_utf8fromwc(dst, 32, L"हिंदी", length_of_src);
>   Fl_Box *box = new Fl_Box(25, 25, 400, 400, dst);
> 
> 
> _______________________________________________
> fltk mailing list
> [email protected]
> http://lists.easysw.com/mailman/listinfo/fltk

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to