I am trying to start learning how to use the FLTK GUI tool kit to make a basic text editor and I'm having a problem with this simple Hello World from the documentation tutorial.
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int main(int argc, char **argv) {
Fl_Window *window = new Fl_Window(340,180);
Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return Fl::run();
}
The program compiles without problems but the text displayed is in a very small font that is neither bold nor italic when it should be. Changing the value of labelsize() doesn't affect the font neither.
I have run the ./fonts program provided in the test folder of the FLTK distribution and most of the fonts displayed there are in the same default unresizable font. Only a few fonts there appear in bold and italic and are resizable.
I have downloaded MS TrueType fonts and rebuilt my font cache but that didn't resolved the issue. I have Linux Mint with XFCE running on a virtual machine. Also I am new to programming and to Linux so please bear with me! I have been trying to solve this all day without finding what I am doing wrong. Can you help me?
I was missing a library dependency of FLTK. Installing the libftgl2 package, a "library to render text in OpenGL using FreeType", made the fonts display properly when using FLTK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With