Use of FL_FREE_FONT crashes?

16 views
Skip to first unread message

lifeatt...@gmail.com

unread,
Jul 22, 2021, 11:36:06 AM7/22/21
to fltk.general
A quick sanity check before I submit a sample / issue.

Was toying with some code which happened to set the tooltip font to FL_FREE_FONT. When attempting to show the tooltip, I got a crash in Fl_Xlib_Graphics_Driver::get_font_name - as the font name is NULL.

Linux Mint 20.2, FLTK 1.4 built from source a couple of weeks ago.

To be expected?
Thanks,
Kevin

Albrecht Schlosser

unread,
Jul 22, 2021, 12:38:54 PM7/22/21
to fltkg...@googlegroups.com
Yes. You need to assign a font [1] to FL_FREE_FONT. This is the first *free* (i.e. unassigned) font number.

I think what you need is Fl::set_font() to set a system font with a given name
[1] https://www.fltk.org/doc-1.4/group__fl__attributes.html#ga15dee80a622a9ab2798acfdc0aabcd95

lifeatt...@gmail.com

unread,
Jul 22, 2021, 1:09:21 PM7/22/21
to fltk.general
>Yes. You need to assign a font [1] to FL_FREE_FONT. This is the first *free* (i.e. unassigned) font number.

Thanks, Albrecht! I figured I was missing something - playing with code out-of-context.

imm

unread,
Jul 22, 2021, 3:28:25 PM7/22/21
to General FLTK
Hi Kevin,

Yes, as Albrecht says, FL_FREE_FONT gives the index for the first unassigned (thus free) font entry.

So you can assign your own font to that index (or higher.) 

But if you use it before a face is assigned to it, then it will be null...
-- 
Ian
From my Fairphone FP3

Reply all
Reply to author
Forward
0 new messages