[cairo] Cairo, Fonts and Illustrator

Davide Rambaldi davide.rambaldi at ifom-ieo-campus.it
Thu Dec 20 07:06:34 PST 2007


Hi all,

First of all sorry for my bad english.

I am new of the Cairo graphics library and I have a question/problem  
that I try to explain:

I am developing a small project (web server) with cairo-perl binding  
to generate images from biological data in Cairo, the Idea is that  
the user can generate a first version of the image and modify it with  
his favorite software (usally in my field the software is  
Illustrator... sigh!)
The Web Server with Cairo run on a Linux server 2.6.17 gentoo ia64, I  
made the Illustrator test on a laptop G4 with OSX 1.4.11

So the idea is that the software generate a PDF that can be opened  
with illustrator and modified.

THE QUESTIONS:

1) for lines, rectangles and filled rectangle the problem is that the  
fill and the stroke of a rectangle are separeted objects for  
Illustrator (so the user must delete the fill of an object and  
reapply another fill inside illustrator).

May be I call fill and stoke function in the wrong way, actually I am  
doing something like this (in Perl):

$cr -> rectangle(10,10,50,50);
$cr -> fill;
$cr -> rectangle(10,10,50,50);
$cr -> stroke

  Do you thinking that recycling the Path can solve this problem?

2)... the real problem are FONTS, consider this small script:

#!/usr/bin/perl
use strict;
use warnings;
use Cairo;
my $output  = $ARGV[0];
my $pdfsurf = Cairo::PdfSurface->create($output, 256,256);
my $pdfcr   = Cairo::Context->create ($pdfsurf);
$pdfcr -> select_font_face('monospace','normal','normal');
$pdfcr -> set_font_size (40);
$pdfcr->move_to(70,70);
$pdfcr->show_text('HELLO');
$pdfcr->show_page;

On my Web server (linux gentoo) I got the output in attachment  
(linux_hello.pdf),




the glyphs are rendered with the font BitStreamVeraSansMono, my  
Preview software (and also Acrobat) on the laptop can see the font,  
while loading in Illustrator I got the message:

"The font BitstreamVeraSansMono is missing.  Affected text will be  
displayed using a substitute font."

The font is rendered with a series of ??????? and is recognized by  
Illustrator as <BitStreamVeraSansMono◊>.

I have installed the very same true type font on my laptop just  
taking from the server the file Vera.ttf and installing into my  
FontBook on the laptop. Problem is the Illustrator recognized this  
new font as "Bitstream Vera Sans" type "Roman" and doesn't recognize  
the font.

I then made another test: Installing Cairo and cairo-perl on my  
laptop and generating PDF from the laptop (so I am sure that the font  
used by Cairo is inside my system). I run the same script as before  
and I get this output:



Now the "default font" for monospace family should be a courier. I  
open the file in Illustrator and... similar behavior, HELLO is not  
there, there are a series of ?, even if the was no error as before  
(the file open without raising a "font missing" error) and seems that  
Illustrator can recognize the font this time.


To conclude seems that the text written with the function show_text  
doesn't maintain the "string information" or something like this....

Please note that if I use something like:

$cr -> text_path('HELLO')
$cr -> fill

It works but in Illustrator the text is now rendered as a series of  
vector paths, so can't be modifiable by the user with the TEXT TOOL.

Finally I should say that personally I hate Adobe Illustrator, so  
please don't answer me: "why are you using Illustrator?"
I am not an Illustrator user but I want to make an output that can be  
modifiable by a Illustrator user (scientist love Adobe Illustrator)

Any solution/trick for this? If exist, else I will just use cr_fill  
to fill the text path.

Many Thanks in advance


Davide Rambaldi,
Bioinformatics PhD student.
-----------------------------------------------------
Bioinformatic Group IFOM-IEO Campus
Via Adamello 16, Milano
I-20139 Italy

[t] +39 02574303 066
[e] davide.rambaldi at ifom-ieo-campus.it
[i] http://ciccarelli.group.ifom-ieo-campus.it/fcwiki/DavideRambaldi  
(homepage)
[i] http://www.semm.it             (PhD school)
[i] http://www.btbs.unimib.it/     (Master)

-----------------------------------------------------




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20071220/d6502c8a/attachment-0003.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Linux_hello.pdf
Type: application/pdf
Size: 7917 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071220/d6502c8a/attachment-0002.pdf 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20071220/d6502c8a/attachment-0004.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OSX_hello.pdf
Type: application/pdf
Size: 4852 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071220/d6502c8a/attachment-0003.pdf 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20071220/d6502c8a/attachment-0005.htm 


More information about the cairo mailing list