FLTK logo

Re: [fltk.general] setting font in fltk

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
[  All Forums  |  Back to fltk.general  ]
 
[ Previous Message ] [ New Message | Reply ] [ Next Message ]

Re: setting font in fltk "'Albrecht Schlosser' via fltk.general" Oct 29, 2025  
 
On 10/29/25 20:34 'Klaus Rudolph' via fltk.general wrote:
I copied a bit of code from test/fonts.cxx

Which bit?

I was able to get a list of font names and the index of the list
e.g. I found something like


Nr: 43 Attrib:  name BPdots
Nr: 44 Attrib: Bold  name BPdots bold
Nr: 45 Attrib:  name BPdots Light
Nr: 46 Attrib:  name BPdotsDiamond
...
which means, font with name "BPdots bold" has index 44.

Yes, I assume you called something like Fl::set_fonts(...) in the "bit of code" mentioned above. Correct?

My question is:

If I have the name like "BPdots bold", how can I set my font? OK, I can run through the list and get the index. But I expect there is some function, which already do this for me.

Yes, this is not how it should be done. Setting "all" fonts like - I assume you did - above is wateful.

I tried:

            Fl::set_font( 1, "BPdots" );
            fl_font( 1, 40 );

or
            Fl::set_font( 1, "BPdots bold" );
            fl_font( 1, 40 );

Both this did not select the font I want to see. ( or maybe did nothing )

Please check the documentation of Fl::set_font(fnum, name):
https://www.fltk.org/doc-1.4/group__fl__attributes.html#ga15dee80a622a9ab2798acfdc0aabcd95

Any hints how I can achieve this? Is there some more documentation?

As you can see in the docs mentioned above, this is - like the available font names - platform specific. On some platforms (see docs) you need to add one character before the font name. On some platforms you need only the family name, on others the full font name.

Which platform are you using for your tests?

BTW: I use # 1 in Fl::set_font( 1, "BPdots" ); But can I have some "free" number? Maybe totally on the wrong path?

The first "free" font number (i.e. the first font that's not loaded automatically at startup) is FL_FREE_FONT. You can use this and the following font numbers to load your own, specific fonts.

If you have further questions after reading the docs, please feel free to ask again, but please post more details about your platform and code.

--
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 visit https://groups.google.com/d/msgid/fltkgeneral/0eed9f7b-0d7d-4dd4-a661-4ee74dffcfea%40aljus.de.
[ Direct Link to Message ]
 
     
[ Previous Message ] [ New Message | Reply ] [ Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.