Bug 1213 : Cannot load font in applet
Last modified: 2009-03-25 16:29




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
gpm
Assigned To:
fry

Attachment Type Created Size Actions
Archive of pde pertaining to bug 1213 application/x-zip-compressed 2009-03-24 18:45 290.43 KB

Description:   Opened: 2009-03-18 20:16
revision number 0163
Windows XP, Intel Centrino Duo T2400
JRE 1.6.0_11

[code]
PFont font;
void setup(){
font = loadFont("TrebuchetBold-16.vlw");
textFont(font);
}
void draw(){
text("word", 15, 30);
}
[/code]


This works fine in the Processing IDE, but when I export it to an applet
and try to view from a browser (Firefox or IE), I get an assortment of
errors. Sometimes I get a null pointer exception ("Exception in thread
"Animation Thread" java.lang.NullPointerException"), sometimes I get an
error that the font could not be loaded. I have verified that the font is
included in the .jar file that was generated.

The issue occurs whether PFont font is global or not, and it occurs no
matter where I call loadFont() or textFont() from.

Possibly related: The code above is a small fragment of a larger program
which access data files from the data folder. Intermittently, I will see
the error

java.security.AccessControlException: access denied (java.io.FilePermission
null\data\myFileName.in read)

Again, I have verified that this file is in the data directory inside the
jar file. That "null" in the path seems odd to me.

I'll be happy to send the entire sketch directory if needed.

Thanks,
Jerry
Additional Comment #1 From fry 2009-03-23 06:41
Is the font located in the data folder of your sketch so that it's exported
properly?
Additional Comment #2 From gpm 2009-03-23 10:22
Hi. Thanks for the reply.

The font is located in the data folder. Also, when I create the applet, if
I manually inspect the jar file with jar -tf <filename>, I can see that
data/TrebuchetBold-16.vlw is included in the jar file. Just for fun, I'll
include the entire output of jar -tf ndg_static.jar (which is itself
located in the applet folder).

Thanks,
Jerry


$ jar -tf ndg_static.jar
META-INF/MANIFEST.MF
processing/core/PApplet$1.class
processing/core/PApplet$2.class
processing/core/PApplet$3.class
processing/core/PApplet$4.class
processing/core/PApplet$5.class
processing/core/PApplet$6.class
processing/core/PApplet$7.class
processing/core/PApplet$8.class
processing/core/PApplet$9.class
processing/core/PApplet$AsyncImageLoader.class
processing/core/PApplet$RegisteredMethods.class
processing/core/PApplet$RendererChangeException.class
processing/core/PApplet.class
processing/core/PConstants.class
processing/core/PFont.class
processing/core/PGraphics.class
processing/core/PGraphics2D.class
processing/core/PGraphics3D.class
processing/core/PGraphicsJava2D$ImageCache.class
processing/core/PGraphicsJava2D.class
processing/core/PImage.class
processing/core/PLine.class
processing/core/PMatrix.class
processing/core/PMatrix2D.class
processing/core/PMatrix3D.class
processing/core/PPolygon.class
processing/core/PShape.class
processing/core/PShapeSVG$Gradient.class
processing/core/PShapeSVG$LinearGradient.class
processing/core/PShapeSVG$LinearGradientPaint$LinearGradientContext.class
processing/core/PShapeSVG$LinearGradientPaint.class
processing/core/PShapeSVG$RadialGradient.class
processing/core/PShapeSVG$RadialGradientPaint$RadialGradientContext.class
processing/core/PShapeSVG$RadialGradientPaint.class
processing/core/PShapeSVG.class
processing/core/PSmoothTriangle.class
processing/core/PStyle.class
processing/core/PTriangle.class
processing/core/PVector.class
processing/xml/CDATAReader.class
processing/xml/ContentReader.class
processing/xml/PIReader.class
processing/xml/StdXMLBuilder.class
processing/xml/StdXMLParser.class
processing/xml/StdXMLReader$1.class
processing/xml/StdXMLReader$StackedReader.class
processing/xml/StdXMLReader.class
processing/xml/XMLAttribute.class
processing/xml/XMLElement.class
processing/xml/XMLEntityResolver.class
processing/xml/XMLException.class
processing/xml/XMLParseException.class
processing/xml/XMLUtil.class
processing/xml/XMLValidationException.class
processing/xml/XMLValidator.class
processing/xml/XMLWriter.class
data/graphlist-100-00000
data/TrebuchetBold-16.vlw
data/Copy of nodelist-100-00000
data/nodelist-100-00000-full
data/related_docs_10.dot
data/related_docs_50.dot
data/nodelist-100-00000
data/graphlist-1000-00000
data/rdtmp.small
data/related_docs_100.dot
data/nodelist-1000-00000
data/Copy of graphlist-100-00000
data/Trebuchet-16.vlw
data/rdtmp
ndg_static$Article.class
ndg_static.class
Additional Comment #3 From gpm 2009-03-23 10:25
Also, I should note that I am running this from Windows, but the folder
itself is located on a Samba share of a Linux directory. That's why you
see the Unix-style prompt before the jar command above. However, even if I
move this directory into a pure Win environment, I get the same errors when
running the applet.
Additional Comment #4 From fry 2009-03-24 06:42
hm, how about using tools > archive sketch and attaching the zip file to
this bug report.
Additional Comment #5 From gpm 2009-03-24 18:45
edit]
Archive of pde pertaining to bug 1213
Additional Comment #6 From gpm 2009-03-24 18:46
Thanks for taking a look at this. The archive is attached.
Additional Comment #7 From fry 2009-03-24 18:52
This is not a bug, and has nothing to do with fonts. The problem is in
loading your other data files. You've just got a bad bad mix of Processing
and Java syntax.

Instead, use createReader() to get a BufferedReader from an object that's
stored in the data folder. For instance, this is correct:

GRAPHFILENAME = "graphlist-100-00000";
BufferedReader graphFile = createReader(GRAPHFILENAME);
Additional Comment #8 From fry 2009-03-25 07:16
Also, where did you read about dataPath()? It's only in the source, and the
source notes the issue that you ran into regarding the JAR file. (I'm just
curious so we can avoid this confusion in the future.)
Additional Comment #9 From gpm 2009-03-25 16:29
Ah, OK. I guess I was taking a few too many liberties with the language
... I'll rewrite it just in Processing, then.

I wish I could tell you where I learned about dataPath() -- I have a
feeling it may have been in the source code for one of the sample projects
you have posted. But of the ones I remember looking at, I can't find
dataPath in there anywhere. If I remember where I read about it, I'll post
an addendum to this report.