Bug 101 : createFont() doesn't work in applets
Last modified: 2006-09-12 18:38




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P3
Severity:
normal

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-07-27 20:06
throws a security exception because of the reflection stuff.

stack trace:

java.security.AccessControlException: access denied
(java.lang.RuntimePermission accessDeclaredMembers)

at
java.security.AccessControlContext.checkPermission(AccessControlContext.
java:267)
at java.security.AccessController.checkPermission(AccessController.java:394 )
at java.lang.SecurityManager.checkPermission(SecurityManager.java:540)
at java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1645)
at java.lang.Class.checkMemberAccess(Class.java:1332)
at java.lang.Class.getDeclaredField(Class.java:1107)
at processing.core.PFont.<init>(PFont.java:749)
at processing.core.PApplet.createFont(PApplet.java:2841)
at processing.core.PApplet.createFont(PApplet.java:2779)
at word_connect.setup(word_connect.java:24)
at processing.core.PApplet.display(PApplet.java:1017)
at processing.core.PGraphics.requestDisplay(PGraphics.java:362)
at processing.core.PApplet.run(PApplet.java:921)
at java.lang.Thread.run(Thread.java:491)

Error while running applet.
java.lang.RuntimeException: access denied (java.lang.RuntimePermission
accessDeclaredMembers)
at processing.core.PFont.<init>(PFont.java:952)
at processing.core.PApplet.createFont(PApplet.java:2841)
at processing.core.PApplet.createFont(PApplet.java:2779)
at word_connect.setup(word_connect.java:24)
at processing.core.PApplet.display(PApplet.java:1017)
at processing.core.PGraphics.requestDisplay(PGraphics.java:362)
at processing.core.PApplet.run(PApplet.java:921)
at java.lang.Thread.run(Thread.java:491)

suggestion from cello:

well, for one of my applets I have:

<PRE>import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

class BrushGraphics2D {
public static final void setTextAntialiasing(Graphics g, boolean antialias) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antialias ?
RenderingHints.VALUE_TEXT_ANTIALIAS_ON :
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
}</PRE>

Then I conditionally call that function if they have java 2. I haven't had
any security exceptions or anything trying to do that, and it works on
older browsers (they don't try to load that class).
Additional Comment #1 From mrdent 2005-11-27 04:31
I'm a bit confused as to how to approach this "work-around" that was mentioned, as
I'm relatively new to java and processing. I understand classes and objects, but not
enough of the java core to implement it. Until this bug get's fixed, if anyone would
be willing to help me figure out how to get my processing web applet to handle Pfont,
it would be greatly appreciated.

member id: mrdent
disposition: confused...
Additional Comment #2 From fry 2005-11-27 08:30
use "Create Font" under the "Tools" menu to create a font to be added to your sketch.
createFont() is an advanced feature that shouldn't really be used for applets, because it
requires that anyone who uses the applet have the same font installed.
Additional Comment #3 From fry 2006-05-22 06:14
original reference from the board:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115877723

also not sure if this is just with TTF files or with any createFont(). this
would be one reason to move to 1.3-only, since the reflection stuff is
what's causing the problem.
Additional Comment #4 From fry 2006-09-12 18:38
fixed for release 0116.