Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Horne2004-11-08 16:52:15 +0000
committerKim Horne2004-11-08 16:52:15 +0000
commitdcd6ff837faea8d9dfc6537c9de1743646db7625 (patch)
tree31da6c363132541a9db42c84d1a994aef7ec0b96 /bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java
parent395752c69c18e611d18b31d3c7da61039de22c60 (diff)
downloadeclipse.platform.ui-dcd6ff837faea8d9dfc6537c9de1743646db7625.tar.gz
eclipse.platform.ui-dcd6ff837faea8d9dfc6537c9de1743646db7625.tar.xz
eclipse.platform.ui-dcd6ff837faea8d9dfc6537c9de1743646db7625.zip
Fix for 56973 - [Themes] FontRegistry.bestDataArray() chops off all but the first "good" font
Diffstat (limited to 'bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java')
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java49
1 files changed, 47 insertions, 2 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java
index 44ece6c50b3..20c2c0b1f26 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java
@@ -379,6 +379,8 @@ public class FontRegistry extends ResourceRegistry {
* Find the first valid fontData in the provided list.
* If none are valid return the first one regardless.
* If the list is empty return null.
+ * @deprecated use filterData in order to preserve
+ * multiple entry fonts on Motif
*/
public FontData[] bestDataArray(FontData[] fonts, Display display) {
@@ -391,6 +393,49 @@ public class FontRegistry extends ResourceRegistry {
return datas;
}
}
+
+ /**
+ * Removes from the list all fonts that do not exist in this system.
+ * If none are valid, return the first irregardless. If the list is
+ * empty return <code>null</code>.
+ *
+ * @param fonts the fonts to check
+ * @param display the display to check against
+ * @return the list of fonts that have been found on this system
+ * @since 3.1
+ */
+ public FontData [] filterData(FontData [] fonts, Display display) {
+ ArrayList good = new ArrayList(fonts.length);
+ for (int i = 0; i < fonts.length; i++) {
+ FontData fd = fonts[i];
+
+ if (fd == null)
+ continue;
+
+ FontData[] fixedFonts = display.getFontList(fd.getName(), false);
+ if (isFixedFont(fixedFonts, fd)) {
+ good.add(fd);
+ }
+
+ FontData[] scalableFonts = display.getFontList(fd.getName(), true);
+ if (scalableFonts.length > 0) {
+ good.add(fd);
+ }
+ }
+
+
+ //None of the provided datas are valid. Return the
+ //first one as it is at least the first choice.
+ if (good.isEmpty() && fonts.length > 0) {
+ good.add(fonts[0]);
+ }
+ else if (fonts.length == 0) {
+ return null;
+ }
+
+ return (FontData[]) good.toArray(new FontData[good.size()]);
+ }
+
/**
* Creates a new font with the given font datas or <code>null</code>
@@ -402,8 +447,8 @@ public class FontRegistry extends ResourceRegistry {
if (display == null)
return null;
- FontData[] validData = bestDataArray(fonts, display);
- if (validData == null) {
+ FontData[] validData = filterData(fonts, display);
+ if (validData.length == 0) {
//Nothing specified
return null;
} else {

Back to the top