Bug 1535 : textMode(SHAPE) is not supported by this renderer.
Last modified: 2010-04-09 08:36




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

 

Reporter:
jonobrone
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2010-04-07 10:28
I get this error using Processing 0182 and trying to run textMode(SHAPE);

This occurs regardless if I import any libraries. In a project I'm working on I want to export
my applet to a PDF with Fonts. The documentation and my error console say to use
textMode(SHAPE) in order for the font, which I looked up using PGraphicsPDF.listFonts(), to
word properly for the PDF rendering.

1. Processing 0182
2. Mac OSX 10.6.2
3.

void setup() {
size(400,400);
textMode(SHAPE);
}

5. Error on the above code:

textMode(SHAPE) is not supported by this renderer.

Error on my personal project when trying to render a frame out to a PDF file:

textMode(SHAPE) is not supported by this renderer.
processing.app.debug.RunnerException: RuntimeException: Use textMode(SHAPE) with when
loading .ttf and .otf files with createFont().
at processing.app.Sketch.placeException(Sketch.java:1543)
at processing.app.debug.Runner.findException(Runner.java:567)
at processing.app.debug.Runner.reportException(Runner.java:543)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.RuntimeException: Use textMode(SHAPE)
with when loading .ttf and .otf files with createFont().
at processing.pdf.PGraphicsPDF.checkFont(PGraphicsPDF.java:549)
at processing.pdf.PGraphicsPDF.textFont(PGraphicsPDF.java:362)
at processing.core.PGraphics.textFont(PGraphics.java:2939)
at processing.core.PApplet.textFont(PApplet.java:8533)
at MindMap$Attribute.render(MindMap.java:355)
at MindMap.draw(MindMap.java:196)
at processing.core.PApplet.handleDraw(PApplet.java:1594)
at processing.core.PApplet.run(PApplet.java:1496)
at java.lang.Thread.run(Thread.java:637)
Additional Comment #1 From fry 2010-04-07 10:57
that's correct, textMode(SHAPE) is not supported by the default renderer.

i'd need to see an example that uses PDF that fails.
Additional Comment #2 From jonobrone 2010-04-07 16:06
Okay. Now I feel bad, maybe this isn't a bug and I should post it on the forums?

You can see the running app without the PDF save functionality here:

http://jonobr1.com/code/mindMap/

or the archived sketch

http://jonobr1.com/code/MindMap-100407a.zip

Thanks Mr. Fry,

-Jono

(In reply to comment #1)
>
>
>
> Additional Comment #1 From
>
> fry
> 2010-04-07 10:57
>
> <!--
> addReplyLink(1); //-->[reply]
>
>
>
>
>
>
> that's correct, textMode(SHAPE) is not supported by the default renderer.
>
> i'd need to see an example that uses PDF that fails.
>
>

Additional Comment #3 From fry 2010-04-08 11:00
yeah, so that's behavior that's changed w/ the new PDF setup. it makes this
particular situation more difficult, but the idea is to prevent PDF from
more situations where it's failing silently with the text (and showing
black boxes or the wrong font).

try this version of your draw() method:

void draw() {
background(0,50);
if (record) {
PGraphics pdf = beginRecord(PDF, "mindMap-####.pdf");
// set only the PDF renderer to use textMode(SHAPE)
pdf.textMode(SHAPE);
}

// set the font *after* the PDF has started recording, otherwise it won't
be set
textFont(h2, 13);
textAlign(CENTER, CENTER);

physics.tick();
background(0);
rect(width-50, 25, 25, 25);
for(int i = 0; i < num; i++) {
attributes[i].update();
attributes[i].render();
}

if (record) {
endRecord();
record = false;
}
}
Additional Comment #4 From jonobrone 2010-04-08 11:09
Wow! Works like a dream! Thank you so so so much! So, let me see if I understand this.
PApplet's Renderer doesn't accept textMode(SHAPE), but PDF is a different renderer and it
not only accepts that method, but requires it to save?

(In reply to comment #3)
>
>
>
> Additional Comment #3 From
> fry
> 2010-04-08 11:00
>
> <!--
> addReplyLink(3); //-->[reply]
>
>
>
>
>
>
> yeah, so that's behavior that's changed w/ the new PDF setup. it makes this
> particular situation more difficult, but the idea is to prevent PDF from
> more situations where it's failing silently with the text (and showing
> black boxes or the wrong font).
>
> try this version of your draw() method:
>
> void draw() {
> background(0,50);
> if (record) {
> PGraphics pdf = beginRecord(PDF, "mindMap-####.pdf");
> // set only the PDF renderer to use textMode(SHAPE)
> pdf.textMode(SHAPE);
> }
>
> // set the font *after* the PDF has started recording, otherwise it won't
> be set
> textFont(h2, 13);
> textAlign(CENTER, CENTER);
>
> physics.tick();
> background(0);
> rect(width-50, 25, 25, 25);
> for(int i = 0; i < num; i++) {
> attributes[i].update();
> attributes[i].render();
> }
>
> if (record) {
> endRecord();
> record = false;
> }
> }
>
>
Additional Comment #5 From fry 2010-04-08 12:00
yeah, so if you use:

size(800, 600, PDF, "blah.pdf");

you could use textMode(SHAPE) with no problems. the issue is that when
using beginRecord(), you can only called textMode(SHAPE) on the PDF
renderer that you're recording to, not the main renderer.

the OpenGL renderer also supports textMode(SHAPE), which is why we don't
just do this by default behind the scenes.

thanks for posting the bug, at any rate, it's a helpful reminder that we
need to update the beginRecord() examples to show how to use text properly.

...or we need to figure out a much simpler way of doing this, since it's
confusing.
Additional Comment #6 From jonobrone 2010-04-09 08:36
Mmm, thanks for responding. That makes a lot of sense to me. I don't necessarily think that
it needs to change, but it would be nice if it were in the documentation / reference. I know
that there are many N.B. within the core libraries and methods...

I'd love to help if you need any, otherwise I'll keep posting to the forum / bugs.

Thanks again!

(In reply to comment #5)
>
>
>
> Additional Comment #5 From
>
> fry
> 2010-04-08 12:00
>
> <!--
> addReplyLink(5); //-->[reply]
>
>
>
>
>
>
> yeah, so if you use:
>
> size(800, 600, PDF, "blah.pdf");
>
> you could use textMode(SHAPE) with no problems. the issue is that when
> using beginRecord(), you can only called textMode(SHAPE) on the PDF
> renderer that you're recording to, not the main renderer.
>
> the OpenGL renderer also supports textMode(SHAPE), which is why we don't
> just do this by default behind the scenes.
>
> thanks for posting the bug, at any rate, it's a helpful reminder that we
> need to update the beginRecord() examples to show how to use text properly.
>
> ...or we need to figure out a much simpler way of doing this, since it's
> confusing.
>
>