Skip to content

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

Open
@processing-bot

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.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions