On 03/04/2011 01:34 AM, Manolo Gouy wrote: > But, I agree a more pertinent question could be > "Is it possible to drastically reduce the number of times fl_width() > is called by Fl_Text_Display when word wrapping is on ?". > > Is fltk2.0 both quick and with kerning on the Mac platform ? > Is the drawing code approach of fltk2 transposable to 1.4 ?
It looks like the fltk2 TextDisplay widget is doing the same single-character measurement as before. fltk2 has not been ported off of Carbon so it is not using the new OSX calls. No matter what algorithm is used, the TextDisplay must be fixed to use the measure-a-string call rather than single characters. I'm sure the overhead of this is much more important than any problem with how many times it measures. It looks like on OSX (and also on Xft) the single-character call is implemented by making a 1-character string and measuring that, so it is a total waste of time. I suspect the overhead of constructing the arguments and doing the system call is much more important than the time the system actually spends measuring, so minimizing these calls is much more important than minimizing how much data is sent. FLTK2 does do text wrapping of labels, and does it by measuring the entire accumulated line at the end of each word, so previously-measured words are sent a second time. If the number of measure calls really need to be minimized, it can do this: first guess how many bytes will fill the line (like 120 or something). After this many look for a word boundary, then measure. The ratio of this to the desired length gives you where to make the next guess, find the nearest (different) word boundary. Measure from there, and use the last two to predict a new point to measure. Keep doing it until you have two measurements one word apart, one shorter and the other longer, and now you know which word to wrap. Other possibility is to rewrite to pass everything to Pango (or the OSX equivalent). This is pretty major but I have been looking at it some for Cairo. _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
