aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontSet.java6
-rw-r--r--src/jogl/classes/jogamp/graph/font/JavaFontLoader.java10
-rw-r--r--src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java11
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java16
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java62
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java43
8 files changed, 109 insertions, 58 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/FontSet.java b/src/jogl/classes/com/jogamp/graph/font/FontSet.java
index 0cee81124..d376922ab 100644
--- a/src/jogl/classes/com/jogamp/graph/font/FontSet.java
+++ b/src/jogl/classes/com/jogamp/graph/font/FontSet.java
@@ -27,6 +27,8 @@
*/
package com.jogamp.graph.font;
+import java.io.IOException;
+
public interface FontSet {
@@ -54,7 +56,7 @@ public interface FontSet {
/** ITALIC style bit flag */
public static final int STYLE_ITALIC = 1 << 3;
- Font getDefault();
+ Font getDefault() throws IOException ;
- Font get(int family, int stylebits);
+ Font get(int family, int stylebits) throws IOException ;
}
diff --git a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
index 6b8260668..a00e9579c 100644
--- a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
+++ b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
@@ -81,11 +81,11 @@ public class JavaFontLoader implements FontSet {
return 0 != ( bits & bit ) ;
}
- public Font getDefault() {
+ public Font getDefault() throws IOException {
return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular
}
- public Font get(int family, int style) {
+ public Font get(int family, int style) throws IOException {
Font font = (Font)fontMap.get( ( family << 8 ) | style );
if (font != null) {
return font;
@@ -135,7 +135,7 @@ public class JavaFontLoader implements FontSet {
return font;
}
- Font abspath(String fname, int family, int style) {
+ Font abspath(String fname, int family, int style) throws IOException {
if(null == javaFontPath) {
throw new GLException("java font path undefined");
}
@@ -147,9 +147,9 @@ public class JavaFontLoader implements FontSet {
fontMap.put( ( family << 8 ) | style, f );
return f;
}
- throw new GLException(err);
+ throw new IOException (err);
} catch (IOException ioe) {
- throw new GLException(err, ioe);
+ throw new IOException(err, ioe);
}
}
}
diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
index 572955fd3..e2c79a5a8 100644
--- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
+++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
@@ -71,12 +71,11 @@ public class UbuntuFontLoader implements FontSet {
return 0 != ( bits & bit ) ;
}
- public Font getDefault() {
+ public Font getDefault() throws IOException {
return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular
}
- public Font get(int family, int style)
- {
+ public Font get(int family, int style) throws IOException {
Font font = (Font)fontMap.get( ( family << 8 ) | style );
if (font != null) {
return font;
@@ -119,7 +118,7 @@ public class UbuntuFontLoader implements FontSet {
return font;
}
- Font abspath(String fname, int family, int style) {
+ Font abspath(String fname, int family, int style) throws IOException {
final String err = "Problem loading font "+fname+", stream "+relPath+fname;
try {
URL url = IOUtil.getResource(UbuntuFontLoader.class, relPath+fname);
@@ -131,9 +130,9 @@ public class UbuntuFontLoader implements FontSet {
fontMap.put( ( family << 8 ) | style, f );
return f;
}
- throw new GLException(err);
+ throw new IOException(err);
} catch(IOException ioe) {
- throw new GLException(err, ioe);
+ throw new IOException(err, ioe);
}
}
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
index a9e5524c8..49e8a5826 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
@@ -44,18 +44,24 @@ import com.jogamp.graph.font.Font;
public class TypecastFontConstructor implements FontConstructor {
public Font create(final File ffile) throws IOException {
- return AccessController.doPrivileged(new PrivilegedAction<Font>() {
- public Font run() {
+ Object o = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
OTFontCollection fontset;
try {
fontset = OTFontCollection.create(ffile);
return new TypecastFont(fontset);
} catch (IOException e) {
- e.printStackTrace();
+ return e;
}
- return null;
}
- });
+ });
+ if(o instanceof Font) {
+ return (Font)o;
+ }
+ if(o instanceof IOException) {
+ throw (IOException)o;
+ }
+ throw new InternalError("Unexpected Object: "+o);
}
public Font create(final URL furl) throws IOException {
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
index 53a8890bc..4a041604d 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
@@ -107,7 +107,7 @@ public class OTFontCollection {
_fileName = file.getName();
if (!file.exists()) {
- throw new IOException();
+ throw new IOException("File <"+file.getName()+"> doesn't exist.");
}
// Do we need to modify the path name to deal with font resources
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
index ad662e000..97c9d905c 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
@@ -29,7 +29,6 @@ package com.jogamp.opengl.test.junit.graph.demos;
import java.io.IOException;
-import javax.media.opengl.FPSCounter;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAnimatorControl;
@@ -41,7 +40,6 @@ import com.jogamp.graph.curve.opengl.TextRenderer;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.AABBox;
-import com.jogamp.graph.geom.Vertex;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.opengl.GLWindow;
@@ -103,13 +101,18 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
boolean userInput = false;
public GPUTextRendererListenerBase01(RenderState rs, int modes, boolean debug, boolean trace) {
- super(TextRenderer.create(rs, modes), modes, debug, trace);
- this.font = FontFactory.get(fontSet).getDefault();
- dumpFontNames();
-
- this.fontName = font.toString();
- this.fontNameBox = font.getStringBounds(fontName, fontSizeFixed*2);
- switchHeadBox();
+ super(TextRenderer.create(rs, modes), modes, debug, trace);
+ try {
+ this.font = FontFactory.get(fontSet).getDefault();
+ dumpFontNames();
+
+ this.fontName = font.toString();
+ this.fontNameBox = font.getStringBounds(fontName, fontSizeFixed*2);
+ switchHeadBox();
+ } catch (IOException ioe) {
+ System.err.println("Catched: "+ioe.getMessage());
+ ioe.printStackTrace();
+ }
}
void dumpFontNames() {
@@ -198,18 +201,39 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
dumpMatrix(true);
}
- public void nextFontSet() {
- fontSet = ( fontSet == FontFactory.UBUNTU ) ? FontFactory.JAVA : FontFactory.UBUNTU ;
- font = FontFactory.get(fontSet).getDefault();
- this.fontName = font.getFullFamilyName(null).toString();
- this.fontNameBox = font.getStringBounds(fontName, fontSizeFixed*3);
- dumpFontNames();
+ public boolean nextFontSet() {
+ try {
+ int set = ( fontSet == FontFactory.UBUNTU ) ? FontFactory.JAVA : FontFactory.UBUNTU ;
+ Font _font = FontFactory.get(set).getDefault();
+ if(null != _font) {
+ fontSet = set;
+ font = _font;
+ fontName = font.getFullFamilyName(null).toString();
+ fontNameBox = font.getStringBounds(fontName, fontSizeFixed*3);
+ dumpFontNames();
+ return true;
+ }
+ } catch (IOException ex) {
+ System.err.println("Catched: "+ex.getMessage());
+ }
+ return false;
}
- public void setFontSet(int set, int family, int stylebits) {
- fontSet = set;
- font = FontFactory.get(fontSet).get(family, stylebits);
- dumpFontNames();
+ public boolean setFontSet(int set, int family, int stylebits) {
+ try {
+ Font _font = FontFactory.get(set).get(family, stylebits);
+ if(null != _font) {
+ fontSet = set;
+ font = _font;
+ fontName = font.getFullFamilyName(null).toString();
+ fontNameBox = font.getStringBounds(fontName, fontSizeFixed*3);
+ dumpFontNames();
+ return true;
+ }
+ } catch (IOException ex) {
+ System.err.println("Catched: "+ex.getMessage());
+ }
+ return false;
}
public boolean isUserInputMode() { return userInput; }
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
index 5abc181a8..c0d7f00e9 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
@@ -1,5 +1,7 @@
package com.jogamp.opengl.test.junit.graph.demos;
+import java.io.IOException;
+
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAnimatorControl;
@@ -81,7 +83,12 @@ public class GPUUISceneGLListener0A implements GLEventListener {
this.debug = debug;
this.trace = trace;
- font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ try {
+ font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ } catch (IOException ioe) {
+ System.err.println("Catched: "+ioe.getMessage());
+ ioe.printStackTrace();
+ }
labelRegions = new UIRegion[3];
sceneUIController = new SceneUIController();
}
@@ -211,7 +218,13 @@ public class GPUUISceneGLListener0A implements GLEventListener {
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2();
}
- this.font = FontFactory.get(fontSet).getDefault();
+ try {
+ font = FontFactory.get(fontSet).getDefault();
+ } catch (IOException ioe) {
+ System.err.println("Catched: "+ioe.getMessage());
+ ioe.printStackTrace();
+ }
+
regionRenderer = RegionRenderer.create(rs, renderModes);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java
index 5f92f13ec..4da5cac10 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java
@@ -28,6 +28,8 @@
package com.jogamp.opengl.test.junit.graph.demos.ui;
+import java.io.IOException;
+
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
@@ -45,24 +47,29 @@ public class UIGLListener01 extends UIListenerBase01 {
public UIGLListener01 (RenderState rs, boolean debug, boolean trace) {
super(RegionRenderer.create(rs, 0), debug, trace);
setMatrix(-20, 00, 0f, -50);
- final Font font = FontFactory.get(FontFactory.UBUNTU).getDefault();
- button = new RIButton(SVertex.factory(), font, "Click me!", 4f, 3f){
- public void onClick() {
- }
- public void onPressed() {
- }
- public void onRelease() {
- }
-
- };
- button.setPosition(2,1,0);
- /** Button defaults !
- button.setLabelColor(1.0f,1.0f,1.0f);
- button.setButtonColor(0.6f,0.6f,0.6f);
- button.setCorner(1.0f);
- button.setSpacing(2.0f);
- */
- System.err.println(button);
+ try {
+ final Font font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ button = new RIButton(SVertex.factory(), font, "Click me!", 4f, 3f){
+ public void onClick() {
+ }
+ public void onPressed() {
+ }
+ public void onRelease() {
+ }
+
+ };
+ button.setPosition(2,1,0);
+ /** Button defaults !
+ button.setLabelColor(1.0f,1.0f,1.0f);
+ button.setButtonColor(0.6f,0.6f,0.6f);
+ button.setCorner(1.0f);
+ button.setSpacing(2.0f);
+ */
+ System.err.println(button);
+ } catch (IOException ex) {
+ System.err.println("Catched: "+ex.getMessage());
+ ex.printStackTrace();
+ }
}
public void init(GLAutoDrawable drawable) {