On 19.10.2010, at 09:59, Duncan Gibson wrote:

> 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?

I don't think that "setting titles and labels" should be compared with
calling fl_draw(). I'm sure that the label drawing functions will
call fl_font(labelfont(),labelsize()) or something similar...


I imagine that f*L*tk doesn't call fl_font() for you before calling your
draw() method because of the 'L'(ight) in its name. Calling fl_font() can
probably be expensive (X server communication, seeking a font, etc.),
and doing this w/o knowing that you need a font for (text) drawing (and
which one) would be ineffective and/or wasting resources.


OTOH, if you call fl_draw() and didn't set a font before calling it, then
we could probably set a default font (and maybe this is done for XFT fonts
or some other cases - ISTR something like that). Maybe worth a look ?

... just found this in src/fl_font_x.cxx, line 321 et seq.:

void Fl_Graphics_Driver::draw(const char* c, int n, int x, int y) {
   if (font_gc != fl_gc) {
     if (!current_font) fl_font(FL_HELVETICA, 14);

IIRC there's been an STR (#2214) as well, but looking at this, it addressed
more than only forgetting to set up a font.


Duncan, on which platform (and if Linux: w/ or w/o XFT) did you run your
program?

Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to