We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › OPENGL textSize() results in blurry font rendering
Page Index Toggle Pages: 1
OPENGL textSize() results in blurry font rendering (Read 2722 times)
OPENGL textSize() results in blurry font rendering
Mar 24th, 2010, 6:07am
 
Hi,

I just recognized that using textSize() in OPENGL mode results in burry text exept when using the generated font size.

...

Code:
import processing.opengl.*;

void setup(){
 size(400, 400, OPENGL);
 background(255);
 fill(0);
 PFont font = createFont("Arial", 14);
 textFont(font);
 text("This is crisp sharp text", 100, 30);
 textSize(20);
 text("This looks really blurry", 100, 50);
}

void draw(){
}


In JAVA2D it works really good (even looks better). Any ideas how to handle that issue?

Flo
Re: OPENGL textSize() results in blurry font rendering
Reply #1 - Mar 24th, 2010, 7:14am
 
Try to create a font larger or at the same size as the size you are using.  A pfont takes a font and turns it into a graphic.  So what your doing is creating a small graphic (14) and making it bigger (20), which gives it a blurry effect.  It would look better if it was created either the same size (20) or larger (32, 48, etc) than the size your using.  Shrinking the image to 14 should not blur it but will end up taking a little more memory.

For example, this looks fine
Code:
import processing.opengl.*;

void setup(){
 size(400, 400, OPENGL);
 background(255);
 fill(0);
 PFont font = createFont("Arial", 20);
 textFont(font);
 textSize(14);
 text("This is crisp sharp text", 100, 30);
 textSize(20);
 text("This is crisp sharp text too", 100, 50);
}
Re: OPENGL textSize() results in blurry font rendering
Reply #2 - Mar 24th, 2010, 7:38am
 
Ok that fixed the problem partly but I got rid of the really blurred text. It's still not as good as the Java2D but I think I'll have to live with it..
Re: OPENGL textSize() results in blurry font rendering
Reply #3 - Mar 24th, 2010, 7:49am
 
Try using this hint in your setup.
Code:
hint(ENABLE_NATIVE_FONTS); 

Re: OPENGL textSize() results in blurry font rendering
Reply #4 - Mar 24th, 2010, 8:47am
 
Couldn't include a link to the output image (due to restrictions)
dl.dropbox.com/u/974773/openglfont.png

Code:
import processing.opengl.*;

void setup(){
 size(400, 400, OPENGL);
 hint(ENABLE_NATIVE_FONTS);
 background(255);
 fill(0);
 PFont font36 = createFont("Arial", 36);
 textFont(font36);
 text("This is sharp text", 10, 40);
 textSize(12);
 text("This looks really blurry in OPENGL when using textSize()", 10, 60);
}

void draw(){
}



Did not change anything. Creating several PFont at different sizes would work but that can't be the trick, eh?
Re: OPENGL textSize() results in blurry font rendering
Reply #5 - Mar 24th, 2010, 9:06am
 
Perhaps disabling smooth..
createFont(name, size, smooth)
Code:
createFont("Arial", 36, false); 

Re: OPENGL textSize() results in blurry font rendering
Reply #6 - Mar 24th, 2010, 9:09am
 
Nope, tried setting smooth to false myself and it didn't help..

If I switch to SansSerif, that seems to do a better job.  Tahoma also has less blur.  So maybe Arial is not the best font option for what your trying to do.
Code:
PFont font36 = createFont("SansSerif", 36); 

Re: OPENGL textSize() results in blurry font rendering
Reply #7 - Mar 24th, 2010, 9:26am
 
Yeah disabling smoothing does not change anything. Of course Arial is not the best choice and I already tried different fonts but never get the good result compared to java2d.
Re: OPENGL textSize() results in blurry font rendering
Reply #8 - Mar 25th, 2010, 5:10am
 
I'm wondering that nobody else complained about this yet (checked the bugs section but did not find that specific problem). Any workaround ideas? I definitely need OpenGL as the renderer.
Re: OPENGL textSize() results in blurry font rendering
Reply #9 - Mar 25th, 2010, 10:25am
 
Not sure if you'll get a different result, but there are several font libraries for Processing.
http://processing.org/reference/libraries/#typography_geometry
Unfortunately, I don't think Vertext has been updated in a while, so I don't think it works correctly.

The glGraphics library also has a new class called glFont.
Page Index Toggle Pages: 1