aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-15 15:07:39 +0200
committerSven Gothel <[email protected]>2011-09-15 15:07:39 +0200
commit54b92eb3240d3d6e4686faf48504e1ecfb385869 (patch)
tree780a38150afd1885199f66a8e1558e509fba0477
parentd341b3160c4af3bc1efb91c995abb44368f628a5 (diff)
Graph Fonts: Decorate w/ PrivilegedAction if required
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontFactory.java17
-rw-r--r--src/jogl/classes/jogamp/graph/font/JavaFontLoader.java20
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java26
3 files changed, 34 insertions, 29 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
index 1e83668de..65799db6f 100644
--- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
+++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
@@ -80,22 +80,7 @@ public class FontFactory {
}
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;
+ return fontConstr.create(url);
}
public static boolean isPrintableChar( char c ) {
diff --git a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
index bead9a5d2..6b8260668 100644
--- a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
+++ b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
@@ -29,6 +29,8 @@ package jogamp.graph.font;
import java.io.File;
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import javax.media.opengl.GLException;
@@ -60,7 +62,16 @@ public class JavaFontLoader implements FontSet {
final String javaFontPath;
private JavaFontLoader() {
- javaFontPath = System.getProperty("java.home") + "/lib/fonts/";
+ final String javaHome = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("java.home");
+ }
+ });
+ if(null != javaHome) {
+ javaFontPath = javaHome + "/lib/fonts/";
+ } else {
+ javaFontPath = null;
+ }
}
// FIXME: Add cache size to limit memory usage
@@ -87,7 +98,9 @@ public class JavaFontLoader implements FontSet {
} else {
font = abspath(availableFontFileNames[4], family, style);
}
- fontMap.put( ( family << 8 ) | style, font );
+ if(null != font) {
+ fontMap.put( ( family << 8 ) | style, font );
+ }
return font;
}
@@ -123,6 +136,9 @@ public class JavaFontLoader implements FontSet {
}
Font abspath(String fname, int family, int style) {
+ if(null == javaFontPath) {
+ throw new GLException("java font path undefined");
+ }
final String err = "Problem loading font "+fname+", file "+javaFontPath+fname ;
try {
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
index 126328ad7..408db555d 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
@@ -45,20 +45,24 @@ import com.jogamp.graph.font.Font;
public class TypecastFontConstructor implements FontConstructor {
- public Font create(File ffile) throws IOException {
- OTFontCollection fontset;
- try {
- fontset = OTFontCollection.create(ffile);
- return new TypecastFont(fontset);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
+ public Font create(final File ffile) throws IOException {
+ return AccessController.doPrivileged(new PrivilegedAction<Font>() {
+ public Font run() {
+ OTFontCollection fontset;
+ try {
+ fontset = OTFontCollection.create(ffile);
+ return new TypecastFont(fontset);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ });
}
public Font create(final URL furl) throws IOException {
- return (Font) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ return AccessController.doPrivileged(new PrivilegedAction<Font>() {
+ public Font run() {
File tf = null;
int len=0;
Font f = null;