summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/font
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/graph/font')
-rw-r--r--src/jogl/classes/jogamp/graph/font/FontConstructor.java2
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java24
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java17
3 files changed, 39 insertions, 4 deletions
diff --git a/src/jogl/classes/jogamp/graph/font/FontConstructor.java b/src/jogl/classes/jogamp/graph/font/FontConstructor.java
index b452ae548..76b5dbb8b 100644
--- a/src/jogl/classes/jogamp/graph/font/FontConstructor.java
+++ b/src/jogl/classes/jogamp/graph/font/FontConstructor.java
@@ -29,11 +29,13 @@ package jogamp.graph.font;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URLConnection;
import com.jogamp.graph.font.Font;
public interface FontConstructor {
Font create(File file) throws IOException ;
+ Font create(InputStream stream) throws IOException ;
Font create(URLConnection url) throws IOException ;
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
index 6154484d5..0b42a65d4 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
@@ -29,6 +29,7 @@ package jogamp.graph.font.typecast;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -67,6 +68,29 @@ public class TypecastFontConstructor implements FontConstructor {
}
@Override
+ public Font create(final InputStream istream) throws IOException {
+ final Object o = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
+ public Object run() {
+ OTFontCollection fontset;
+ try {
+ fontset = OTFontCollection.create(istream);
+ return new TypecastFont(fontset);
+ } catch (final IOException e) {
+ return e;
+ }
+ }
+ });
+ if(o instanceof Font) {
+ return (Font)o;
+ }
+ if(o instanceof IOException) {
+ throw (IOException)o;
+ }
+ throw new InternalError("Unexpected Object: "+o);
+ }
+
+ @Override
public Font create(final URLConnection fconn) throws IOException {
return AccessController.doPrivileged(new PrivilegedAction<Font>() {
@Override
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 e5ad2900a..87c68eae8 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
@@ -25,6 +25,7 @@ import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
@@ -58,9 +59,9 @@ public class OTFontCollection {
/**
* @param file The OpenType font file
*/
- public static OTFontCollection create(final File file) throws IOException {
+ public static OTFontCollection create(final InputStream istream) throws IOException {
final OTFontCollection fc = new OTFontCollection();
- fc.read(file);
+ fc.read(istream);
return fc;
}
@@ -119,11 +120,19 @@ public class OTFontCollection {
}
_resourceFork = true;
}
+
+ read(new FileInputStream(file));
+ }
+
+ /**
+ * @param inputstream The OpenType font stream
+ */
+ protected void read(InputStream file) throws IOException {
final DataInputStream dis = new DataInputStream(
new BufferedInputStream(
- new FileInputStream(file), (int) file.length()));
- dis.mark((int) file.length());
+ file));
+ //dis.mark((int) file.length());
if (_resourceFork || _pathName.endsWith(".dfont")) {