Tabular IQ

SystemFonts Class

Class Index By Category

Overview

The SystemFonts class provides access to the fonts the system uses, each read a fresh Font made from the current settings: changing the Font you got (setPointSize, say) changes only your copy. Default is the font the user interface is drawn in, what every control uses unless told otherwise; Monospace is a fixed-pitch font at the same size, for code and columns of figures. A heading is usually a derivation of Default, such as SystemFonts.Default.bold().scaled(1.4). The remaining members date from Windows' stock fonts and are kept for older scripts: AnsiFixedFont, AnsiVariableFont, OemFixedFont and SystemFont are bitmap fonts of fixed pixel size that do not scale with the display, SwissFont is the Swiss family (Arial) rather than a system font, and DefaultFont is the old spelling of Default.

Properties

SystemFonts.Default
The user interface font, what controls use.
SystemFonts.Monospace
A fixed-pitch font at the user interface size.
SystemFonts.DefaultFont
The same as Default; the older spelling.
SystemFonts.SwissFont
A font of the Swiss family (Arial); not a system font, kept for older scripts.
SystemFonts.AnsiFixedFont
Legacy: Windows' fixed-width stock font, a bitmap font that does not scale with the display.
SystemFonts.AnsiVariableFont
Legacy: Windows' variable-width stock font, a bitmap font that does not scale with the display.
SystemFonts.OemFixedFont
Legacy: the original equipment manufacturer's fixed-width stock font; does not scale with the display.
SystemFonts.SystemFont
Legacy: Windows' system stock font, a bitmap font that does not scale with the display.

Methods

SystemFonts.getInstalledFonts
Returns an array of the installed font facenames.

Example

// the fonts the system uses, read from SystemFonts: Default is the font
// every control draws in, Monospace a fixed-pitch font at the same size,
// and a heading is a derivation of Default.  Every read is a fresh Font
// and every derivation a copy, so nothing here changes the system's fonts
// or each other.

class FontsForm extends Form {
    constructor() {
        super("System Fonts", 0, 0, 480, 220);

        const layout = new BoxLayout(Layout.Vertical);

        // a heading: the user interface font, bold and two fifths larger;
        // the labels expand to the form's width, since a label is sized
        // for the font it had when it was made
        const heading = new Label("A heading: Default.bold().scaled(1.4)");
        heading.setFont(SystemFonts.Default.bold().scaled(1.4));

        // the user interface font itself, named by face and size
        const ui = SystemFonts.Default;
        const body = new Label("Default: " + ui.getFaceName() + ", " + ui.getPointSize() + " pt");
        body.setFont(ui);

        // a fixed-pitch font keeps columns of figures aligned
        const mono = SystemFonts.Monospace;
        const table = new Label("Monospace: " + mono.getFaceName() + "\n" +
                                "Jan      42\n" +
                                "Feb     158\n" +
                                "Mar    1073");
        table.setFont(mono);

        const flags = Layout.Expand | Layout.Left | Layout.Top | Layout.Right;
        layout.add(heading, 0, flags, 10);
        layout.add(body, 0, flags, 10);
        layout.add(table, 0, flags, 10);
        this.setLayout(layout);
    }
}

const f = new FontsForm();
f.center();
f.show();
Application.run();

SystemFonts.getInstalledFonts

static function SystemFonts.getInstalledFonts() : Array(String)

Returns

An array containing string values which represent the facenames of all the fonts that are installed on the system.

Description

Returns an array of the installed font facenames.