On 11/05/2009 05:37 PM, Allin Cottrell wrote:

I'm trying to write a function in such a way that (a) it doesn't
use currently deprecated code if that's avoidable while (b) it
builds OK against earlier versions of pango. I'd be grateful if
any pango expert could take a quick look at this and see if
anything looks wrong:

PangoLayout *gp_cairo_create_layout (void)
{
     static PangoFontMap *fontmap;
     PangoContext *context;
     PangoLayout *layout;

     if (fontmap == NULL) {
         fontmap = pango_cairo_font_map_new_for_font_type(CAIRO_FONT_TYPE_FT);
         if (fontmap == NULL) {
            fontmap = pango_cairo_font_map_get_default();
         }
     }

#if PANGO_VERSION_MAJOR>  1 || PANGO_VERSION_MINOR>= 22
     context = pango_font_map_create_context(fontmap);
#else
     context = pango_cairo_font_map_create_context((PangoCairoFontMap *)
                                                   fontmap);
#endif
     layout = pango_layout_new(context);
     g_object_unref(context);

     return layout;
}

My main concern is whether the cast from PangoFontMap to
PangoCairoFontMap is kosher.

Yes, that's fine.

behdad

Thanks!

Allin Cottrell
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to