Text rendering off-center in P2D renderer

When I try to draw text in the P2D renderer, it draws slightly below where I want it, and the line spacing is greatly increased compared to the default renderer (see the image)

Does anyone know why it does this? Thanks

Edit:
Here’s the code for the sketch

size(854, 480);
background(#000000);
textSize(min(width,height)/2);
textAlign(CENTER, CENTER);
text("Test", width/2,height/2);
2 Likes

It seems like P2D treats the text as having a larger vertical size than it appears. I did find a work around/solution. If you create a font and then use that font, the text is centered as expected with P2D.

You can create a font by going to “Tools” then “Create Font”

PFont arial;

void setup(){
  size(854, 480,P2D);
  background(#000000);
  arial = loadFont("Arial-Black-48.vlw");
  
}

void draw(){
  textFont(arial);
  textSize(min(width,height)/2);
  textAlign(CENTER, CENTER);
  text("Test", width/2,height/2);
}

1 Like

Weird, but thank you

Hello @Username3,

There is a related issue here:

:)