diff options
author | Sven Gothel <[email protected]> | 2014-09-30 23:07:50 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-09-30 23:07:50 +0200 |
commit | bd24599b21f9787ac989e65b44dc1ba762162f22 (patch) | |
tree | 48bf52d4ebdd5e4172dd83a4d6d7f75f961c7574 /src/test | |
parent | f197d38d0ea31416645ac69cebb3f9b3544d903f (diff) |
Refine Graph/Font InputStream Capabilities (commit 628509b39ea7c16210315d191860511d6be4aa69)
FontFactory Remove:
- Font get(final URLConnection conn)
- Font get(final InputStream stream)
FontFactory Add:
- [1] Font get(final InputStream stream, final int streamLen, final boolean closeStream)
- Direct usage of font InputStream w/ determined length,
may instantiate BufferedInputStream in case given stream
doesn't support mark/reset!
- [2] Font get(final InputStream stream, final boolean closeStream)
- Copy font InputStream w/o determined length,
resulting in BufferedInputStream supporting mark/reset!
Security Related:
- Only perform priviledged code on determine InputStream,
_not_ when parsing the font stream itself!
- Hence PrivilegedAction only happens in FontFactory's
InputStream preparation.
Misc:
- Use Uri class
Diffstat (limited to 'src/test')
3 files changed, 23 insertions, 10 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java b/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java index 03a00af78..0666ec4db 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java @@ -15,21 +15,21 @@ public class FontSet01 { fonts[i++] = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_REGULAR, FontSet.STYLE_ITALIC); fonts[i++] = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_REGULAR, FontSet.STYLE_BOLD); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeMono.ttf")); + "fonts/freefont/FreeMono.ttf").getInputStream(), true); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeMonoBold.ttf")); + "fonts/freefont/FreeMonoBold.ttf").getInputStream(), true); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeSans.ttf")); + "fonts/freefont/FreeSans.ttf").getInputStream(), true); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeSansBold.ttf")); + "fonts/freefont/FreeSansBold.ttf").getInputStream(), true); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeSerif.ttf")); + "fonts/freefont/FreeSerif.ttf").getInputStream(), true); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeSerifBold.ttf")); + "fonts/freefont/FreeSerifBold.ttf").getInputStream(), true); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeSerifBoldItalic.ttf")); + "fonts/freefont/FreeSerifBoldItalic.ttf").getInputStream(), true); fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class, - "fonts/freefont/FreeSerifItalic.ttf")); + "fonts/freefont/FreeSerifItalic.ttf").getInputStream(), true); return fonts; } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java index 3a561eda4..2f67466a9 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.graph; import java.io.File; import java.io.IOException; +import java.net.URL; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; @@ -75,6 +76,7 @@ public class TestTextRendererNEWT00 extends UITestCase { static int SwapInterval = 0; static String fontFileName = null; + static URL fontURL = null; static int fontSet = 0; static int fontFamily = 0; static int fontStylebits = 0; @@ -92,6 +94,9 @@ public class TestTextRendererNEWT00 extends UITestCase { if(args[i].equals("-time")) { i++; Duration = atoi(args[i]); + } else if(args[i].equals("-fontURL")) { + i++; + fontURL = new URL(args[i]); } else if(args[i].equals("-fontFile")) { i++; fontFileName = args[i]; @@ -279,7 +284,15 @@ public class TestTextRendererNEWT00 extends UITestCase { regionFPS = GLRegion.create(renderModes, null); regionFPSAnim = GLRegion.create(renderModes, null); - if( null != fontFileName ) { + if( null != fontURL ) { + Font _font = null; + try { + _font = FontFactory.get(fontURL.openStream(), true); + } catch (final IOException e) { + e.printStackTrace(); + } + font = _font; + } else if( null != fontFileName ) { Font _font = null; try { _font = FontFactory.get(getClass(), fontFileName, false); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java index c0753ba85..78dc87489 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java @@ -102,7 +102,7 @@ public class TestTextRendererNEWT10 extends UITestCase { forceGL3 = true; } else if(args[i].equals("-font")) { i++; - font = FontFactory.get(IOUtil.getResource(TestTextRendererNEWT10.class, args[i])); + font = FontFactory.get(IOUtil.getResource(TestTextRendererNEWT10.class, args[i]).getInputStream(), true); } else if(args[i].equals("-fontSize")) { i++; fontSize = MiscUtils.atof(args[i], fontSize); |