|
|
On 1/21/23 08:37, 'Matthias Melcher'
via fltk.general wrote:
The current solution is not the best solution, and it should not
break existing code. The background is the use of FLUID and other
tools in the command line. Depending on the OS, opening a
connection to the display may throw an error if the tool is
intended for the command line. So we try to leave all measuring of
fonts and other machine relevant data until the app calls
`show()`. This works generally very well, because font size
commonly don't need to be known until a widget is shown or drawn.
But as we see here, this is not always the case and can not always
be expected from the user.
I think too, IIRC, the font system initialization overhead is
significant enough on some
platforms should be delayed until absolutely necessary. Esp. so
that in FLTK applications
that even draw any text (pure graphics, like a speedometer on
embedded hardware)
the overhead can be avoided.
I hope we find a solution to that soon. Probably just calling
fl_open_display() whenever the graphics driver is requested, but
not yet initialised, ie enough. Other core devs?
I think the OP's problem (which he's since corrected) is
probably one of assuming
a font had already been set, as I *think* what he's saying is
he called the getter
version of fl_font(), e.g. "fl_font(void)", without
having first called fl_font(face,size) to set it,
which probably would have yielded "undefined behavior".
Anyway, he's since fixed the problem.
It's certainly a valid use (and documented) to call fl_font()
outside of draw(),
such as to measure text with fl_measure() during widget
construction, before graphics
has been initialized. I'm guessing fl_font(face,size) checks
if graphics has not yet been
initialized, and initializes it.. but fl_font(void) does not
(and perhaps shouldn't)
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/2fb79c31-50e5-a020-dd28-e73275d463e6%40seriss.com.
[ Direct Link to Message ] | |
|
| |