Modify the utf8 test demo code to handle surrogate pairs.

It was hard coded to cover the range 0 to 0xFFFF, i.e. the
Basic multilingual plane, even though the demo code allowed
any start index, for any plane, to be entered on the CLI...
As a result, attempts to view supplemental planes were always
just folded back into the BMP.
This change makes the code display the 64K Unicode points
starting at the index given on the CLI, so that the 
supplemental planes *can* now be viewed and tested.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8629 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Ian MacArthur 2011-05-01 12:24:22 +00:00
parent ae8d142ed0
commit 6c9d1f7840
1 changed files with 23 additions and 13 deletions

View File

@ -75,6 +75,10 @@ static Fl_Font extra_font;
static int font_count = 0;
static int first_free = 0;
static void cb_exit(Fl_Button*, void*) {
if(fnt_chooser_win) fnt_chooser_win->hide();
if(main_win) main_win->hide();
} /* cb_exit */
/*
Class for displaying sample fonts.
@ -410,6 +414,7 @@ static void create_font_widget()
}
fnt_chooser_win->resizable(tile);
fnt_chooser_win->end();
fnt_chooser_win->callback((Fl_Callback*)cb_exit);
}
}
@ -602,17 +607,20 @@ int main(int argc, char** argv)
Fl_Scroll scroll(200,0,5 * 75,400);
int off = 2;
int end_list = 0x10000 / 16;
if (argc > 1) {
off = (int)strtoul(argv[1], NULL, 0);
end_list = off + 0x10000;
off /= 16;
end_list /= 16;
}
argc = 1;
for (long y=off; y< 0x10000 / 16; y++) {
for (long y = off; y < end_list; y++) {
int o = 0;
char bu[25];
char buf[16*6];
char bu[25]; // index label
char buf[16 * 6]; // utf8 text
int i = 16 * y;
for (int x=0; x<16; x++) {
for (int x = 0; x < 16; x++) {
int l;
l = fl_utf8encode(i, buf + o);
if (l < 1) l = 1;
@ -620,15 +628,16 @@ int main(int argc, char** argv)
i++;
}
buf[o] = '\0';
sprintf(bu, "0x%04lX", y * 16);
Fl_Input* b = new Fl_Input(200,(y-off)*25,60,25);
sprintf(bu, "0x%06lX", y * 16);
Fl_Input *b = new Fl_Input(200,(y-off)*25,80,25);
b->textfont(FL_COURIER);
b->value(strdup(bu));
b = new Fl_Input(260,(y-off)*25,400,25);
b = new Fl_Input(280,(y-off)*25,380,25);
b->textfont(extra_font);
b->value(strdup(buf));
}
main_win->resizable(scroll);
scroll.end();
main_win->resizable(scroll);
thescroll = &scroll;
@ -696,20 +705,21 @@ int main(int argc, char** argv)
o9.textsize(30);
o9.value(utfstr);
main_win->end();
main_win->callback((Fl_Callback*)cb_exit);
fl_set_status(0, 370, 100, 30);
main_win->show(argc,argv);
fnt_chooser_win->show();
int ret = Fl::run();
// Free up the sizes arrays we allocated
if(numsizes) {delete [] numsizes;}
if(sizes) {delete [] sizes;}
return ret;
}