textFont/text bugs of Processing 3.4


#1

I believe I found a bug in Processing 3.4. The textFont will mess transparency in P3D render mode.
I tested the following code in former Processing versions 3.37 and before, all works fine, just the 3.4 version has problems
It has image and font files, so I also uploaded a compressed source code and downloadable here:
https://drive.google.com/open?id=11n3867_K_o0xYAiJD07HlazbLnQ65rfF
Here is the code.
PFont body, head;
int page=0;
PImage scene;
void setup() {
size(1366, 768, P3D);
body=loadFont(“Apple-Chancery-48.vlw”);//You can try any 2 different fonts, if the 2 fonts are same, then the problem gone
head=loadFont(“AmericanTypewriter-Bold-48.vlw”);
scene=loadImage(“Scene.png”);
}
void draw() {
background(0);
if (page==0) {
textFont(body, 32);
fill(255, 0, 0);
text(“Press any key to show next Page”, width/2, height2/3);
} else {
image(scene, 0, 0, width, height);
textFont(head, 36);
text(“Test”, 0, height
2/3);//if you comment out this line, the scene image shows properly, if you draw other shapes with transparent filled color, then the alpha effect will affect be a mess.
}
}
void keyPressed() {
if (page==0)
page=1;
else
page=0;
}


#2

Hi, could you please format your code with the </> button?

Could you please send a screenshot of the problem and a screenshot of how it should look?

I ran your code and it looks like this:

A problem with transparency in 3D is that you have to draw the objects in order from the farthest to the nearest. Once you draw a transparent shape, you can’t draw other shapes behind it. Text is rendered as small rectangular images with transparent parts, therefore you should keep in mind to first draw everything which goes behind it, then the text.

Another problem might be that you are using a P3D renderer, but you are drawing everything at the same depth. Sometimes the graphics card can’t tell what should be in front and what goes behind and you get “z-fighting”. Either use P2D, or try to move your text closer to the screen.

These are only guesses though. I can tell you more when I see the screenshots.


#4

I found the issue triggered be the textFont(); If you commented out all the “textFont” statements, the picture shows properly, otherwise it will show in a mess like what your screenshot here.
In order to make things more clear, I took one screenshot with no textFont statements, you will see the difference from your screenshot.


#5

BTW, I also tried what you mentioned draw all the objects with proper depth in P3D. It’s not solving the problem. And this issue only happens in the current 3.4 version. Do you have any ideas for solving the issue? Or if it is a bug, I hope it could be fixed soon in newer version.


#6

Ah, ok, now I see that the image is broken. It seems to be a bug. I will test it when I have a bit of time and reply back.