/******************************************************************************* | |
* <copyright> | |
* | |
* Copyright (c) 2013, 2013 SAP AG. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* SAP AG - initial API, implementation and documentation | |
* | |
* </copyright> | |
* | |
*******************************************************************************/ | |
package org.eclipse.fmc.blockdiagram.editor.util; | |
import java.util.Arrays; | |
import java.util.HashSet; | |
import java.util.Set; | |
import org.eclipse.swt.graphics.FontData; | |
import org.eclipse.swt.widgets.Display; | |
/** | |
* Utility class for fonts. Not intended to be instantiated. | |
* | |
* @author Rainer Thome | |
* | |
*/ | |
public class FontUtils { | |
private FontUtils(){} | |
/** | |
* Returns a list of all available fonts. | |
* | |
* @return string array of available font names | |
*/ | |
public static String[] getFontNames() { | |
Set<String> stringItems = new HashSet<String>(); | |
FontData[] fontDatas = Display.getDefault().getFontList(null, true); | |
for (int i = 0; i < fontDatas.length; i++) { | |
if (fontDatas[i].getName() != null) { | |
stringItems.add(fontDatas[i].getName()); | |
} | |
} | |
// add strings into the array | |
String strings[] = new String[stringItems.size()]; | |
int i = 0; | |
for (String item : stringItems) { | |
strings[i++] = item; | |
} | |
// sort the array | |
Arrays.sort(strings); | |
return strings; | |
} | |
/** | |
* List of predefined font sizes. | |
*/ | |
public static String[] FONT_SIZES = new String[] { "8", "9", "10", "11", | |
"12", "14", "16", "18", "20", "22", "24", "26", "28", "36", "48", | |
"72" }; | |
} |