aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-01 15:13:17 +0200
committerSven Gothel <[email protected]>2011-04-01 15:13:17 +0200
commitd4c400b9e70550bc93ebc2c0df2cd916b9ea0b3b (patch)
tree38f1b53b1aeb5af4b12e9a3901ee45a2da690ee3 /src/jogl/classes/com/jogamp/graph
parentf47753b63c9530a6af36cb69135dee0421abfe6b (diff)
Load fonts via File or URL .
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph')
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontFactory.java37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
index 1752a693c..9bf4b1f73 100644
--- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
+++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
@@ -27,7 +27,12 @@
*/
package com.jogamp.graph.font;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import com.jogamp.common.util.ReflectionUtil;
@@ -58,8 +63,6 @@ public class FontFactory {
fontConstr = (FontConstructor) ReflectionUtil.createInstance(fontImplName, FontFactory.class.getClassLoader());
}
- public static final FontConstructor getFontConstr() { return fontConstr; }
-
public static final FontSet getDefault() {
return get(UBUNTU);
}
@@ -73,8 +76,34 @@ public class FontFactory {
}
}
- public static final Font get(String path) {
- return fontConstr.create(path);
+ public static final Font get(File file) throws IOException {
+ return fontConstr.create(file);
}
+ public static final Font get(final URL url) throws IOException {
+ final IOException[] ioeA = new IOException[1];
+
+ Font f = (Font) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ return fontConstr.create(url);
+ } catch (IOException ioe) {
+ ioeA[0] = ioe;
+ }
+ return null;
+ }
+ });
+ if(null != ioeA[0]) {
+ throw ioeA[0];
+ }
+ return f;
+ }
+
+ public static boolean isPrintableChar( char c ) {
+ Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
+ return (!Character.isISOControl(c)) &&
+ c != 0 &&
+ block != null &&
+ block != Character.UnicodeBlock.SPECIALS;
+ }
}