processing/processing4

Text mis-aligned when scaling and using `textSize()` with `P2D`

Open

#425 opened on Feb 27, 2022

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Java (176 forks)auto 404
help wantedopengl

Repository metrics

Stars
 (439 stars)
PR merge metrics
 (PR metrics pending)

Description

Created by: Santarii

Expected Behavior

If I use the scale function and then use the textSize function to reverse that scaling, I expect to get the same result as just rendering the text without any scaling.

Current Behavior

In the default renderer the text is lower than it should be when scaled up then sized back down. In P2D the space between characters also changes.

Steps to Reproduce

float scale = 1;

void setup() {
  size(1920, 1080, P2D);
  textFont(createFont("Consolas", 256));
}

void draw() {
  scale += 1;
  scale(scale);
  background(0);
  textAlign(LEFT, TOP);
  textSize(256f/scale);
  text("Wow", 0, 0);
}

This code renders text, and each frame increases the scale, but the scale is exactly reversed with the textSize function. If the bug didn't exist, this would look like stationary unchanging text, however this is not the case.

Your Environment

  • Processing version: 4.0b6
  • Operating System and OS version: Windows 10 Home 64-bit. 10.0.19043 Build 19043.

Possible Causes / Solutions

It seems to not just be small values in textSize, even reasonable values mess with the alignment a bit, though very small values have a more significant effect.

Contributor guide