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 & HelpOther Libraries › Bold font extremely fuzzy in pdf
Page Index Toggle Pages: 1
Bold font extremely fuzzy in pdf (Read 2182 times)
Bold font extremely fuzzy in pdf
Apr 2nd, 2010, 6:51am
 
I'm using the processing.pdf.* library to capture snapshots of my sketch.  The non bolded text renders just fine, but the bolded text comes out as a fuzzy blob.  I tried adding textMode(SHAPE) but got an error message saying
"textMode(SHAPE) is not supported by this renderer."

Any suggestions?  My two fonts are
 regular = createFont("GillSans", 12);
 title = loadFont("GillSans-Bold-12.vlw");

Many thanks!
Re: Bold font extremely fuzzy in pdf
Reply #1 - Apr 2nd, 2010, 7:02am
 
Well, that's not surprising, you mix native fonts (look OK) with bitmap fonts (bad rendering). Stick to createFont.
Re: Bold font extremely fuzzy in pdf
Reply #2 - Apr 2nd, 2010, 7:27am
 
Many thanks for the swift response!

I switched to createFont and it isn't fuzzy anymore, but it also isn't rendering as bold in the pdf file (but it is bold in the sketch) and bolding certain elements is important to the overall design.  

Here is the new font
title = createFont("GillSans-Bold", 10);

Any thoughts?  And many thanks.
Re: Bold font extremely fuzzy in pdf
Reply #3 - Apr 2nd, 2010, 2:04pm
 
Not sure... Perhaps try the variant where you specify the TTF font? (something like GILSB__.TTF for example).
Re: Bold font extremely fuzzy in pdf
Reply #4 - Apr 5th, 2010, 9:18pm
 
Thanks for the suggestion.  I tried using .ttf fonts (Bitstream's Vera and Vera Bold) but still the bolded text rendered as regular weight in the pdf snapshot.  Should I put in a bug report?
Re: Bold font extremely fuzzy in pdf
Reply #5 - Apr 6th, 2010, 6:11am
 
Well, with Processing 1.1 on Windows XP SP3, I tried:
Code:
import processing.pdf.*;

PFont fontR;
PFont fontB;

void setup()
{
 size(512, 512, PDF, "test.pdf");
 background(255);
 fontR = createFont("Bitstream Vera Sans", 48);
 fontB = createFont("Bitstream Vera Sans Bold", 48);
 fill(0);
}

void draw()
{
 textFont(fontR);
 text("This is a regular font", 20, 100);
 textFont(fontB);
 text("This is a bold font", 20, 200);
 exit();
}

and the font of the second line was bold.
I tried also with the .ttf files in the data folder:
Code:
import processing.pdf.*;

PFont fontR;
PFont fontB;

void setup()
{
 size(512, 512, PDF, "test.pdf");
 textMode(SHAPE);
 g.textMode = SHAPE;  // Should be done by textMode() call
 background(255);
 fontR = createFont("Vera.ttf", 48);
 fontB = createFont("VeraBd.ttf", 48);
 fill(0);
}

void draw()
{
 textFont(fontR);
 text("This is a regular font", 20, 100);
 textFont(fontB);
 text("This is a bold font", 20, 200);
 exit();
}

I noticed a bug, textMode variable isn't set by textMode() method. I will report it. [EDIT: no need, I just updated my copy of the source to the latest version on SVN and saw it is corrected]
Re: Bold font extremely fuzzy in pdf
Reply #6 - Apr 7th, 2010, 2:20pm
 
Many thanks for looking into this.  I've just upgraded to Processing 0182 (the most recent version I could find), but now I'm having new problems.  I'm using your second example (loading .ttf fonts).  

When I run the program, I get the error message "textMode(SHAPE) is not supported by this renderer".

Then when I try to save a snapshot, I get the following error message "Exception in thread "Animation Thread" java.lang.RuntimeException: Use textMode(SHAPE) with when loading .ttf and .otf files with createFont()."

I'm running OSX 10.5.8, but when I just used your 2nd code snippet as it's own program it ran fine.  

The first code snipped returned the following error "
Use PGraphicsPDF.listFonts() to get a list of fonts that can be used with PDF.
processing.app.debug.RunnerException: RuntimeException: The font “Bitstream Vera Sans” cannot be used with PDF Export."
Re: Bold font extremely fuzzy in pdf
Reply #7 - Apr 7th, 2010, 3:16pm
 
Ok.  Weird workaround.

Just to see what would happen, I moved the textMode(SHAPE) just before the textFont() call that was highlighted when the error message appeared.  

And now everything works fine.  I still get the error message about how "textMode(SHAPE) is not supported by this renderer", but it doesn't interfere with the program running.

FYI: The textFont() that is called first by the program is actually in a subclass.  I don't know if that matters.  

Many, many thanks for all your help.  Maybe a latter release will clear this up entirely.
Page Index Toggle Pages: 1