Can anyone else confirm? textFont overrides stroke opacity?

Hey guys, please see example below to try and recreate the behaviour I’m seeing: when setting the font to a font loaded with loadFont (as opposed to using createFont) all stroke opacity in the sketch is set to 255:

PFont font;

void setup()
{
  size(600, 600, P3D);
  pixelDensity(2);
  smooth(8);
  
  //font = createFont("Helvetica", 100);
  font = loadFont("Helvetica-100.vlw");
  
  
  // when setting font to loaded font, all stroke opacity is set to full??
  textFont(font, 20); // comment out to see normal behaviour
}

void draw() 
{
  background(255);
  
  // draw some low opacity circles
  noFill();
  stroke(0, 30);
  ellipseMode(CENTER);
  ellipse(width/2 - 50, height/2 - 50, 300, 300);
  ellipse(width/2 + 50, height/2 + 50, 300, 300);
  
  // render some text with a loaded font
  fill(0);
  textAlign(CENTER, CENTER);
  text("Strange", width/2, height/2);
}
1 Like

can not see that ( win7, processing 3.4 )

PFont font;
int opaq=120;

void setup()
{
  size(600, 600, P3D);
  //pixelDensity(2);
  smooth(8);

  //font = createFont("Helvetica", 100);
  //  font = loadFont("Helvetica-100.vlw");
  font = loadFont("Uni0554-8.vlw");

  // when setting font to loaded font, all stroke opacity is set to full??
  textFont(font); // comment out to see normal behaviour
  println("use mousewheel for adjust");
}

void draw() 
{
  background(0, 0, 100);

  // draw some low opacity circles
  noFill();
  stroke(200, 200, 0, opaq);
  //  stroke(0, 30);
  ellipseMode(CENTER);
  ellipse(width/2 - 50, height/2 - 50, 300, 300);
  ellipse(width/2 + 50, height/2 + 50, 300, 300);

  // render some text with a loaded font
  //fill(200, 0, 0);
  fill(200, 0, 0, opaq);
  textSize(40);
  textAlign(CENTER, CENTER);
  text("TEXT", width/2, height/2);
}

//_______________________________________________________________
void mouseWheel(MouseEvent event) { 
  opaq += event.getCount()*5; 
  if ( opaq < 0 ) { 
    opaq = 0;
  }
  if ( opaq > 255 ) { 
    opaq = 255;
  }
  println("opaq "+opaq);
}

1 Like

@rapatski was this resolved for you, or are you still having a problem on your system?

I have not heard of a solution or workaround, but adding my specs: macOS Mohave, Processing 3.4. Anyone else with a mac who can recreate or get it to work on mac?

I can confirm this bug on Processing 3.4 with macOS 10.12.

There is something deeply weird going on here. When I tested with noLoop I was getting text-only results, so I changed the test sketch.

In this revised sketch, it renders as normal. Now hold down space for ~1 second to load the font. In the very next frame, only the second text renders – no other lines, including prior lines AND prior text – are drawn at all. In the following frame, all lines are drawn opaque. Are you seeing the same thing?

// https://discourse.processing.org/t/can-anyone-else-confirm-textfont-overrides-stroke-opacity/4513

PFont font;
boolean loaded;

void setup() {
  size(600, 300, P3D);
  pixelDensity(2);
  smooth(8);
  frameRate(1);
}

void draw() {
  background(255);

  drawCircleText(); // no loaded font

  if (keyPressed && !loaded) {
    // create the font with PDE > Tools > Create Font > Helvetica, 100
    font = loadFont("Helvetica-100.vlw");
    // when setting font to loaded font, all prior drawing is lost, then next frame stroke opacity is set to full?
    textFont(font, 20);
    loaded = true;
  }

  translate(width/2, 0);
  drawCircleText();  // optionally loaded font

}

void drawCircleText() {
  // draw intersecting low opacity circles
  noFill();
  stroke(0, 30);
  strokeWeight(5);
  ellipseMode(CENTER);
  ellipse(width/4 - 50, height/2 - 50, 160, 160);
  ellipse(width/4 + 50, height/2 + 50, 160, 160);
  // render some text
  fill(0);
  textAlign(CENTER, CENTER);
  text("Strange", width/4 - 50, height/4);
}