| [ Return to Bugs & Features | Post Text | Post File | SVN ⇄ GIT | Prev | Next ]
STR #1029
Application: | FLTK Library |
Status: | 5 - New |
Priority: | 1 - Request for Enhancement, e.g. asking for a feature |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Core Library |
Summary: | Fl::font(), Fl::size(), etc. for changing defaults |
Version: | 1.4-feature |
Created By: | greg.ercolano |
Assigned To: | Unassigned |
Fix Version: | Unassigned |
Update Notification: | |
Trouble Report Files:
[ Post File ]No files
Trouble Report Comments:
[ Post Text ]
|
#1 | greg.ercolano 17:12 Sep 21, 2005 |
| Would be nice if there was a way to get/set the default font, size, etc. using Fl:: methods such as Fl::font(), Fl::size(), instead of this approach: http://fltk.org/newsgroups.php?s6582+gfltk.general+v6588+T ..which seems 'unexpected' from an API perspective.
Additionally, it would be great if one could easily enable/disable global things like symbols, instead of the effort needed such as: http://seriss.com/people/erco/fltk/#DisableSymbols eg: Fl::symbols(FL_NO_SYMBOLS) | |
|
#2 | matt 01:54 Jan 20, 2023 |
| You can set the default font size by changing `Fl_Fontsize FL_NORMAL_SIZE = 14;`. You can set the default font by calling `Fl::set_font(FL_HELVETICA, "my_fovourite_font")`.
Do we need extra calls for that? Should we add `Fl_Font FL_NORMA_FONT = FL_HELVETICA`? | |
|
#3 | AlbrechtS 05:09 Jan 20, 2023 |
| > You can set the default font size by changing `Fl_Fontsize FL_NORMAL_SIZE = 14;`
The problem with this "feature" is that the all-capital letters look like a macro and not like a (global) variable that can be changed. We could probably discourage using it and add a documented function as Greg proposed, but I would suggest a more self-explanatory name like Fl::default_fontsize(Fl_Fontsize fs).
Another potential problem with this default fontsize is (or might be?) that it is copied into widgets at construction time, hence it could be too late if the default fontsize is set during runtime, if my assumption is true.
> Should we add `Fl_Font FL_NORMAL_FONT = FL_HELVETICA`?
Probably not: this would have the same issue with the all-caps name. Again, I'd suggest a longer name, e.g. Fl::default_font(Fl_Font font). However, the same thoughts about static initialization apply here.
Whatever we change, the (static) initialization aspect should be considered and documented carefully.
These are only my thoughts, I didn't verify anything by looking at the code (e.g. is the default font really copied into widgets at construction time, and if yes, are all or only some widgets concerned?). I'm not going to investigate further, leaving this STR to others. | |
|
#4 | matt 05:27 Jan 20, 2023 |
| Both are copied at construction time, into labelsize and textsize if it is a widget with an input field.
It's different for Fl_Menu_Item. If textfont or textsize are 0, the default font and default size are used for `measure` and `draw` (which is bad for textfont, because if the default font were FL_SCREEN, you could never force the font to be FL_HELVETICA, because that's 0, and 0 sets the default value...) | |
[ Return to Bugs & Features | Post Text | Post File ]
|
| |