needed complete rewrite to test something here,
-a- please post processing IDE testable code
with default path
if files needed ( here like font… ) provide or default
-b- your size numbers / for size() / font / PGraphics / translate / text position
is confusing and might be part of the problem
-c- a textFont.save(outfile);
can not be used here?
-d- your structure
createGraphics in draw / save / exit i changed:
–1- i first create it in setup
–2- show by draw
–3- print by key ‘p’
// https://discourse.processing.org/t/text-partly-invisible-with-p3d-renderer/13575/3
PGraphics textLayer;
int iwidth = 800;
int iheight = 600;
String sfont = "Arial";
int mainFontSize = 100;
String outfile = "data/3dtest.png";
void settings() {
size(iwidth, iheight, P3D);
}
void setup() {
colorMode(RGB, 255);
textLayer = createGraphics(iwidth, iheight, P3D);
textLayer.beginDraw();
textLayer.background(0,0,80);
textLayer.textAlign(CENTER);
textLayer.textFont(createFont(sfont, mainFontSize));
textLayer.fill(color(255, 255, 255));
textLayer.translate(0, 0, 20); // change 200 to 20 to see full string
textLayer.text("California", 300, 200);
textLayer.endDraw();
println("click canvas and use:\nkey [p] to save picture");
}
void draw() {
background(200,200,0); // should never be visible! or printed
image(textLayer,0,0); // show first what you created
}
public void keyPressed() {
if ( key == 'p' ) {
save(outfile);
// textLayer.save(outfile); // can NOT use!
println("saved to "+outfile);
}
}