Re: Pango + Cairo + Xcb



Matthew Allen wrote:
> Hi,
> 
> I'm writing a backend for a widget set using Pango + Cairo + Xcb. And I've got some text showing up on the screen but I think I still have some misconceptions about how things should be done.
> 
> First I'm starting with this in my singleton font engine class:
> 
> 	Map = pango_cairo_font_map_get_default();
> 	Ctx = pange_cairo_font_map_create_context((PangoCairoFontMap*)Map);
> 
> Then to load a font I do:
> 
> 	Desc = pango_font_description_new();
> 	pango_font_description_set_family(...);
> 	pango_font_description_set_size(...);
> 	Hnd = pango_font_map_load_font(Map, Ctx, Desc);
> 	pango_font_description_free(Desc);

The load_font call is wrong and unnecessary.  You need
pango_context_set_font_description, or pango_layout_set_font_description.

I know the docs are not very helpful in getting the big picture of how to
drive things.  I plan to work on fixing that.

behdad

> That 'Hnd' is stored in a font object. Thats then passed to a "DisplayString" class which maps to a pango layout, which draws a peice of text on the screen. So in there I do:
> 
> 	Layout = pango_layout_new(Ctx);
> 	pango_layout_set_text(Layout, ...);
> 	pango_layout_get_size(Layout, ...);
> 
> But it also has a Draw method to put that layout on screen:
> 
> 	Surface = cairo_xcb_surface_create(...);
> 	Cr = cairo_create(Surface);
> 	cairo_set_source_rgb(Cr, ...);
> 	pango_cairo_show_layout(Cr, Layout);
> 	cairo_destroy(Cr);
> 	cairo_surface_destroy(Surface);
> 
> However I suspect the load font call should be somewhere else, because when I load several fonts I can't draw with the first one anymore... the last one is cached. So should I be doing the load font just before drawing? Is it an expensive call time wise?
> 
> Are these calls in the right order?
> Maybe I have to select the font into the context before drawing with it?
> 
> Thanks for any comments or direction you can provide.
> --
> Matthew Allen
> 
> _______________________________________________
> gtk-i18n-list mailing list
> gtk-i18n-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
> 


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