processing/processing4

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

Open

#425 aberto em 27 de fev. de 2022

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)Java (176 forks)auto 404
help wantedopengl

Métricas do repositório

Stars
 (439 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

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.

Guia do colaborador