diff options
-rw-r--r-- | jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html | 68 | ||||
-rw-r--r-- | jnlp-files/jogl-test-applets.html | 6 | ||||
-rw-r--r-- | make/build-common.xml | 1 | ||||
-rw-r--r-- | make/build-jogl.xml | 7 | ||||
-rw-r--r-- | make/scripts/tests.sh | 5 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java | 89 |
6 files changed, 160 insertions, 16 deletions
diff --git a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html new file mode 100644 index 000000000..c4c949487 --- /dev/null +++ b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html @@ -0,0 +1,68 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head> +<title>JOGL Graph Text Demo 01b (NApplet)</title> +</head> +<body BGCOLOR="#ffffff"> + +<P> +JOGL Graph Text Demo 01b (w/ atomic/jogl-fonts-p0.jar in path) +</P> + +<P> +<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" + width="800" height="400"> + <param name="code" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> + <param name="archive" value="jar/gluegen-rt.jar, + jar/jogl-all.jar, + jar/atomic/jogl-fonts-p0.jar, + jar/jogl-test.jar"> + <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> + <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.graph.demos.GPUTextGLListener0A"> + <param name="gl_profile" value="GL2ES2"> + <param name="gl_swap_interval" value="1"> + <param name="gl_alpha" value="4"> + <param name="gl_multisamplebuffer" value="4"> + <param name="gl_nodefaultkeyListener" value="true"> + <param name="gl_debug" value="false"> + <param name="gl_trace" value="false"> + <comment> + <embed code="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" + width="800" height="400" + type="application/x-java-applet;version=1.6" + pluginspage="http://java.sun.com/javase/downloads/ea.jsp" + archive="jar/gluegen-rt.jar, + jar/jogl-all.jar, + jar/atomic/jogl-fonts-p0.jar, + jar/jogl-test.jar" + java_arguments="-Dsun.java2d.noddraw=true" + gl_event_listener_class="com.jogamp.opengl.test.junit.graph.demos.GPUTextGLListener0A" + gl_profile="GL2ES2" + gl_swap_interval="1" + gl_alpha="4" + gl_multisamplebuffer="4" + gl_nodefaultkeyListener="true" + gl_debug="false" + gl_trace="false"> + <noembed>Sorry, no Java support detected.</noembed> + </embed> + </comment> +</object> +</P> + +<P> +Graph Text Demo Keys:<br> +<ul> + <li> 1/2 - zoom in/out red-text </li> + <li> 6/7 - edit texture size if using VBAA (nope) </li> + <li> 0/9 - rotate the red-text </li> + <li> v - toggle vsync </li> + <li> i - live text input (CR ends it, backspace supported)</li> + <li> f - toggle fps </li> + <li> h - change text</li> + <li> space - change font</li> +</ul> +</P> + +</body> +</html> diff --git a/jnlp-files/jogl-test-applets.html b/jnlp-files/jogl-test-applets.html index 76cd6effe..3ac2d5952 100644 --- a/jnlp-files/jogl-test-applets.html +++ b/jnlp-files/jogl-test-applets.html @@ -127,10 +127,12 @@ See Legend below table </td> <td> <a href="jogl-applet-runner-newt-GraphTextDemo01.html">Dual</a><br/> - <a href="jogl-applet-runner-newt-GraphTextDemo01-napplet.html">NApplet</a><br/> + <a href="jogl-applet-runner-newt-GraphTextDemo01-napplet.html">NApplet</a> + (<a href="jogl-applet-runner-newt-GraphTextDemo01b-napplet.html">cp-fonts</a>)<br/> </td> <td> - GPU accelerated Text Demo using JOGL's new Graph package. + GPU accelerated Text Demo using JOGL's new Graph package.<br/> + <small><i>cp-fonts</i> fonts via classpath, otherwise via URI</small>. </td> </tr> <tr> diff --git a/make/build-common.xml b/make/build-common.xml index e790ab42b..658359302 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -280,6 +280,7 @@ <property name="jogl-glmobile-dbg.jar" value="${build.jogl}/jogl-glmobile-dbg.jar" /> <property name="jogl-util.jar" value="${build.jogl}/jogl-util.jar" /> <property name="jogl-util-graph.jar" value="${build.jogl}/jogl-util-graph.jar" /> + <property name="jogl-util-graph-fonts-p0.jar" value="${build.jogl}/jogl-fonts-p0.jar" /> <property name="jogl-util-fixedfuncemu.jar" value="${build.jogl}/jogl-util-fixedfuncemu.jar" /> <property name="jogl-awt.jar" value="${build.jogl}/jogl-awt.jar" /> <property name="jogl-swt.jar" value="${build.jogl}/jogl-swt.jar" /> diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 8c30bb038..28b738b10 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1837,7 +1837,12 @@ </jar> <jar manifest="${build.jogl}/manifest.mf" destfile="${jogl-util-graph.jar}" filesonly="true"> <fileset dir="${classes}" - includes="${java.part.util.graph}"/> + includes="${java.part.util.graph}" + excludes="${java.part.util.graph.fonts}"/> + </jar> + <jar manifest="${build.jogl}/manifest.mf" destfile="${jogl-util-graph-fonts-p0.jar}" filesonly="true"> + <fileset dir="${classes}" + includes="${java.part.util.graph.fonts}"/> </jar> <jar manifest="${build.jogl}/manifest.mf" destfile="${jogl-util-fixedfuncemu.jar}" filesonly="true"> <fileset dir="${classes}" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index db16343c3..00d34e5a9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -210,6 +210,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" + D_ARGS="-Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false" @@ -475,7 +476,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* @@ -624,7 +625,7 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB8 # # Graph # -#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* +testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java index 9096f7d16..e1e44c92c 100644 --- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java +++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java @@ -28,22 +28,33 @@ package jogamp.graph.font; import java.io.IOException; -import javax.media.opengl.GLException; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.IOUtil; - +import com.jogamp.common.util.JarUtil; +import com.jogamp.common.util.cache.TempJarCache; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontSet; import com.jogamp.graph.font.FontFactory; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URLConnection; +import java.security.AccessController; +import java.security.PrivilegedAction; public class UbuntuFontLoader implements FontSet { // FIXME: Add cache size to limit memory usage private static final IntObjectHashMap fontMap = new IntObjectHashMap(); - private static final String relPath = "fonts/ubuntu/" ; + private static final String jarSubDir = "atomic/" ; + private static final String jarName = "jogl-fonts-p0.jar" ; + + private static final String relFontPath = "fonts/ubuntu/" ; + private static final String absFontPath = "jogamp/graph/font/fonts/ubuntu/" ; private static final FontSet fontLoader = new UbuntuFontLoader(); @@ -120,21 +131,77 @@ public class UbuntuFontLoader implements FontSet { return font; } - Font abspath(String fname, int family, int style) throws IOException { - final String err = "Problem loading font "+fname+", stream "+relPath+fname; + private static boolean attemptedJARLoading = false; + private static boolean useTempJarCache = false; + + private synchronized Font abspath(String fname, int family, int style) throws IOException { + final String err = "Problem loading font "+fname+", stream "+relFontPath+fname; + final Exception[] privErr = { null }; try { - URLConnection conn = IOUtil.getResource(UbuntuFontLoader.class, relPath+fname); - if(null == conn) { - throw new GLException(err); + final Font f0 = abspathImpl(fname, family, style); + if(null != f0) { + return f0; + } + if( !attemptedJARLoading ) { + attemptedJARLoading = true; + Platform.initSingleton(); + if( TempJarCache.isInitialized() ) { + final URI uri = JarUtil.getRelativeOf(UbuntuFontLoader.class, jarSubDir, jarName); + AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() { + try { + TempJarCache.addResources(UbuntuFontLoader.class, uri); + } catch (Exception e) { privErr[0] = e; } + return null; + } } ); + if( null == privErr[0] ) { + useTempJarCache = true; + final Font f1 = abspathImpl(fname, family, style); + if(null != f1) { + return f1; + } + } + } + } + } catch(Exception e) { + throw new IOException(err, e); + } + if( null != privErr[0] ) { + throw new IOException(err, privErr[0]); + } + throw new IOException(err); + } + private Font abspathImpl(final String fname, final int family, final int style) throws IOException { + final URLConnection conn; + if( useTempJarCache ) { + // this code-path throws .. all exceptions + final Exception[] privErr = { null }; + final URLConnection[] privConn = { null }; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() { + try { + final URI uri = TempJarCache.getResource(absFontPath+fname); + privConn[0] = null != uri ? uri.toURL().openConnection() : null; + } catch (Exception e) { privErr[0] = e; } + return null; + } } ); + if( null != privErr[0] ) { + throw new IOException(privErr[0]); } + conn = privConn[0]; + } else { + // no exceptions .. + conn = IOUtil.getResource(UbuntuFontLoader.class, relFontPath+fname); + } + if(null != conn) { final Font f= FontFactory.get ( conn ) ; if(null != f) { fontMap.put( ( family << 8 ) | style, f ); return f; } - throw new IOException(err); - } catch(IOException ioe) { - throw new IOException(err, ioe); } + return null; } } |