[cairo] creating graphics for use with cairo

Dan McMahill dan at mcmahill.net
Thu Jan 15 16:25:59 PST 2009


Hello,

I have a gtk app I wrote about 12 years ago.  I've slowly evolved it.  I 
have about a dozen figures (graphics) that get displayed in some of the 
dialogs.  A sample screen shot can be seen at 
http://www.sf.net/gtk-wcalc.html

The figures are drawn with tgif (a nice 2-d vector drawing program) and 
then I export several formats from that:

- png for display on web pages as well as for a CGI version of wcalc
(http://wcalc.sf.net/coupled_microstrip.html for example of one of the 
web pages)

- xpm for displaying in some of my gtk dialogs (see a screen shot at 
http://www.sf.net/gtk-wcalc.html)

- eps for printing.

Currently my printing (written ages ago) is done via a custom dialog box 
and it works by sending postscript code (generated by my code but it 
includes the eps versions of my graphics) to a file or to a program like 
lpr.  This is a hold over from the fact that wcalc was written 
originally for gtk-1.x

Now that gtkprint is available I want to convert over so I can have 
better cross-platform printing support.

I'm totally new to cairo and pango but have managed to get the basics 
working.  I can print out my text information ok.

The problem is the figures.  I've tried loading my png files and 
rendering them with cairo.  The problem is that the bitmap version just 
doesn't look that hot (especially the text in the figure) when printed. 
Especially when compared to the postscript version.  No surprise since 
the postscript version had vector graphics.

Does anyone have suggestions for the right way to deal with these 
graphics?  I still need png for the web pages, probably xpm for my gtk 
dialogs and some vector format for printing.  I understand there is a 
way with SVG to get the printing but I can't seem to get my figures into 
SVG short of re-drawing them in some other tool (inkscape maybe?). 
Programming the figures in cairo would make them  pretty and I guess 
those could go directly in the gtk forms and cairo could produce png's 
but the thought of of recreating a dozen or so figures like this with 
cairo code sounds a bit painful.  In general I prefer using a drawing 
tool as the "source code editor" for the actual figure and then generate 
all the other representations of that figure that I may need.

I have played around a little with trying to use pstoedit to convert my 
.eps files to .svg but haven't managed to get it to work right.

At this point I'm a little unsure of the direction I should take.  Any 
thoughts?

Thanks and sorry for a somewhat long question.

-Dan




More information about the cairo mailing list