On 21.09.2011, at 16:52, Nikita Egorov wrote: >> No, even if you use monospace fonts, you can not assume that the number of >> characters times the width of the font will give you the width of the string >> that will be rendered on screen. There are characters and character >> combinations in Unicode that need more or less pixels, even in monospaced >> fonts! There are even character sequences that have different width in >> different combinations, so simply adding up the width on each individual >> character will not work. > > Hmm, it's quite new thing for me! Could you tell me a sample of one of > such combinations?
characters > 0x2e80 for example have a width of two monospace chars. These are mostly Chinese, Japanese and Korean. Basically, for monospaced font in Unicode, you can have non-spacing, single-width or double-width characters or ligatures. >> The only reliable way to get the width of whatever is printed is using >> fl_width() after setting the font and size. > > I have no width of line in dots. I have only maximal length of string > in characters. Oh, OK. I misread that. You can use this: /* OD: returns the number of Unicode chars in the UTF-8 string */ FL_EXPORT int fl_utf_nb_char(const unsigned char *buf, int len); - Matthias _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
