Change GUI font size

1,034 views
Skip to first unread message

Thomas Mitterfellner

unread,
Mar 18, 2014, 2:42:07 PM3/18/14
to fltkg...@googlegroups.com
Hello!

Is there a way to generally increase the font size used in a FLTK based GUI, either at run time or at compile time?

Best regards,

Thomas

Greg Ercolano

unread,
Mar 18, 2014, 2:54:22 PM3/18/14
to fltkg...@googlegroups.com
On 03/18/14 11:42, Thomas Mitterfellner wrote:
> Hello!
>
> Is there a way to generally increase the font size used in a FLTK based GUI, either at run time or at compile time?

There isn't..

And if there was, it probably wouldn't work well anyway, as the fonts would
change but the widgets wouldn't. So you'd have to adjust the logic of your code
to take the font size into consideration (eg. make buttons larger, change widget
spacing, etc)

I had to do this in one of my apps.. it was kinda a pain, but the results
were great; one could read the app well on HD / retina displays.

I set up a global shortcut for Ctrl+ and Ctrl- to increase/decrease the
font sizes. It involved implementing my own resize() logic for my widgets
to handle the resizing. In my case, the app in question is a cpu monitoring tool..
an example of how it resizes:

http://seriss.com/rush.103.00/features/gifs/rushtop-103.05-font-adjust.png

Greg Ercolano

unread,
Mar 18, 2014, 3:04:46 PM3/18/14
to fltkg...@googlegroups.com
Oh, and I assumed you know you can change it on a per widget basis with
the usual w->labelsize(), etc, as that's how you'd control the font size
at runtime/compile time, and were only asking if there's a way to /globally/
(generally) adjust the font size of all widgets, which there isn't any way
that I know of I don't think. At least not in fltk 1.x

Ian MacArthur

unread,
Mar 18, 2014, 4:58:13 PM3/18/14
to fltkg...@googlegroups.com
On Tue Mar 18 2014 18:54:22, Greg Ercolano wrote:
>
> On 03/18/14 11:42, Thomas Mitterfellner wrote:
>> Hello!
>>
>> Is there a way to generally increase the font size used in a FLTK based GUI, either at run time or at compile time?
>
> There isn't..


Welllll.... That maybe isn’t *quite* true, depends on what the OP wants...

Once upon a time, the default font size in fltk was a

#define FL_NORMAL_SIZE 14

but along the way, that was changed (in Enumerations.h, from Fl_Widget.cxx) to be:

extern FL_EXPORT Fl_Fontsize FL_NORMAL_SIZE; (Enumerations.H)

Fl_Fontsize FL_NORMAL_SIZE = 14; (Fl_Widget.cxx)


So... That means that you can sort of change the default value for the font size now. If you set

FL_NORMAL_SIZE = 24;

In your code before you create/show your widgets, then you should get bigger text...

But:

>
> And if there was, it probably wouldn't work well anyway, as the fonts would
> change but the widgets wouldn't. So you'd have to adjust the logic of your code
> to take the font size into consideration (eg. make buttons larger, change widget
> spacing, etc)

Indeed, which is why messing about with FL_NORMAL_SIZE may not be the panacea the OP seeks...




Greg Ercolano

unread,
Mar 18, 2014, 5:35:52 PM3/18/14
to fltkg...@googlegroups.com
On 03/18/14 13:58, Ian MacArthur wrote:
> Fl_Fontsize FL_NORMAL_SIZE = 14; (Fl_Widget.cxx)

Thanks Ian, ya, was wondering if we had that
but was too lazy to look.

That should at least affect things like the default font size
of pulldown menus and labels and such if you don't change them.

I recall we discussed a bit the idea of adding a global
'font size offset' value that would normally be zero,
and if it were say +2, it would add two sizes to all fonts,
and if it were -2, subtract two sizes from all fonts..
something that could be applied below the actual fl_draw()
text string functions so that it affects 'everything'.

I don't think that'd be hard to add, and even though it might
have unexpected results for simple apps, perhaps having this
would allow the creation of higher level widgets to be designed
in the future that can intelligently size themselves with font sizes
taken into account.

Edzard Egberts

unread,
Mar 19, 2014, 3:05:46 AM3/19/14
to fltkg...@googlegroups.com
Thomas Mitterfellner schrieb:
> Hello!
>
> Is there a way to generally increase the font size used in a FLTK based
> GUI, either at run time or at compile time?

http://www.edzeg.net/komponenten/FLTK/font_size/


Reply all
Reply to author
Forward
0 new messages