# :: Font Settings :: The JGoodies Looks 2.0 use a completely overhauled font lookup. On Windows this mechanism aims to use the native originals. On other platforms it uses the logical fonts defined by the Java environment. It is recommended to use the fonts suggested by the JGoodies Looks - at least on Windows. You can customize the fonts used by the JGoodies Windows L&f and the Plastic L&f family. You can set a fixed control and menu fonts, provide a set of fonts, or replace the default font lookup with a custom font policy. ## Setting the Control and Menu Font If you just want to set a specific font for the components and menu, set it in the system properties, either as a runtime argument or during the application start.
        java -DWindows.controlFont="Segoe UI-plain-15"
             -DPlastic.controlFont="Segoe UI-plain-15"
             ...

        java -DWindows.controlFont=Tahoma-plain-11
             -DWindows.menuFont=Tahoma-plain-12
             -DPlastic.controlFont=Tahoma-plain-11
             -DPlastic.menuFont=Tahoma-bold-11
    	     ...

        System.setProperty("Windows.controlFont", "Segoe UI-plain-15");
        System.setProperty("Plastic.controlFont", "Segoe UI-plain-15");
## FontSet and FontSets The JGoodies L&fs use instances of `FontSet` to describe the fonts used for the components, menus, tool tips, etc. The class `FontSets` vends predefined FontSet instances. Here's an example how to use a custom FontSet:
    FontSet fontSet = FontSets.createDefaultFontSet(
        new Font("Tahoma", Font.PLAIN, 11),    // control font
        new Font("Tahoma", Font.PLAIN, 12),    // menu font
        new Font("Tahoma", Font.BOLD, 11),     // title font
        );
    FontPolicy fixedPolicy = FontPolicies.createFixedPolicy(fontSet);
    PlasticLookAndFeel.setFontPolicy(fixedPolicy);
## FontPolicy and FontPolicies The JGoodies Windows L&f and the Plastic L&f family use a `FontPolicy` to determine the `FontSet` to be used. Typically a FontPolicy returns a FontSet that varies with the L&f, locale, platform, and platform settings such as the software display resolution or user desktop settings. Class `FontPolicies` vends predefined FontPolicy instances. Here's an example for a custom FontPolicy that sets custom fonts on a special platform:
    public final class MyPlasticFontPolicy implements FontPolicy {

        public FontSet getFontSet(String lafName, UIDefaults table) {
            if (MyFontUtils.IS_TAHOMA_AVAILABE) {
                Font controlFont = MyFonts.getTahoma();
                return FontSets.createDefaultFontSet(controlFont);
            }
            if (MySystemUtils.IS_OS_LINUX_UBUNTU) {
                return MyFontSets.getUbuntuFontSet();
            }
            FontPolicy default = FontPolicies.getDefaultPlasticFontPolicy().
            return default.getFontSet(lafName, table);
        }
    }

    // Instantiate my Plastic font policy.
    FontPolicy myPlasticFontPolicy = new MyPlasticFontPolicy();

    // Wrap the above to honor the System properties (Plastic.controlFont, etc).
    FontPolicy myFontPolicy = FontPolicies.customSettingsPolicy(
        myPlasticFontPolicy);

    // Set the wrapped policy.
    PlasticLookAndFeel.setFontPolicy(myFontPolicy);
## Fonts The `Fonts` class provides fonts and font names For popular Windows fonts. For example `Fonts.WINDOWS_XP_96DPI_NORMAL` is the default font on Windows XP with a 96dpi software resolution and a desktop font size Normal. This can be used to preview how your application looks in different environments:
    Font controlFont = Fonts.WINDOWS_VISTA_96DPI_NORMAL;
    FontSet fontSet = FontSets.createDefaultFontSet(controlFont);
    FontPolicy fontPolicy = FontPolicies.createFixedPolicy(fontSet);
    WindowsLookAndFeel.setFontPolicy(fontPolicy);
## Visual Backward Compatibility The JGoodies Looks 2.0 include `FontPolicies` that mimic the font lookup of the JGoodies Looks 1.x and one that can be used during a transition from 1.x to 2.0:
    WindowsLookAndFeel.setFontPolicy(FontPolicies.getLooks1xWindowsPolicy());
    PlasticLookAndFeel.setFontPolicy(FontPolicies.getLooks1xPlasticPolicy());

    PlasticLookAndFeel.setFontPolicy(FontPolicies.getTransitionalPlasticPolicy());
(c) 2006 JGoodies |  |