processing/processing

incorrect textWidth() with pixelDensity(2) when textFont() not used

Closed

#5,768 opened on Jan 23, 2019

 (2 comments) (0 reactions) (0 assignees)Java (1,540 forks)batch import
help wanted

Repository metrics

Stars
 (6,431 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Processing 3.4 / 3.5.2 OSX 10.12.6

println(textWidth("A")); gives me 8.279297. When I used pixelDensity(2); it will gives 16.558594.

But there is more! Having the following sketch:


void setup() {
  size(200, 200);  
  pixelDensity(2);
}

void draw() {
  background(30);
  rectMode(CORNERS);
  fill(255);
  rect(65, 80, 190, 110);
  fill(0);
  text("A B C D E F G H I J K", 65, 80, 190, 110);
}

pixelDensity(1)

pixelDensity(2)

and in P2D (pixelDensity(2)):

Note that FX2D works fine with pixelDensity(1) and pixelDensity(2) (also the textWidth returned is consistent, so I guess fixing that will fix the whole issue). (I thought I posted something related regarding the size of a tab but I can't find it).

Contributor guide