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 › export vector typography to pdf
Page Index Toggle Pages: 1
export vector typography to pdf (Read 1748 times)
export vector typography to pdf
Mar 8th, 2010, 11:23am
 
Greetings,

I'm trying to export typography from my processing sketch to pdf using the beginRecord() and endRecord() method. I'm randomizing the fonts used for each letter, so there's an array of typefaces stored and rendered.

The screen output is as expected and pdf is produced, but the letterforms become abstracted to black rectangles rather than keeping their typographic shapes. My output is thus a vector pdf that contains black boxes scaled to the horizontal and vertical dimensions of each letter, rather than clean typography.

Any ideas why this might happen?

Thanks,
Greg
Re: export vector typography to pdf
Reply #1 - Mar 8th, 2010, 2:23pm
 
Quote:
Any ideas why this might happen?

No. Even less as we don't know how you produce your shapes.
Re: export vector typography to pdf
Reply #2 - Mar 8th, 2010, 4:09pm
 
you should try createfont.


Using createFont() (instead of loadFont) enables vector data to be used with the JAVA2D (default) renderer setting. This can be helpful when many font sizes are needed, or when using any renderer based on JAVA2D, such as the PDF library.
Re: export vector typography to pdf
Reply #3 - Mar 11th, 2010, 11:22am
 
To answer Cedric, I'm using loadFont rather than createFont because I'm pulling random typefaces from a big library folder of over 100 vlw font files. To create all fonts every time I run the program would be inefficient.

To answer PhiLho, here's my (probably dirty) code for generating the type:

Code:

void mousePressed() {

PFont TypeNameFont;
//TypeNameFont = loadFont("Interstate-Regular-9.vlw");
TypeNameFont = loadFont("AkzidenzGrotesk-Roman-10.vlw"); //font for displaying letter font type

// Set the left and top margin and kern factor spacing between letters
int margin = 30;
int gap = -2; //determine gap between letters
translate(margin, 0);
float kernFactor = 0;

println("Generating wordmark. Please wait!");
for(int j=0; j< name.length(); j++){
fill(fontColor); //reset back to fontColor from Interface color

int ch = int(random(0,fontList.length));
//println(qArray[j]+". "+fontList[ch]); //displays complete font file name

//remove file extension from font name
String thisString = fontList[ch];
String name = thisString;
int dotPos = thisString.lastIndexOf("-");
if (dotPos > 0)
name = thisString.substring(0, dotPos);
println(qArray[j]+". "+name); // displays font file name without extension

myfont = loadFont(fontList[ch]); //loadfont from data folder vlw font list

textFont(myfont, fontSize);
text(qArray[j], margin+kernFactor, mouseY);

kernFactor = kernFactor+gap+textWidth(qArray[j]); //update kern factor for next letter

//interface elements, font name listing

fill(TypeNameFontColor);

textFont(TypeNameFont, 10); //size of tiny letter font type
//String letterFont = (qArray[j]+" "+name); //name is font name with no extension, this shows Q and font name with space between
String letterFont = (qArray[j]+" ");
String fontName = (name);

text(letterFont, 765, mouseY-96-12*(1-j)); //positions letter name "Q" "U" "I" etc in column to right of wordmark
text(name, 782, mouseY-96-12*(1-j)); //positions font name listing to right of letter name in column

}



Thanks again, any insights would be very helpful!

Best,
Greg
Re: export vector typography to pdf
Reply #4 - Mar 11th, 2010, 11:43am
 
maybe these libraries help.
not sure thought how pdf export works

http://www.nexttext.net/
http://www.ghost-hack.com/p5/vertext/
Re: export vector typography to pdf
Reply #5 - Mar 11th, 2010, 12:15pm
 
deltasounds wrote on Mar 11th, 2010, 11:22am:
I'm using loadFont rather than createFont

See PDF library reference: "If loadFont() is used instead of createFont(), the text may show up bitmapped and ugly."
If you use loadFont, you use bitmaps instead of shapes.
You can use createFont with only one char, I have shown this technique with Random kanji generator sketch.
Efficiency is probably not really important here.
Re: export vector typography to pdf
Reply #6 - Mar 11th, 2010, 9:45pm
 
todays procssing update. doesnt that sound good ?

+ Also in this release, the createFont() method will only load characters
 as they are used, which should greatly improve the font situation on
 non-Roman systems like Japanese. This will use far less memory, and should
 be all around much more efficient. Formerly, createFont() took several
 seconds to run, depending on the speed of your system.
 http://dev.processing.org/bugs/show_bug.cgi?id=1111

Re: export vector typography to pdf
Reply #7 - Mar 12th, 2010, 4:36am
 
Cool, Cedric, I keep missing the announcements because they are sticky... Smiley
Page Index Toggle Pages: 1