From cd2e9f16ec2612587c08bf407d522243fb7a9d20 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 27 Jan 2015 19:52:28 +0100 Subject: Fix UbuntuFontLoader: Regression of commit bd24599b21f9787ac989e65b44dc1ba762162f22 Commit bd24599b21f9787ac989e65b44dc1ba762162f22 removed font loading w/o TempJarCache, e.g. as used on Android. --- .../jogamp/graph/font/UbuntuFontLoader.java | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java index bbf022657..e4b0cb2a8 100644 --- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java +++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java @@ -29,9 +29,11 @@ package jogamp.graph.font; import java.io.IOException; import java.io.InputStream; +import java.net.URLConnection; import com.jogamp.common.net.Uri; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.JarUtil; import com.jogamp.common.util.cache.TempJarCache; @@ -170,20 +172,26 @@ public class UbuntuFontLoader implements FontSet { } } private Font abspathImpl(final String fname, final int family, final int style) throws IOException { - final Exception[] privErr = { null }; - final InputStream stream = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public InputStream run() { - try { - final Uri uri = TempJarCache.getResourceUri(fname); - return null != uri ? uri.toURL().openConnection().getInputStream() : null; - } catch (final Exception e) { - privErr[0] = e; - return null; - } - } } ); - if( null != privErr[0] ) { - throw new IOException(privErr[0]); + final InputStream stream; + if( useTempJARCache ) { + final Exception[] privErr = { null }; + stream = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public InputStream run() { + try { + final Uri uri = TempJarCache.getResourceUri(fname); + return null != uri ? uri.toURL().openConnection().getInputStream() : null; + } catch (final Exception e) { + privErr[0] = e; + return null; + } + } } ); + if( null != privErr[0] ) { + throw new IOException(privErr[0]); + } + } else { + final URLConnection urlConn = IOUtil.getResource(UbuntuFontLoader.class, fname); + stream = null != urlConn ? urlConn.getInputStream() : null; } if(null != stream) { final Font f= FontFactory.get ( stream, true ) ; -- cgit v1.2.3