Bug 1313 : Some Unicode characters not displayed correctly in P3D or OPENGL
Last modified: 2009-08-26 15:27




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

 

Reporter:
bakercp
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-08-26 14:56
Version 1.0.6
OS X 10.5.8
Macbook Pro

Some Unicode characters not displayed correctly in P3D or OPENGL but work
in normal rendering mode.

All characters are rendered correctly in normal mode:

char unicode_pi = '\u03C0'; // pi
char unicode_alpha = '\u03B1'; // alpha
char ascii = 'a';
void setup() {
size(500,500); // normal
textFont(createFont("",100));
}

void draw() {
background(0);
textAlign(CENTER);
text(unicode_pi,width/2,height/4); // success in P3D and OPENGL
text(unicode_alpha,width/2,height/2); // fail in P3D and OPENGL
text(ascii,width/2,3*height/4); // success in P3D and OPENGL
}

In P3D, the alpha character is not rendered, but the pi and ascii a are:

char unicode_pi = '\u03C0'; // pi
char unicode_alpha = '\u03B1'; // alpha
char ascii = 'a';
void setup() {
size(500,500,P3D); // P3D
smooth();
textFont(createFont("",100));
}

void draw() {
background(0);
textAlign(CENTER);
text(unicode_pi,width/2,height/4); // success in P3D and OPENGL
text(unicode_alpha,width/2,height/2); // fail in P3D and OPENGL
text(ascii,width/2,3*height/4); // success in P3D and OPENGL
}

In OPENGL, the alpha character is not rendered, but the pi and ascii a are:

import processing.opengl.*;

char unicode_pi = '\u03C0';
char unicode_alpha = '\u03B1';
char ascii = 'a';
void setup() {
size(500,500,OPENGL); // OPENGL
smooth();
textFont(createFont("",100));
}

void draw() {
background(0);
textAlign(CENTER);
text(unicode_pi,width/2,height/4); // success in P3D and OPENGL
text(unicode_alpha,width/2,height/2); // fail in P3D and OPENGL
text(ascii,width/2,3*height/4); // success in P3D and OPENGL
}
Additional Comment #1 From fry 2009-08-26 15:16
that's correct, if you want non-ascii characters, you have to select "All
Characters" with the Create Font tool, or pass in a set of characters you
want to use to createFont().
http://processing.org/reference/createFont_.html
we can't include all characters by default, because some unicode fonts are
enormous.
Additional Comment #2 From bakercp 2009-08-26 15:27
Got it. It's been a while since I read that document. Forgot about the
JAVA2D vs. bitmap issue. Sorry for the false alarm.