[cairo] print text to a PostScript (PS) file using Cairo

Vladimir Vukicevic vladimirv at gmail.com
Fri Nov 4 02:26:54 PST 2005


On 10/26/05, Evan Martin <martine at danga.com> wrote:
> On 10/25/05, rush ta <anjutagtk at gmail.com> wrote:
> > hi guys...
> >
> >  I m trying to print text to a PostScript (PS) file using Cairo...
> >
> >  I get the prog to complie and run with out errors...
> >
> >  But the PS file obtained doesnot contain any text ...
> [snip]
> >      surface = cairo_ps_surface_create (FILENAME,
> >                         X_INCHES * 72.0,
> >                         Y_INCHES * 72.0);
> >
> >      cr = cairo_create (surface);
> >      cairo_surface_destroy(surface);
> >
> >      draw (cr);
> >      cairo_show_page (cr);
>
> Right in there, you destroy the surface before you use it.

destroy is a misnomer; it just dereferences the surface, which is
correct, because cairo_create held a reference to the surface in the
returned cairo_t.  This bit of the code looks correct; not sure what's
going on with the ps surface. Try doing some drawing that doesn't
include text rendering (e.g. draw a simple square or something).

    - Vlad


More information about the cairo mailing list