> If the intent is to trim glyphs off the end of a string until it only has the > required number of glyphs left, then I think you could do something useful > using: > > /* F2: Move backward to the previous valid UTF8 sequence start */ > FL_EXPORT const char* fl_utf8back(const char* p, const char* start, const > char* end); > > > Starting one byte in from the end, I think you can use this to walk backwards > through the string until you have removed the necessary number of glyphs... > > Say you have used: > > int num_glyphs = fl_utf_nb_char(const unsigned char *buf, int len); > > To determine that there are 10 glyphs in your string, and you know you only > have room for 6 on the screen, then you could use > > const char *glyph_begin = fl_utf8back(buf, ...); > > 4 times to walk back to the start of glyph 7, then by comparing the values of > "buf" and "glyph_begin" you know exactly how many bytes in your string are > required to create the 6 glyphs that you can fit on the display... > > Well, something like that, anyway...
Thanks, I found what I need. It can be approached via several ways, certainly. :) off topic: I'm not sure the word "glyph" is a proper one in our case. IIRC the "glyph" can be only part of character. A few glyphs can be at one character cell and make up grapheme, symbol. So I'm interested in how many character cells will be displayed. Nikita _______________________________________________ fltk-dev mailing list fltk-dev@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-dev