processing / processing/processing4

Incorrect calculation of the text width in the P2D renderer

Open
#1,328 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
494
Forks
183
Avg merge
4h 39m
Merged PRs (30d)
3

Description

Most appropriate sub-area of Processing 4?

Core/Environment/Rendering

Processing version

4.3.4

Operating system

Windows 7

Bug description

Significant errors in calculating the width of text using the textWidth(String) method in P2D mode in the Eclipse environment

Steps to reproduce this

To reproduce the error, you need to run the code that I specified here in the Eclipse environment.

void settings() {
size(720,360,P2D);
}

void setup() {
stroke(0);
textSize(24);
final String str = "WWWtttt".repeat(100);
final float textWidth = textWidth(str);
text(str, 100 - textWidth, 200);
stroke(255, 0, 0);
line(100 - textWidth, 200, 100, 200);
noLoop();
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Processing sketch in P2D mode under the reported environment and compare the textWidth result with the rendered text and reference line. Then trace the P2D renderer's text-width calculation; done means textWidth(String) measures the repeated string accurately and the reproduction no longer shows a significant alignment error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.