/**
 * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Eclipse Public License (EPL).
 * Please see the license.txt included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */
package org.python.pydev.shared_ui;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.python.pydev.shared_core.structure.Tuple;

/**
 * <p><tt>FontUtils</tt> provides helper methods dealing with
 * <tt>Font</tt>s.</p>
 * 
 * @author André Berg
 * @version 0.1
 */
public class FontUtils {

    /**
     * Selects a proper font name and height for various usage cases of monospaced fonts throughout Pydev.
     * 
     * @param usage intended usage. See {@link IFontUsage} for valid values.
     * @return a {@link Tuple} containing the font name as {@link String} and the base height as {@link Integer}.
     * @throws IllegalArgumentException if <tt>usage</tt> is not found in {@link IFontUsage}.
     */
    private static Tuple<String, Integer> getCodeFontNameAndHeight(int usage) throws IllegalArgumentException {
        String fontName = "Courier New";
        int fontHeight = 10;
        if (Platform.getOS().equals(Constants.OS_MACOSX)) {
            switch (usage) {
                case IFontUsage.STYLED:
                    fontName = "Monaco";
                    fontHeight = 11;
                    break;
                case IFontUsage.DIALOG:
                    // on OS X we need a different font because 
                    // under Mac SWT the bitmap font rasterizer 
                    // doesn't take hinting into account and thus 
                    // makes small fonts rendered as bitmaps unreadable
                    // see http://aptanastudio.tenderapp.com/discussions/problems/2052-some-dialogs-have-unreadable-small-font-size
                    fontName = "Courier";
                    fontHeight = 11;
                    break;
                case IFontUsage.WIDGET:
                    fontName = "Monaco";
                    fontHeight = 9;
                    break;
                case IFontUsage.IMAGECACHE:
                    fontName = "Monaco";
                    fontHeight = 11;
                    break;

                default:
                    throw new IllegalArgumentException(
                            "Invalid usage. See org.python.pydev.core.IFontUsage for valid values.");
            }
        } else {
            switch (usage) {
                case IFontUsage.STYLED:
                    fontName = "Courier New";
                    fontHeight = 10;
                    break;
                case IFontUsage.DIALOG:
                    fontName = "Courier New";
                    fontHeight = 8;
                    break;
                case IFontUsage.WIDGET:
                    fontName = "Courier New";
                    fontHeight = 10;
                    break;
                case IFontUsage.IMAGECACHE:
                    fontName = "Courier New";
                    fontHeight = 9;
                    break;

                default:
                    throw new IllegalArgumentException(
                            "Invalid usage. See org.python.pydev.core.IFontUsage for valid values.");
            }
        }
        return new Tuple<String, Integer>(fontName, fontHeight);
    }

    public static FontData getFontData(int usage, boolean useDefaultJFaceFontIfPossible) {
        if (useDefaultJFaceFontIfPossible) {
            FontData[] textFontData = JFaceResources.getTextFont().getFontData();
            if (textFontData.length == 1) {
                return textFontData[0];
            }
        }
        Tuple<String, Integer> codeFontDetails = FontUtils.getCodeFontNameAndHeight(IFontUsage.IMAGECACHE);
        String fontName = codeFontDetails.o1;
        int base = codeFontDetails.o2.intValue();
        return new FontData(fontName, base, SWT.BOLD);
    }
}

@@ -3557,51 +3557,768 @@
     
-public static FontData getFontData(int usag
+%0A    /**%0A     * Calls %7B@link #getFontData(int, boolean)%7D with %7B@link SWT#NONE%7D for the style param.%0A     * @see %7B@link #getFontData(int, int, boolean)%7D%0A     */%0A    public static FontData getFontData(int usage, boolean useDefaultJFaceFontIfPossible) %7B%0A        return getFontData(usage, SWT.NONE, useDefaultJFaceFontIfPossible);%0A    %7D%0A    %0A    /**%0A     * Select a monospaced font based on intended usage. %0A     * Can be used to provide a consistend code font size between platforms.%0A     * %0A     * @param usage intended usage. See %7B@link IFontUsage%7D for valid values.%0A     * @param style SWT style constants mask%0A     * @param useDefaultJFaceFontIfPossible%0A     * @return %7B@link FontData%7D object%0A     */%0A    public static FontData getFontData(int usage, int styl
 e, b
@@ -4676,37 +4676,21 @@
 dHeight(
-IFontUsage.IMAGECACHE
+usage
 );%0A     
@@ -4828,16 +4828,13 @@
 se, 
-SWT.BOLD
+style
 );%0A 

Add getFontData method to FontUtils that allows for specifying a SWT style other than BOLD.