> Greg replied: > > Don't forget to set the font ;) eg. fl_font(). > > FLTK will crash if the font isn't set before the fl_draw() call. > > Is there some reason why this is acceptable behaviour and not an STR? > You don't need to call fl_font() before setting titles and labels, so > why is it needed before fl_draw()? Can't the same font be used? > > Just thinking aloud...
Yes - I think maybe it's just always been like that... In practice, it may actually depend on what order the widgets get rendered. If some other widget has set "fl_fontsize" already before your widget calls fl_draw(...) then it may Just Work for you. Though what font you actually get might vary from redraw to redraw. That is, if you have a widget that uses fl_draw(...) but which does not explicitly set its own font, and you have other widgets that are rendered using a variety of fonts, then there is a real chance that your widget will be rendered with a different font each time it is redrawn, depending on which other widget was last redrawn previously. So, we could maybe make a "fallback" substitution but in practice that might not be the best option - having it fail early and consistently might be easier to debug and fix! Thoughts? Also, harking back to your example program, I would caution that your ought really to explicitly set the tw, th values to zero before calling fl_measure(...) as otherwise it may think you are defining a bounding box and attempt to wrap your passed text to fit in that box. It doesn't seem to be doing any harm in your example, but it looks like a potential bug, I think. And actually, I think I would use fl_text_extents() anyway in that particular case! Cheers, -- Ian SELEX Galileo Ltd Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL A company registered in England & Wales. Company no. 02426132 ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ******************************************************************** _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
