On 05/08/12 05:38, MacArthur, Ian (SELEX GALILEO, UK) wrote:
>> Second question: What function should be used: fl_measure() or
>> fl_text_extents()? Would there be a performance difference to be
>> expected, or would it only be the small difference in the exact
>> layout? The latter could IMHO be ignored, I'd suggest to use the
>> faster method, because exactness wouldn't matter here, anyway.
> 
> They also do slightly different things:
> 
> fl_text_extents measures the "inked" area of the string, but assumes that the 
> text is "ready to be rendered" when measured, whereas fl_measure does text 
> wrapping and symbol expansion and so forth before measuring the string, so 
> the results are not directly analogous.
> 
> Note that fl_measure attempts to expand symbols and wrap text in exactly the 
> same fashion as fl_draw would do when rendering a widget label, so it is 
> probably the more appropriate method for this particular job. I assume what 
> we are looking at here is how to stop widget labels from wrapping back onto 
> the screen inappropriately?
> Though it may well be slower than fl_text_extents in the general case?

        Right -- for instance fl_text_extents() will return the same
        width for these two strings:

                "  This is a test  "
                "This is a test"

        ..because the 'inked' areas are the same; the leading/trailing
        white space is ignored in the width calculation.

        Whereas fl_measure() will return different values for those
        strings, because it includes the leading/trailing spaces.

        I believe the same goes for vertical white space as well,
        ie. "\nTesting\n\n\n" and "Testing" would I think return
        the same vertical size.

        fl_text_extent() does, however, give you the offset from the
        string origin, so for instance the X offset for "This is a test"
        and "   This is a test" will be different.
_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to