3.9 Widgets and fonts

When the user starts an application, it sets the default font to be used for all widgets. On Windows platforms the application obtains the default font from the desktop settings. On Linux platforms the default font is Helvetica.

The application can issue a command to change its default font. After the command is issued, all widgets created by the application use the new font. Alternatively, you can change an individual widget’s font by using the setFont method that is available for many widgets.

You use the getAFXFont method to obtain the current font setting for a widget. Possible fonts are:

The following example shows how you can change the default font for all widgets and the font for a particular widget:

    # Get the current default font.
    normalFont = getAFXApp().getNormalFont()

    # Set the font to bold for subsequently created widgets.
    getAFXApp().setNormalFont( getAFXFont(FONT_BOLD) )
    FXLabel(self, 'Bold font')

    # Restore the default font.
    getAFXApp().setNormalFont( normalFont )

    # Set the font of a widget after it is created.
    l = FXLabel(self, 'Sample text')
    l.setFont( getAFXFont(FONT_MONOSPACE) )