Re: Pango::Layout::create ({ImageSurface Cairo Context})



On Wed, 2007-11-21 at 09:21 +0100, Murray Cumming wrote:
> On Wed, 2007-11-21 at 06:22 +0000, Dale Mellor wrote:
> > On Fri, 2007-11-16 at 11:15 -0600, Jonathon Jongsma wrote:
> > > On Wed, 2007-11-14 at 05:35 +0000, Dale Mellor wrote:
> > > > I'm trying to use pango to write text into a PNG file.  I have a
> > > > Cairo::Context on a Cairo::ImageSurface which works perfectly well with
> > > > graphics, but when I do Pango::Layout::create from this I get a NULL
> > > > object.
> > > > 
> > > > I have seen in the cairofontmap.h header file that the wrapping around
> > > > pango_cairo_font_map_get_default is commented out, so I can't use that
> > > > from which to create a Pango::Context.
> > > > 
> > > > Ideas anybody?
> > > > Thanks in advance.
> > > 
> > > If you could provide a minimal test case to illustrate the issue, that might help people respond more easily.
> > 
> > Here you go.
> > 
> > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > #include <cairomm/cairomm.h>
> > #include <pangomm.h>
> > 
> > int main ()
> > {
> >   Cairo::RefPtr<Cairo::ImageSurface> surface
> >               = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, 750,
> > 600);
> >   
> >   Cairo::RefPtr<Cairo::Context> cairo = Cairo::Context::create
> > (surface);
> > 
> >   Glib::RefPtr <Pango::Layout> pango = Pango::Layout::create (cairo);
> >   
> >   return 0;
> > }
> 
> This produces these warnings. I know they are cryptic, but you can't
> just ignore them:
> 
> (process:8207): glibmm-CRITICAL **: Glib::ObjectBase*
> Glib::wrap_create_new_wrapper(GObject*): assertion `wrap_func_table !=
> 0' failed
> 
> (process:8207): glibmm-WARNING **: failed to wrap type of 'PangoLayout'
> 
> It works if you initialize pangomm. In the attached corrected example I
> have done that by instantiating Gtk::Main. If you don't want to use
> gtkmm then you can use Pango::init() instead, I believe.

Bingo, thank you very much.

I wasn't ignoring the warning, I just thought it was telling me that
Pango::Layout::create wasn't working.  Guess I could not see through the
cryptopgraphy :)

I used Pango::init() in the end, but I had to include pangomm/init.h as
well as the generic pangomm.h.

This isn't really very C++ is it?  Can't you put a singleton somewhere
which makes sure pango is initialized the first time it is used?  Just a
thought.

Thanks again for your help.

Dale

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]