FLTK logo

[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 ]

setting font in fltk "'Klaus Rudolph' via fltk.general" Oct 29, 2025  
 
I copied a bit of code from test/fonts.cxx

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
Nr: 47 Attrib: Bold  name BPdotsDiamond bold
Nr: 48 Attrib:  name BPdotsDiamond Light
Nr: 49 Attrib:  name BPdotsMinus
Nr: 50 Attrib: Bold  name BPdotsMinus bold
Nr: 51 Attrib:  name BPdotsPlus
Nr: 52 Attrib: Bold  name BPdotsPlus bold
Nr: 53 Attrib:  name BPdotsSquares
Nr: 54 Attrib: Bold  name BPdotsSquares bold
Nr: 55 Attrib:  name BPdotsSquares Light
Nr: 56 Attrib:  name BPdotsVertical
Nr: 57 Attrib: Bold  name BPdotsVertical bold

which means, font with name "BPdots bold" has index 44.

If I do:
fl_font(44, 40);
fl_draw( "Hallo world", 10,20);

it works as expected, I got the selected font in size 40. Perfect!

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. 

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 )

Any hints how I can achieve this? Is there some more documentation? BTW: I use # 1 in Fl::set_font( 1, "BPdots" ); But can I have some "free" number? Maybe totally on the wrong path?

Regards
 Klaus



--
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/e763b70c-1c60-4612-b729-12241f918bcdn%40googlegroups.com.
[ 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'.