FOX Community

Recent site activity

Cookbook‎ > ‎

Using different font styles

Problem

You need to display some text with a different font style (for example displayed in bold)

Solution

You retrieve the "normal" font attributes, change the attributes you need and create a new FXFont object which subsequently can be used with the setFont() function of most widgets.

FXFontDesc fontdesc;

/// Get the font description,in this case, from the normal font.
getApp()->getNormalFont()->getFontDesc(fontdesc );

/// Change some of the attributes. Here we change the font weight, making it bolder.
fontdesc.weight+=200;

/// Based on the font description we create a new font object.
FXFont * thickfont = new FXFont(getApp(),fontdesc);

/// Do whatever you want with this font object
widget->setFont(thickfont);

/// Just don't forget to delete it when you're done with it.
delete thickfont;

Contributor(s)

Sander Jansen