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 › fonts aren't embedded correctly in pdfs
Page Index Toggle Pages: 1
fonts aren't embedded correctly in pdfs (Read 353 times)
fonts aren't embedded correctly in pdfs
Jan 21st, 2009, 11:23pm
 
Hey,

I want to export a sketch with a font embeded and I recognized a somewaht strange behaviour of processing. The pdf exports only correctly (with the correct font) when I place a page first before the one I draw the text on. The text on the first page is always in a standart typeface (in my case helvetica). It's also the same error if I try to use te createFont() command with a ttf Font or a name from the Pfon.list(). Normal drawing commands such as line or rect are processed normal.
The problem is I really need it on the firstpage as I am printing the generated pdf automaticly.
I'm using Processing1.0.1 on a Mac OS X 10.5.6

x
Constantin

Here's a sample code:
Code:

import processing.pdf.*;

PFont font;
PGraphicsPDF pdf;

void setup(){
 size(400,400);
 pdf = (PGraphicsPDF)createGraphics(width, height, PDF, "test.pdf");
 font = createFont("akcon.otf", 24);
 //font = createFont("AkzidenzGrotConBQ-Medium", 24);
 noLoop();
}

void draw(){
 String testText = "The quick brown fox jumps over a lazy dog.";

 beginRecord(pdf);
 background(255);
 fill(0);
 pdf.nextPage();
 textFont(font, 24);
 text(testText, 80, 20, width-40, height-40);
 endRecord();
}



Re: fonts aren't embedded correctly in pdfs
Reply #1 - Jan 21st, 2009, 11:43pm
 
I recently played a bit with PDF output, in Multipage PDF does not work anymore, and I noticed I had to do textFont() on each page. So you should call it before doing nextPage().
Re: fonts aren't embedded correctly in pdfs
Reply #2 - Jan 21st, 2009, 11:51pm
 
I tried that too but it doesn't work.
The above sample code gives you the correct font in the pdf (on the 2nd page though) if you use the nextPage() command before the text. If you remove that command a standart font gets embedded. I only want a one page pdf file.
Re: fonts aren't embedded correctly in pdfs
Reply #3 - Jan 22nd, 2009, 12:26am
 
Ah, I didn't understand you wanted only one page.

Well, if you look at my code, and replace >= 10 by >= 1, it works, without using nextPage(). At least on my Windows XP Pro SP3, with Processing 1.0.1.

Actually, your code works too, after removing the nextPage().

Note that drawing directly on the graphics seems faster than using beginRecord, because there is no display to manage.
Re: fonts aren't embedded correctly in pdfs
Reply #4 - Jan 22nd, 2009, 12:55am
 
PhiLho  wrote on Jan 22nd, 2009, 12:26am:
Actually, your code works too, after removing the nextPage().


Mhh, well maybe it's a Mac problem...because for me it doesn't. I'll try a another computer tommorow and let's see what happens
Re: fonts aren't embedded correctly in pdfs
Reply #5 - Jan 22nd, 2009, 7:45am
 
please file a bug report for it if it's not already in the bugs db:
http://dev.processing.org/

F
Page Index Toggle Pages: 1