[fltk/fltk] In Fl_Text_Display style should apply to UTF-8 characters. (#233)

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

[fltk/fltk] In Fl_Text_Display style should apply to UTF-8 characters. (#233) Basile Starynkevitch 17:29 May 19 top right image
 

Using FLTK 1.3.6 (probably git commit cbee488) with the following example, slightly adapted from examples/textdisplay-with-colors.cxx but using UTF-8 characters does not show the expected colors:

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Text_Display.H>
int main() {
// Style table
Fl_Text_Display::Style_Table_Entry stable[] = {
// FONT COLOR FONT FACE FONT SIZE
// --------------- ----------- --------------
{ FL_RED, FL_COURIER, 18 }, // A - Red
{ FL_DARK_YELLOW, FL_COURIER, 18 }, // B - Yellow
{ FL_DARK_GREEN, FL_COURIER, 18 }, // C - Green
{ FL_BLUE, FL_COURIER, 18 }, // D - Blue
};
Fl_Window *win = new Fl_Window(640, 480, "Simple Text Display With Colors");
Fl_Text_Display *disp = new Fl_Text_Display(20, 20, 640-40, 480-40);
Fl_Text_Buffer *tbuff = new Fl_Text_Buffer(); // text buffer
Fl_Text_Buffer *sbuff = new Fl_Text_Buffer(); // style buffer
disp->buffer(tbuff);
int stable_size = sizeof(stable)/sizeof(stable[0]); // # entries in style table (4)
disp->highlight_data(sbuff, stable, stable_size, 'A', 0, 0);
// Text
tbuff->text("Red Line 1\nYel Line euro:€ 2\nGrn Line para:§ 3\nBlu Line 4\n"
"Red Line 5\nYel Line 6\nGrn Line 7\nBlu Line 8\n");
// Style for text
sbuff->text("AAAAAAAAAA\nBBBBBBBBBBBBBBBBB\nCCCCCCCCCCCCCCCCC\nDDDDDDDDDD\n"
"AAAAAAAAAA\nBBBBBBBBBB\nCCCCCCCCCC\nDDDDDDDDDD\n");
win->resizable(*disp);
win->show();
return(Fl::run());
}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2021 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.