creating a PFont from custom path source
in
Programming Questions
•
2 years ago
Hi all,
I have doubts in how can i create an PFont from custom path instead data folder;
In specific project;
I want to manage data folder according data type, with subfolders, like:
I have this stack trace:
SketchApplet(10:03:37) sketch size
SketchApplet(10:03:37) width: 500
SketchApplet(10:03:37) height: 500
Could not createInput() for curseCasualJVE.ttf
java.io.FileNotFoundException: curseCasualJVE.ttf (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at processing.core.PApplet.createInput(Unknown Source)
at gml.processing.sketch.SketchApplet.setup(SketchApplet.java:145)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:679)
SketchApplet(10:03:37) Exiting gml.processing.sketch.SketchApplet[panel0,0,0,500x500,layout=java.awt.FlowLayout]#SketchApplet#
SketchApplet(10:03:37) path: curseCasualJVE.ttf
Exception in thread "Animation Thread" java.lang.NullPointerException
at gml.processing.sketch.SketchApplet.setup(SketchApplet.java:158)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:679)
How can I acess custom src to PFont instance?
Thanks
I have doubts in how can i create an PFont from custom path instead data folder;
In specific project;
I want to manage data folder according data type, with subfolders, like:
- data/images
- data/fonts
- data/xml
- PFont pFont = PApplet.loadFont("data/font/curseCasualJVE.ttf");
- public class SketchApplet extends PApplet implements Sketch{
- /*
- * some code
- */
- //Configure the size
- @Override
- public void setup(){
- size(500, 500);
- if(LOG){
- Log.d(TAG, "sketch size");
- Log.i(TAG, "width: "+this.width);
- Log.i(TAG, "height: "+this.height);
- }
- //Configure the message features
String filename = "/data/font/curseCasualJVE.ttf";
PFont pFont = null;
try{
pFont = new PFont(createInput(new File(filename)));
if(LOG)
Log.d(TAG, "loading font");
Log.i(TAG, pFont.getName());
textFont(pFont);
textMode(PConstants.SCREEN);
textAlign(PConstants.CENTER);
} catch (Exception e) {
if(LOG)
Log.d(TAG, "Exiting "+toString());
Log.i(TAG, "path: "+filename);
Log.i(TAG, "PFont: "+(!pFont.equals(null)?pFont.getName():"null"));
Log.i(TAG, "\tsize: "+pFont.getSize());
die("Could not load font " + filename + ". " +
"Make sure that the font has been copied " +
"to the data folder of your sketch.", e);
}finally{
if(!this.exitCalled)
this.exit();
} - }
I have this stack trace:
SketchApplet(10:03:37) sketch size
SketchApplet(10:03:37) width: 500
SketchApplet(10:03:37) height: 500
Could not createInput() for curseCasualJVE.ttf
java.io.FileNotFoundException: curseCasualJVE.ttf (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at processing.core.PApplet.createInput(Unknown Source)
at gml.processing.sketch.SketchApplet.setup(SketchApplet.java:145)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:679)
SketchApplet(10:03:37) Exiting gml.processing.sketch.SketchApplet[panel0,0,0,500x500,layout=java.awt.FlowLayout]#SketchApplet#
SketchApplet(10:03:37) path: curseCasualJVE.ttf
Exception in thread "Animation Thread" java.lang.NullPointerException
at gml.processing.sketch.SketchApplet.setup(SketchApplet.java:158)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:679)
How can I acess custom src to PFont instance?
Thanks
1