Changeset 5797 in josm for trunk/src/org


Ignore:
Timestamp:
2013-03-22T23:47:54+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #8488 - Do not use Helvetica font when it is not available

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r5493 r5797  
    7070        JPanel info = new JPanel(new GridBagLayout());
    7171        JLabel caption = new JLabel("JOSM – " + tr("Java OpenStreetMap Editor"));
    72         caption.setFont(new Font("Helvetica", Font.BOLD, 20));
     72        caption.setFont(GuiHelper.getTitleFont());
    7373        info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
    7474        info.add(GBC.glue(0,10), GBC.eol());
  • trunk/src/org/openstreetmap/josm/gui/SplashScreen.java

    r5015 r5797  
    2828import org.openstreetmap.josm.gui.progress.ProgressRenderer;
    2929import org.openstreetmap.josm.gui.progress.SwingRenderingProgressMonitor;
     30import org.openstreetmap.josm.gui.util.GuiHelper;
    3031import org.openstreetmap.josm.tools.ImageProvider;
    3132import org.openstreetmap.josm.tools.WindowGeometry;
     
    6465        // Add the name of this application
    6566        JLabel caption = new JLabel("JOSM - " + tr("Java OpenStreetMap Editor"));
    66         caption.setFont(new Font("Helvetica", Font.BOLD, 20));
     67        caption.setFont(GuiHelper.getTitleFont());
    6768        gbc.gridheight = 1;
    6869        gbc.gridx = 1;
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r5790 r5797  
    99import java.awt.Dialog;
    1010import java.awt.Dimension;
     11import java.awt.Font;
     12import java.awt.GraphicsEnvironment;
    1113import java.awt.Image;
    1214import java.awt.Stroke;
     
    1820import java.awt.image.FilteredImageSource;
    1921import java.lang.reflect.InvocationTargetException;
     22import java.util.Arrays;
     23import java.util.List;
    2024
    2125import javax.swing.GrayFilter;
     
    212216    }
    213217   
     218    /**
     219     * Gets the font used to display JOSM title in about dialog and splash screen.
     220     * @return By order or priority, the first font available in local fonts:
     221     *         1. Helvetica Bold 20
     222     *         2. Calibri Bold 23
     223     *         3. Arial Bold 20
     224     *         4. SansSerif Bold 20
     225     * @since 5797
     226     */
     227    public static Font getTitleFont() {
     228        List<String> fonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
     229        // Helvetica is the preferred choice but is not available by default on Windows
     230        // (http://www.microsoft.com/typography/fonts/product.aspx?pid=161)
     231        if (fonts.contains("Helvetica")) {
     232            return new Font("Helvetica", Font.BOLD, 20);
     233        // Calibri is the default Windows font since Windows Vista but is not available on older versions of Windows, where Arial is preferred
     234        } else if (fonts.contains("Calibri")) {
     235            return new Font("Calibri", Font.BOLD, 23);
     236        } else if (fonts.contains("Arial")) {
     237            return new Font("Arial", Font.BOLD, 20);
     238        // No luck, nothing found, fallback to one of the 5 fonts provided with Java (Serif, SansSerif, Monospaced, Dialog, and DialogInput)
     239        } else {
     240            return new Font("SansSerif", Font.BOLD, 20);
     241        }
     242    }
    214243}
Note: See TracChangeset for help on using the changeset viewer.